feat: add Docker Compose developer environment with Makefile shortcuts (M4)
- Root docker-compose.yml: backend (python:3.11-slim) + frontend (multi-stage node build -> nginx:alpine) on the newzy-network bridge network, frontend waits for the backend health check - Persistent SQLite via bind mount ./data/db -> /app/data/db - .env / .env.example documenting DATABASE_URL, DEBUG, BACKEND_CORS_ORIGINS and FRONTEND_API_URL - Makefile: dev, stop, restart, build, logs, status, backend-start, frontend-start, test, e2e, shell-backend, shell-frontend, clean - data/.gitignore keeps the data/ structure in git while excluding the database; root .gitignore drops the overly broad data/ rule and adds docker-compose.override.yml - backend: .gitignore covers .env.*, Dockerfile sets unbuffered python and pre-creates the db volume dir; frontend: new .dockerignore - README: full Docker setup docs (prerequisites, quick start, services, ports, network/storage, env vars, Makefile reference, troubleshooting)
This commit is contained in:
1 parent
9144411e0f
commit
ed7b30438e
11 files changed
+653
-15
No files matched your search
+39
-2
@@ -1,23 +1,60 @@
|
||||
# newzy — full application stack (FastAPI backend + Nginx frontend).
|
||||
#
|
||||
# make dev # build (if needed) and start both services in the background
|
||||
# make stop # stop and remove the containers (local data is kept)
|
||||
# make clean # stop everything and remove containers, volumes and data/
|
||||
#
|
||||
# Environment variables are read from `.env` in this directory (template:
|
||||
# `.env.example`). See README.md for the complete developer documentation.
|
||||
#
|
||||
# The `version` key is intentionally omitted: it is obsolete in Compose v2
|
||||
# and only produces a deprecation warning.
|
||||
|
||||
services:
|
||||
backend:
|
||||
build: ./backend
|
||||
build:
|
||||
context: ./backend
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "8000:8000"
|
||||
volumes:
|
||||
# Persistent SQLite database: ./data/db on the host -> /app/data/db
|
||||
# inside the container (excluded from git, see data/.gitignore).
|
||||
- ./data/db:/app/data/db
|
||||
environment:
|
||||
- DATABASE_URL=sqlite:///./data/db/newzy.db
|
||||
- DEBUG=false
|
||||
- BACKEND_CORS_ORIGINS=http://localhost:3000,http://localhost:5173
|
||||
healthcheck:
|
||||
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
networks:
|
||||
- newzy-network
|
||||
restart: unless-stopped
|
||||
|
||||
frontend:
|
||||
build: ./frontend
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "3000:80"
|
||||
depends_on:
|
||||
backend:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- newzy-network
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
newzy-network:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.28.0.0/16
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
name: newzy-db-data
|
||||
Reference in new issue
Block a user