extending docker setup README
This commit is contained in:
205
README-Docker.md
205
README-Docker.md
@@ -174,3 +174,208 @@ services:
|
|||||||
- .:/app
|
- .:/app
|
||||||
command: ["flask", "run", "--host", "0.0.0.0", "--port", "8000"]
|
command: ["flask", "run", "--host", "0.0.0.0", "--port", "8000"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Coolify Deployment
|
||||||
|
|
||||||
|
This application can be deployed on [Coolify](https://coolify.io) using Docker Compose. Coolify provides additional features and management capabilities for containerized applications.
|
||||||
|
|
||||||
|
### Coolify Prerequisites
|
||||||
|
|
||||||
|
- Coolify instance (self-hosted or cloud)
|
||||||
|
- Git repository accessible to Coolify
|
||||||
|
|
||||||
|
### Coolify-Specific Configuration
|
||||||
|
|
||||||
|
#### 1. Environment Variables
|
||||||
|
|
||||||
|
Coolify automatically detects environment variables in your `docker-compose.yml` and provides a UI to manage them. Use the following syntax for better integration:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
jobs-app:
|
||||||
|
environment:
|
||||||
|
# Required variables (will show red border if empty)
|
||||||
|
- FLASK_SECRET=${FLASK_SECRET:?}
|
||||||
|
|
||||||
|
# Required with default (prefilled but editable)
|
||||||
|
- FLASK_ENV=${FLASK_ENV:?production}
|
||||||
|
|
||||||
|
# Optional with default
|
||||||
|
- GUNICORN_WORKERS=${GUNICORN_WORKERS:-4}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Coolify Magic Environment Variables
|
||||||
|
|
||||||
|
Leverage Coolify's dynamic environment variables:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
jobs-app:
|
||||||
|
environment:
|
||||||
|
# Generate FQDN for the application
|
||||||
|
- SERVICE_FQDN_JOBS_APP
|
||||||
|
|
||||||
|
# Generate secure password for admin user
|
||||||
|
- ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN:?M11ffpgm.}
|
||||||
|
|
||||||
|
# Generate database credentials
|
||||||
|
- DB_USER=${SERVICE_USER_DB:?jobs}
|
||||||
|
- DB_PASSWORD=${SERVICE_PASSWORD_DB:?jobdb}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Storage Configuration
|
||||||
|
|
||||||
|
Coolify supports advanced storage options:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
jobs-app:
|
||||||
|
volumes:
|
||||||
|
# Create empty directories
|
||||||
|
- type: bind
|
||||||
|
source: ./cache
|
||||||
|
target: /app/cache
|
||||||
|
is_directory: true
|
||||||
|
|
||||||
|
- type: bind
|
||||||
|
source: ./logs
|
||||||
|
target: /app/logs
|
||||||
|
is_directory: true
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
volumes:
|
||||||
|
# Persistent database storage
|
||||||
|
- mysql_data:/var/lib/mysql
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 4. Health Checks and Service Management
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
services:
|
||||||
|
jobs-app:
|
||||||
|
# Exclude from health checks if needed
|
||||||
|
exclude_from_hc: false
|
||||||
|
|
||||||
|
# Labels for Coolify management
|
||||||
|
labels:
|
||||||
|
- coolify.managed=true
|
||||||
|
- traefik.enable=true
|
||||||
|
- "traefik.http.routers.jobs-app.rule=Host(`${SERVICE_FQDN_JOBS_APP:-localhost}`)"
|
||||||
|
- traefik.http.routers.jobs-app.entryPoints=http
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 5. Database Configuration for Coolify
|
||||||
|
|
||||||
|
Update your `config/settings.json` to use Coolify environment variables:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"database": {
|
||||||
|
"mysql": {
|
||||||
|
"host": "mysql",
|
||||||
|
"user": "${DB_USER:-jobs}",
|
||||||
|
"password": "${DB_PASSWORD:-jobdb}",
|
||||||
|
"database": "jobs",
|
||||||
|
"port": 3306
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Complete Coolify docker-compose.yml
|
||||||
|
|
||||||
|
Here's a complete `docker-compose.yml` optimized for Coolify:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
jobs-app:
|
||||||
|
build: .
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
environment:
|
||||||
|
# Required environment variables
|
||||||
|
- FLASK_SECRET=${FLASK_SECRET:?}
|
||||||
|
- FLASK_ENV=${FLASK_ENV:?production}
|
||||||
|
|
||||||
|
# Coolify magic variables
|
||||||
|
- SERVICE_FQDN_JOBS_APP
|
||||||
|
- ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN:?M11ffpgm.}
|
||||||
|
- DB_USER=${SERVICE_USER_DB:?jobs}
|
||||||
|
- DB_PASSWORD=${SERVICE_PASSWORD_DB:?jobdb}
|
||||||
|
|
||||||
|
# Optional configuration
|
||||||
|
- GUNICORN_WORKERS=${GUNICORN_WORKERS:-4}
|
||||||
|
volumes:
|
||||||
|
- type: bind
|
||||||
|
source: ./cache
|
||||||
|
target: /app/cache
|
||||||
|
is_directory: true
|
||||||
|
- type: bind
|
||||||
|
source: ./logs
|
||||||
|
target: /app/logs
|
||||||
|
is_directory: true
|
||||||
|
depends_on:
|
||||||
|
- mysql
|
||||||
|
labels:
|
||||||
|
- coolify.managed=true
|
||||||
|
- traefik.enable=true
|
||||||
|
- "traefik.http.routers.jobs-app.rule=Host(`${SERVICE_FQDN_JOBS_APP:-localhost}`)"
|
||||||
|
- traefik.http.routers.jobs-app.entryPoints=http
|
||||||
|
networks:
|
||||||
|
- jobs-network
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
mysql:
|
||||||
|
image: mysql:8.0
|
||||||
|
environment:
|
||||||
|
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD:?rootpassword}
|
||||||
|
- MYSQL_DATABASE=jobs
|
||||||
|
- MYSQL_USER=${DB_USER:-jobs}
|
||||||
|
- MYSQL_PASSWORD=${DB_PASSWORD:-jobdb}
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
|
volumes:
|
||||||
|
- mysql_data:/var/lib/mysql
|
||||||
|
- ./mysql-init:/docker-entrypoint-initdb.d
|
||||||
|
networks:
|
||||||
|
- jobs-network
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql_data:
|
||||||
|
|
||||||
|
networks:
|
||||||
|
jobs-network:
|
||||||
|
driver: bridge
|
||||||
|
```
|
||||||
|
|
||||||
|
### Coolify Deployment Steps
|
||||||
|
|
||||||
|
1. **Connect Repository**: Link your Git repository to Coolify
|
||||||
|
2. **Create Service Stack**: Choose "Docker Compose" as the build pack
|
||||||
|
3. **Configure Environment Variables**: Set required variables in Coolify's UI:
|
||||||
|
- `FLASK_SECRET`: Generate a secure random string
|
||||||
|
- `FLASK_ENV`: Set to "production"
|
||||||
|
- `MYSQL_ROOT_PASSWORD`: Set a secure password
|
||||||
|
4. **Deploy**: Coolify will automatically build and deploy your application
|
||||||
|
5. **Access**: Use the generated FQDN to access your application
|
||||||
|
|
||||||
|
### Coolify Benefits
|
||||||
|
|
||||||
|
- **Automatic SSL**: HTTPS certificates are automatically managed
|
||||||
|
- **Environment Management**: Easy variable management through UI
|
||||||
|
- **Monitoring**: Built-in logging and health monitoring
|
||||||
|
- **Scaling**: Easy horizontal scaling
|
||||||
|
- **Backups**: Automated backup capabilities
|
||||||
|
- **Security**: Isolated networks and secure defaults
|
||||||
|
|
||||||
|
### Troubleshooting Coolify Deployments
|
||||||
|
|
||||||
|
1. **Environment Variables**: Check that all required variables are set in Coolify's UI
|
||||||
|
2. **Build Logs**: Review build logs for any compilation errors
|
||||||
|
3. **Network Issues**: Ensure services can communicate within the stack
|
||||||
|
4. **Storage Permissions**: Verify volume permissions are correct
|
||||||
|
5. **FQDN Configuration**: Check that the generated FQDN is accessible
|
||||||
|
|
||||||
|
For more information, visit the [Coolify Docker Compose documentation](https://coolify.io/docs/knowledge-base/docker/compose).
|
||||||
|
|||||||
Reference in New Issue
Block a user