Shumiland/docker-compose.prod.yml
Vadym Samoilenko c707a70065
Some checks are pending
CI / Type Check (push) Waiting to run
CI / Lint (push) Waiting to run
CI / Unit Tests (push) Waiting to run
Deploy / Build & Push Image (push) Waiting to run
Deploy / Deploy to VPS (push) Blocked by required conditions
feat(migrations): remove push:true, run migrations automatically on deploy
- Remove push:true from postgres adapter (unreliable for new columns)
- Remove profile:tools from migrate service so it runs on every deploy
- Add restart:no to migrate service (one-shot runner)
- App now depends on migrate with service_completed_successfully condition:
  postgres healthy → migrate applies pending → app starts

Workflow for future schema changes:
  1. Add field to collection/global TypeScript
  2. ssh server: docker-compose run --rm migrate migrate:create --name <field>
  3. git pull the generated .ts migration file
  4. commit + push → next deploy applies it automatically

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13 19:11:50 +01:00

88 lines
2.3 KiB
YAML

services:
postgres:
image: postgres:16-alpine
container_name: shumiland-postgres
environment:
POSTGRES_USER: shumiland
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: shumiland
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ['CMD-SHELL', 'pg_isready -U shumiland']
interval: 10s
timeout: 5s
retries: 5
restart: unless-stopped
networks:
- internal
migrate:
build:
context: .
dockerfile: Dockerfile.migrator
container_name: shumiland-migrate
env_file: .env.production
depends_on:
postgres:
condition: service_healthy
volumes:
- ./migrations:/app/migrations
networks:
- internal
restart: "no"
app:
build: .
container_name: shumiland-app
env_file: .env.production
depends_on:
postgres:
condition: service_healthy
migrate:
condition: service_completed_successfully
volumes:
- media_uploads:/app/media
restart: unless-stopped
networks:
- internal
- traefik-public
labels:
- traefik.enable=true
- traefik.http.routers.shumiland.rule=Host(`shumi.ai-impress.com`)
- traefik.http.routers.shumiland.entrypoints=websecure
- traefik.http.routers.shumiland.tls.certresolver=cloudflare
- traefik.http.services.shumiland.loadbalancer.server.port=3000
- traefik.http.routers.shumiland.middlewares=security-headers@file
pg_backup:
image: alpine:3
volumes:
- postgres_data:/var/lib/postgresql/data:ro
- ./backups:/backups
environment:
POSTGRES_USER: shumiland
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: shumiland
POSTGRES_HOST: postgres
command: >-
sh -c "apk add --no-cache postgresql-client &&
echo '0 3 * * * pg_dump postgresql://$$POSTGRES_USER:$$POSTGRES_PASSWORD@$$POSTGRES_HOST/$$POSTGRES_DB | gzip > /backups/shumiland_$$(date +\%Y\%m\%d_\%H\%M\%S).sql.gz && find /backups -mtime +14 -delete' | crontab - &&
crond -f"
depends_on:
- postgres
restart: unless-stopped
networks:
- internal
networks:
internal:
name: shumiland-internal
traefik-public:
external: true
volumes:
postgres_data:
name: shumiland-postgres-data
media_uploads:
name: shumiland-media-uploads