Split Docker config for dev/prod and fix arch-agnostic builds
- Dockerfile: use --platform=$BUILDPLATFORM + ARG TARGETARCH instead of hardcoded GOARCH=arm64, enabling cross-compilation and native builds on both arm64 (M1) and amd64 (prod server) - docker-compose.yml: rewrite for Docker Swarm — image refs, deploy sections, overlay network, no container_name/depends_on conditions, DB/Redis ports not exposed externally - docker-compose.dev.yml: rewrite as self-contained dev compose with build targets, container_name, depends_on, dev-safe defaults - Makefile: switch to docker compose v2, point dev targets at docker-compose.dev.yml, add docker-build-prod target - Delete stale docker/Dockerfile (Go 1.21) and docker/docker-compose.yml Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,40 +1,189 @@
|
||||
# Development configuration - use with:
|
||||
# docker-compose -f docker-compose.yml -f docker-compose.dev.yml up
|
||||
# Local development compose file (self-contained, no base file needed)
|
||||
# Usage:
|
||||
# docker compose -f docker-compose.dev.yml up --build
|
||||
|
||||
services:
|
||||
# PostgreSQL Database
|
||||
db:
|
||||
image: postgres:16-alpine
|
||||
container_name: casera-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-casera}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-casera_dev_password}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-casera}
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5433:5432" # Use 5433 to avoid conflicts with other projects
|
||||
- "${DB_PORT:-5433}:5432" # 5433 externally to avoid conflicts with local postgres
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-casera} -d ${POSTGRES_DB:-casera}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- casera-network
|
||||
|
||||
# Redis Cache
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
container_name: casera-redis
|
||||
restart: unless-stopped
|
||||
command: redis-server --appendonly yes
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
ports:
|
||||
- "6380:6379" # Use 6380 to avoid conflicts
|
||||
- "${REDIS_PORT:-6379}:6379"
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
networks:
|
||||
- casera-network
|
||||
|
||||
# Casera API
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
target: api
|
||||
environment:
|
||||
DEBUG: "true"
|
||||
volumes:
|
||||
- ./:/app/src:ro # Mount source for debugging
|
||||
container_name: casera-api
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "${PORT:-8000}:8000"
|
||||
environment:
|
||||
# Server
|
||||
PORT: "8000"
|
||||
DEBUG: "true"
|
||||
ALLOWED_HOSTS: "localhost,127.0.0.1"
|
||||
TIMEZONE: "${TIMEZONE:-UTC}"
|
||||
|
||||
# Database
|
||||
DB_HOST: db
|
||||
DB_PORT: "5432"
|
||||
POSTGRES_USER: ${POSTGRES_USER:-casera}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-casera_dev_password}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-casera}
|
||||
DB_SSLMODE: "disable"
|
||||
|
||||
# Redis
|
||||
REDIS_URL: "redis://redis:6379/0"
|
||||
|
||||
# Security
|
||||
SECRET_KEY: ${SECRET_KEY:-dev-secret-key-change-in-production-min-32-chars}
|
||||
|
||||
# Email
|
||||
EMAIL_HOST: ${EMAIL_HOST:-smtp.gmail.com}
|
||||
EMAIL_PORT: ${EMAIL_PORT:-587}
|
||||
EMAIL_HOST_USER: ${EMAIL_HOST_USER}
|
||||
EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD}
|
||||
DEFAULT_FROM_EMAIL: ${DEFAULT_FROM_EMAIL:-Casera <noreply@casera.com>}
|
||||
EMAIL_USE_TLS: "true"
|
||||
|
||||
# Push Notifications
|
||||
APNS_AUTH_KEY_PATH: ${APNS_AUTH_KEY_PATH}
|
||||
APNS_AUTH_KEY_ID: ${APNS_AUTH_KEY_ID}
|
||||
APNS_TEAM_ID: ${APNS_TEAM_ID}
|
||||
APNS_TOPIC: ${APNS_TOPIC:-com.example.casera}
|
||||
APNS_USE_SANDBOX: "true"
|
||||
FCM_SERVER_KEY: ${FCM_SERVER_KEY}
|
||||
volumes:
|
||||
- ./push_certs:/certs:ro
|
||||
- ./uploads:/app/uploads
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://127.0.0.1:8000/api/health/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
start_period: 10s
|
||||
retries: 3
|
||||
networks:
|
||||
- casera-network
|
||||
|
||||
# Casera Admin Panel (Next.js)
|
||||
admin:
|
||||
build:
|
||||
context: .
|
||||
target: admin
|
||||
environment:
|
||||
NEXT_PUBLIC_API_URL: "http://localhost:8000"
|
||||
container_name: casera-admin
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "${ADMIN_PORT:-3000}:3000"
|
||||
environment:
|
||||
PORT: "3000"
|
||||
HOSTNAME: "0.0.0.0"
|
||||
NEXT_PUBLIC_API_URL: "${NEXT_PUBLIC_API_URL:-http://api:8000}"
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3000/admin/"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
networks:
|
||||
- casera-network
|
||||
|
||||
# Casera Worker (Background Jobs)
|
||||
worker:
|
||||
build:
|
||||
context: .
|
||||
target: worker
|
||||
container_name: casera-worker
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
DEBUG: "true"
|
||||
# Database
|
||||
DB_HOST: db
|
||||
DB_PORT: "5432"
|
||||
POSTGRES_USER: ${POSTGRES_USER:-casera}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-casera_dev_password}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-casera}
|
||||
DB_SSLMODE: "disable"
|
||||
|
||||
# Redis
|
||||
REDIS_URL: "redis://redis:6379/0"
|
||||
|
||||
# Security
|
||||
SECRET_KEY: ${SECRET_KEY:-dev-secret-key-change-in-production-min-32-chars}
|
||||
|
||||
# Push Notifications
|
||||
APNS_AUTH_KEY_PATH: "/certs/apns_key.p8"
|
||||
APNS_AUTH_KEY_ID: ${APNS_AUTH_KEY_ID}
|
||||
APNS_TEAM_ID: ${APNS_TEAM_ID}
|
||||
APNS_TOPIC: ${APNS_TOPIC:-com.example.casera}
|
||||
APNS_USE_SANDBOX: "true"
|
||||
FCM_SERVER_KEY: ${FCM_SERVER_KEY}
|
||||
|
||||
# Email
|
||||
EMAIL_HOST: ${EMAIL_HOST:-smtp.gmail.com}
|
||||
EMAIL_PORT: ${EMAIL_PORT:-587}
|
||||
EMAIL_HOST_USER: ${EMAIL_HOST_USER}
|
||||
EMAIL_HOST_PASSWORD: ${EMAIL_HOST_PASSWORD}
|
||||
DEFAULT_FROM_EMAIL: ${DEFAULT_FROM_EMAIL:-Casera <noreply@casera.com>}
|
||||
EMAIL_USE_TLS: "true"
|
||||
|
||||
# Worker settings (UTC hours for scheduled jobs)
|
||||
TASK_REMINDER_HOUR: ${TASK_REMINDER_HOUR:-14}
|
||||
OVERDUE_REMINDER_HOUR: ${OVERDUE_REMINDER_HOUR:-15}
|
||||
DAILY_DIGEST_HOUR: ${DAILY_DIGEST_HOUR:-3}
|
||||
volumes:
|
||||
- ./:/app/src:ro
|
||||
- ./push_certs:/certs:ro
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- casera-network
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
|
||||
networks:
|
||||
casera-network:
|
||||
driver: bridge
|
||||
|
||||
Reference in New Issue
Block a user