-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
executable file
·200 lines (194 loc) · 5.79 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
executable file
·200 lines (194 loc) · 5.79 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# ============================================
# Docker Compose para DESARROLLO - NexFit365
# ============================================
# 📁 Carpeta: /srv/mykaizenfit/dev/
#
# ⚠️ ESTE ARCHIVO ES PARA DESARROLLO con servicios y datos aislados de producción
#
# COMANDOS:
# Iniciar: COMPOSE_PROJECT_NAME=mykaizenfit-dev docker compose -f docker-compose.dev.yml up -d
# Detener: COMPOSE_PROJECT_NAME=mykaizenfit-dev docker compose -f docker-compose.dev.yml down
# Logs: COMPOSE_PROJECT_NAME=mykaizenfit-dev docker compose -f docker-compose.dev.yml logs -f
# Build: COMPOSE_PROJECT_NAME=mykaizenfit-dev docker compose -f docker-compose.dev.yml up -d --build
#
# PUERTOS DE DESARROLLO:
# - Frontend: 3001 (prod: 3000)
# - Backend: 8001 (prod: 8000)
# - DB: 5434 (prod: 5433)
#
# BASE DE DATOS PARA PRUEBAS:
# - Backend/Celery usan SIEMPRE la BD local de desarrollo (mykaizenfit_dev)
# - La BD se puede inicializar desde una copia lógica de producción sin compartir datos en vivo
services:
# ============================================
# BASE DE DATOS POSTGRES (DESARROLLO)
# ============================================
db:
image: postgres:15
restart: unless-stopped
env_file:
- ./docker/postgres.env.dev
environment:
# Variables requeridas por la imagen oficial de Postgres
POSTGRES_DB: mykaizenfit_dev
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
# Configuración de encoding UTF-8
POSTGRES_INITDB_ARGS: "--encoding=UTF8 --locale=C.UTF-8"
LC_ALL: "C.UTF-8"
LANG: "C.UTF-8"
PGCLIENTENCODING: "UTF8"
ports:
- "127.0.0.1:5434:5432"
volumes:
- /srv/mykaizenfit/dev/data/postgres:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
networks:
internal:
aliases:
- mykaizenfit-dev-db
db_access:
# ============================================
# REDIS (DESARROLLO)
# ============================================
redis:
image: redis:7-alpine
restart: unless-stopped
command: ["redis-server", "--appendonly", "yes"]
# Sin password en desarrollo para simplicidad
volumes:
- /srv/mykaizenfit/dev/data/redis:/data
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
networks:
internal:
aliases:
- mykaizenfit-dev-redis
# ============================================
# BACKEND (Django) - DESARROLLO
# ============================================
backend:
build:
context: ./backend
dockerfile: Dockerfile
restart: unless-stopped
user: "0:0"
env_file:
- ./docker/backend.env.dev
environment:
# Logs
LOG_LEVEL: DEBUG
DB_HOST: mykaizenfit-dev-db
DB_NAME: mykaizenfit_dev
DB_PORT: 5432
REDIS_URL: redis://redis:6379/0
READ_DOTENV: "False"
command: >
sh -c "
echo '🔎 Usando BD de desarrollo: '$$DB_NAME' @ '$$DB_HOST':'$$DB_PORT &&
echo '📦 Aplicando migraciones...' &&
python manage.py migrate --noinput &&
echo '🚀 Iniciando servidor de desarrollo...' &&
python manage.py runserver 0.0.0.0:8000
"
ports:
- "0.0.0.0:8001:8000"
volumes:
- ./backend:/app
- /srv/mykaizenfit/dev/data/staticfiles:/app/staticfiles
- /srv/mykaizenfit/dev/data/media:/app/media
- /srv/mykaizenfit/dev/data/backups:/app/backups
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:8000/api/health/ || exit 1"]
interval: 30s
timeout: 10s
retries: 5
start_period: 60s
networks:
- internal
- web
# ============================================
# FRONTEND (Next.js) - DESARROLLO
# ============================================
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.dev
env_file:
- ./frontend/docker.env.dev
restart: unless-stopped
environment:
NEXT_PUBLIC_VAPID_PUBLIC_KEY: "BA4lHz3MgE1aCZulpFl3fgl6wDt5busFjax0SlqbxO6Xmu1XqHkId_AGbOuYCdhiFnYTCx4l7KdJrDTNVBN4BRk"
WATCHPACK_POLLING: "true"
CHOKIDAR_USEPOLLING: "true"
ports:
- "0.0.0.0:3001:3000"
volumes:
- ./frontend:/app
- /app/node_modules
- /app/.next
depends_on:
backend:
condition: service_healthy
networks:
- web
# ============================================
# CELERY WORKER - DESARROLLO
# ============================================
celery_worker:
build:
context: ./backend
dockerfile: Dockerfile
restart: unless-stopped
user: "0:0"
env_file:
- ./docker/backend.env.dev
environment:
LOG_LEVEL: DEBUG
DB_HOST: mykaizenfit-dev-db
DB_NAME: mykaizenfit_dev
DB_PORT: 5432
REDIS_URL: redis://redis:6379/0
READ_DOTENV: "False"
command: >
sh -c "celery -A backend worker --loglevel=info --concurrency=2"
volumes:
- ./backend:/app
- /srv/mykaizenfit/dev/data/media:/app/media
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy
networks:
- internal
# ============================================
# VOLÚMENES
# ============================================
# ============================================
# REDES
# ============================================
# Nombres únicos para evitar conflictos con producción
networks:
internal:
name: mykaizenfit-dev-internal
driver: bridge
internal: true
web:
name: mykaizenfit-dev-web
driver: bridge
db_access:
name: mykaizenfit-dev-db-access
driver: bridge