-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
97 lines (91 loc) · 2.93 KB
/
Copy pathdocker-compose.yml
File metadata and controls
97 lines (91 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Project name: prefixes containers, networks and the default volume with
# "basquets" (e.g. basquets-backend-1, basquets_default).
name: basquets
services:
db:
image: postgres:16-alpine
environment:
POSTGRES_DB: basketball_stats
POSTGRES_USER: basketball_stats
POSTGRES_PASSWORD: basketball_stats
ports:
# Host port 5433 (container 5432) to avoid clashing with other local
# Postgres instances. Containers still reach it internally at db:5432.
- "5433:5432"
volumes:
# Bind-mount to ./data/postgres so the DB survives docker volume prune,
# docker compose down -v, and Docker Desktop resets. The directory is
# git-ignored; never commit it.
- ./data/postgres:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U basketball_stats"]
interval: 5s
timeout: 5s
retries: 10
redis:
image: redis:7-alpine
ports:
# Host port 6380 (container 6379) to avoid clashing with other local
# Redis instances. Containers still reach it internally at redis:6379.
- "6380:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 10
backend:
image: basquets-backend
build:
context: ./backend
command: python manage.py runserver 0.0.0.0:8000
# Run as the host user so the container can write to the bind-mounted
# ./backend directory (media uploads, collectstatic). UID/GID default to
# 1000 (typical first regular user on Linux/WSL2).
user: "${UID:-1000}:${GID:-1000}"
volumes:
- ./backend:/app
ports:
- "8000:8000"
env_file:
- ./backend/.env
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
worker:
# Reuses the backend image (same code/dependencies) instead of building a
# second identical image; `make build` builds basquets-backend once.
image: basquets-backend
# Single process running both the Celery worker and Celery Beat scheduler,
# appropriate for a low-traffic, non-commercial deployment.
command: celery -A config worker --beat --loglevel=info
user: "${UID:-1000}:${GID:-1000}"
volumes:
- ./backend:/app
env_file:
- ./backend/.env
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
frontend:
image: basquets-frontend
build:
context: ./frontend
command: npm run dev
volumes:
- ./frontend:/app
- /app/node_modules
ports:
- "3000:3000"
env_file:
- ./frontend/.env.local
environment:
# Server-side (SSR) fetches reach the backend over the compose network.
# The browser still uses NEXT_PUBLIC_API_BASE_URL from .env.local.
- API_INTERNAL_BASE_URL=http://backend:8000/api/v1
depends_on:
- backend
# No top-level named volumes — db uses a bind mount (./data/postgres).