Files
baby-monitor/docs/DOCKER_USAGE.md
T

187 lines
3.8 KiB
Markdown

# Baby Monitor - Self-Contained Docker Image
This Docker image is a self-contained service ready for deployment with all optional dependencies pre-installed.
## Quick Start
```bash
docker run -p 8000:8000 baby-monitor
```
Access the application at `http://localhost:8000`
## Features
This image includes all optional dependencies:
-**Redis** support for distributed token storage
-**PostgreSQL** support for scalable database backend
-**SQLite** built-in for single-instance deployments
## Configuration
Configure the service using environment variables:
### Basic Configuration
| Variable | Default | Description |
| ---------------- | ------------ | --------------------------------------- |
| `ENVIRONMENT` | `production` | Set to `development` to enable API docs |
| `DATA_DIR` | `/data` | Directory for SQLite database |
| `ADMIN_USERNAME` | `admin` | Admin username |
| `ADMIN_PASSWORD` | _(required)_ | Admin password (required in production) |
### Redis Configuration (Optional)
| Variable | Description |
| ----------- | --------------------------------------------------- |
| `REDIS_URI` | Redis connection URI (e.g., `redis://redis:6379/0`) |
When `REDIS_URI` is set, the application uses Redis for token storage instead of in-memory storage.
### PostgreSQL Configuration (Optional)
_Coming soon_
## Examples
### Basic Deployment
```bash
docker run -d \
-p 8000:8000 \
-e ADMIN_PASSWORD=your_secure_password \
-v ./data:/data \
baby-monitor
```
### With Redis
```bash
# Start Redis
docker run -d --name redis redis:7-alpine
# Start Baby Monitor with Redis
docker run -d \
-p 8000:8000 \
-e ADMIN_PASSWORD=your_secure_password \
-e REDIS_URI=redis://redis:6379/0 \
--link redis \
baby-monitor
```
### Using Docker Compose
```yaml
version: "3.8"
services:
app:
image: baby-monitor
ports:
- "8000:8000"
environment:
- ADMIN_PASSWORD=your_secure_password
- REDIS_URI=redis://redis:6379/0
volumes:
- ./data:/data
depends_on:
- redis
redis:
image: redis:7-alpine
volumes:
- redis-data:/data
volumes:
redis-data:
```
## Health Checks
The image provides several endpoints for monitoring:
- `GET /health` - Basic health check (returns `{"status": "healthy"}`)
- `GET /ready` - Readiness check for orchestration
- `GET /info` - Service information including installed features
Example:
```bash
curl http://localhost:8000/info
```
Response:
```json
{
"service": "baby-monitor",
"version": "0.1.0",
"features": {
"redis": true,
"postgresql": true
},
"config": {
"environment": "production",
"data_dir": "/data",
"redis_configured": true
}
}
```
## Volumes
- `/data` - Persistent storage for SQLite database
Mount this directory to preserve data across container restarts:
```bash
docker run -v /path/on/host:/data baby-monitor
```
## Ports
- `8000` - HTTP API server
## Security Notes
1. **Always set `ADMIN_PASSWORD`** in production
2. Use **strong passwords** (minimum 16 characters)
3. Run behind a **reverse proxy** with HTTPS
4. Use **Redis** for multi-instance deployments
5. **Back up** the `/data` directory regularly
## Troubleshooting
### Check installed features
```bash
curl http://localhost:8000/info
```
### View logs
```bash
docker logs <container-name>
```
### Verify Redis connection
Look for startup message:
```bash
✓ Connected to Redis at redis://...
```
### Test authentication
```bash
curl -X POST http://localhost:8000/api/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"your_password"}'
```
## Support
For issues and feature requests, please visit the project repository.