73 lines
1.9 KiB
YAML
73 lines
1.9 KiB
YAML
|
|
version: '3.8'
|
||
|
|
|
||
|
|
services:
|
||
|
|
# PostgreSQL Database
|
||
|
|
postgres:
|
||
|
|
image: postgres:16-alpine
|
||
|
|
container_name: bmc-hub-postgres-prod
|
||
|
|
environment:
|
||
|
|
POSTGRES_USER: ${POSTGRES_USER}
|
||
|
|
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||
|
|
POSTGRES_DB: ${POSTGRES_DB}
|
||
|
|
volumes:
|
||
|
|
- postgres_data:/var/lib/postgresql/data
|
||
|
|
- ./migrations/init.sql:/docker-entrypoint-initdb.d/init.sql:ro
|
||
|
|
ports:
|
||
|
|
- "${POSTGRES_PORT:-5432}:5432"
|
||
|
|
restart: always
|
||
|
|
healthcheck:
|
||
|
|
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
|
||
|
|
interval: 10s
|
||
|
|
timeout: 5s
|
||
|
|
retries: 5
|
||
|
|
networks:
|
||
|
|
- bmc-hub-network
|
||
|
|
|
||
|
|
# FastAPI Application - Production with GitHub Release Version
|
||
|
|
api:
|
||
|
|
build:
|
||
|
|
context: .
|
||
|
|
dockerfile: Dockerfile
|
||
|
|
args:
|
||
|
|
RELEASE_VERSION: ${RELEASE_VERSION:-latest}
|
||
|
|
GITHUB_TOKEN: ${GITHUB_TOKEN}
|
||
|
|
GITHUB_REPO: ${GITHUB_REPO:-ct/bmc_hub}
|
||
|
|
image: bmc-hub:${RELEASE_VERSION:-latest}
|
||
|
|
container_name: bmc-hub-api-prod
|
||
|
|
depends_on:
|
||
|
|
postgres:
|
||
|
|
condition: service_healthy
|
||
|
|
ports:
|
||
|
|
- "${API_PORT:-8000}:8000"
|
||
|
|
volumes:
|
||
|
|
- ./logs:/app/logs
|
||
|
|
- ./uploads:/app/uploads
|
||
|
|
- ./data:/app/data
|
||
|
|
# NOTE: No source code mount in production - code comes from GitHub release
|
||
|
|
env_file:
|
||
|
|
- .env
|
||
|
|
environment:
|
||
|
|
# Override database URL to point to postgres service
|
||
|
|
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB}
|
||
|
|
- ENABLE_RELOAD=false
|
||
|
|
restart: always
|
||
|
|
healthcheck:
|
||
|
|
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
|
||
|
|
interval: 30s
|
||
|
|
timeout: 10s
|
||
|
|
retries: 3
|
||
|
|
start_period: 40s
|
||
|
|
networks:
|
||
|
|
- bmc-hub-network
|
||
|
|
labels:
|
||
|
|
- "com.bmcnetworks.app=bmc-hub"
|
||
|
|
- "com.bmcnetworks.version=${RELEASE_VERSION:-latest}"
|
||
|
|
|
||
|
|
networks:
|
||
|
|
bmc-hub-network:
|
||
|
|
driver: bridge
|
||
|
|
|
||
|
|
volumes:
|
||
|
|
postgres_data:
|
||
|
|
driver: local
|