Two issues caused DB reset on every deploy: 1. docker-compose.prod.yml used bind mount (./data/postgres) with PostgreSQL 18's incompatible /var/lib/postgresql/data path. 2. The Gitea CI runner shares Docker socket with the host, but ./data/postgres resolves to a temp path inside the runner container. Each deploy creates a fresh workspace, so the bind mount always points to an empty directory on the host. Fix: Use a named Docker volume (same as docker-compose.yml dev config). Named volumes are managed by Docker daemon directly, survive container recreation, and don't depend on working directory resolution. Also fix deploy.yml: remove unnecessary mkdir for data dirs, write backup to /tmp instead of relative path. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
76 lines
1.9 KiB
YAML
76 lines
1.9 KiB
YAML
# Production Docker Compose
|
|
# Usage: docker compose -f docker-compose.prod.yml up -d
|
|
#
|
|
# DB data is stored in a named volume (galaxis-po_postgres_data).
|
|
# This survives container recreation and avoids path resolution issues
|
|
# when deploying via CI runners with shared Docker sockets.
|
|
# To back up: docker exec galaxis-po-db pg_dump -U $DB_USER $DB_NAME > backup.sql
|
|
# Volume is only removed with: docker volume rm galaxis-po_postgres_data
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:18-alpine
|
|
container_name: galaxis-po-db
|
|
environment:
|
|
POSTGRES_USER: ${DB_USER}
|
|
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
|
POSTGRES_DB: ${DB_NAME}
|
|
volumes:
|
|
- postgres_data:/var/lib/postgresql
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 5
|
|
restart: always
|
|
networks:
|
|
- galaxy-net
|
|
|
|
backend:
|
|
build:
|
|
context: ./backend
|
|
dockerfile: Dockerfile
|
|
container_name: galaxis-po-backend
|
|
env_file:
|
|
- .env.prod
|
|
environment:
|
|
DATABASE_URL: postgresql://${DB_USER}:${DB_PASSWORD}@postgres:5432/${DB_NAME}
|
|
PYTHONPATH: /app
|
|
depends_on:
|
|
postgres:
|
|
condition: service_healthy
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
|
|
interval: 30s
|
|
timeout: 10s
|
|
start_period: 10s
|
|
retries: 3
|
|
restart: always
|
|
networks:
|
|
- galaxy-net
|
|
|
|
frontend:
|
|
build:
|
|
context: ./frontend
|
|
dockerfile: Dockerfile
|
|
target: production
|
|
container_name: galaxis-po-frontend
|
|
environment:
|
|
BACKEND_URL: http://backend:8000
|
|
ports:
|
|
- "3000:3000"
|
|
depends_on:
|
|
backend:
|
|
condition: service_healthy
|
|
restart: always
|
|
networks:
|
|
- galaxy-net
|
|
|
|
networks:
|
|
galaxy-net:
|
|
driver: bridge
|
|
|
|
volumes:
|
|
postgres_data:
|
|
driver: local
|