Initial commit
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
59
docker-compose.yml
Normal file
59
docker-compose.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
services:
|
||||
|
||||
# ── MySQL ────────────────────────────────────────────────────────────────────
|
||||
db:
|
||||
image: mysql:8.0
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
|
||||
MYSQL_DATABASE: ${MYSQL_DATABASE}
|
||||
MYSQL_USER: ${MYSQL_USER}
|
||||
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
|
||||
volumes:
|
||||
- mysql_data:/var/lib/mysql # persistent data
|
||||
- ./mysql/init.sql:/docker-entrypoint-initdb.d/init.sql:ro # run once on first start
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${MYSQL_ROOT_PASSWORD}"]
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 5
|
||||
start_period: 30s
|
||||
networks:
|
||||
- backend
|
||||
|
||||
# ── FastAPI ──────────────────────────────────────────────────────────────────
|
||||
api:
|
||||
build: ./backend
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
||||
environment:
|
||||
DATABASE_URL: mysql+pymysql://${MYSQL_USER}:${MYSQL_PASSWORD}@db/${MYSQL_DATABASE}
|
||||
depends_on:
|
||||
db:
|
||||
condition: service_healthy # wait for MySQL to be ready before starting
|
||||
networks:
|
||||
- backend
|
||||
|
||||
# ── Nginx ────────────────────────────────────────────────────────────────────
|
||||
nginx:
|
||||
image: nginx:alpine
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8056:80"
|
||||
volumes:
|
||||
- ./nginx/html:/usr/share/nginx/html:ro # static files — edit locally, live immediately
|
||||
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro # nginx config
|
||||
depends_on:
|
||||
- api
|
||||
networks:
|
||||
- backend
|
||||
|
||||
# ── Volumes ───────────────────────────────────────────────────────────────────
|
||||
volumes:
|
||||
mysql_data: # survives container restarts and rebuilds
|
||||
|
||||
# ── Networks ──────────────────────────────────────────────────────────────────
|
||||
networks:
|
||||
backend:
|
||||
driver: bridge
|
||||
Reference in New Issue
Block a user