Repository navigation
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
80 lines (74 loc) · 2.63 KB
/
Copy pathdocker-compose.dev.yml
File metadata and controls
80 lines (74 loc) · 2.63 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
# Desarrollo local: PostgreSQL, y backend y frontend con recarga en caliente.
# docker compose -f docker-compose.dev.yml up --build
# La app queda en http://localhost:5173 (Vite redirige /api al backend). Sin nginx.
name: vestuario-dev
x-logging: &logging
driver: json-file
options:
max-size: "10m"
max-file: "3"
services:
db:
image: postgres:18-alpine
environment:
POSTGRES_DB: ${POSTGRES_DB:-vestuario}
POSTGRES_USER: ${POSTGRES_USER:-vestuario}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-vestuario}
TZ: ${TZ:-Europe/Madrid}
ports:
# Accesible desde el equipo para usar herramientas de base de datos
- "127.0.0.1:${PUERTO_DB:-5432}:5432"
volumes:
- db-data:/var/lib/postgresql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U \"$${POSTGRES_USER}\" -d \"$${POSTGRES_DB}\""]
interval: 5s
timeout: 5s
retries: 10
logging: *logging
backend:
build:
context: ./backend
target: dev
environment:
PORT: 3000
DATABASE_URL: postgres://${POSTGRES_USER:-vestuario}:${POSTGRES_PASSWORD:-vestuario}@db:5432/${POSTGRES_DB:-vestuario}
ENTORNO: desarrollo
# Solo para desarrollo: en el servidor cada entorno tiene la suya en su .env
BETTER_AUTH_SECRET: ${BETTER_AUTH_SECRET:-desarrollo-no-usar-en-el-servidor-0123456789}
URL_PUBLICA: ${URL_PUBLICA:-http://localhost:5173}
# Base de datos de los tests (npm test), en el mismo PostgreSQL; se crea sola
TEST_DATABASE_URL: postgres://${POSTGRES_USER:-vestuario}:${POSTGRES_PASSWORD:-vestuario}@db:5432/${POSTGRES_DB:-vestuario}_test
TZ: ${TZ:-Europe/Madrid}
# Detección de cambios por sondeo (tsx usa chokidar); necesaria con el código en Windows
CHOKIDAR_USEPOLLING: ${RECARGA_POLLING:-false}
volumes:
- ./backend:/app
# node_modules del contenedor (Linux), no el del equipo
- /app/node_modules
ports:
- "127.0.0.1:3000:3000"
depends_on:
db:
condition: service_healthy
logging: *logging
frontend:
build:
context: ./frontend
target: dev
# --host en la línea de comandos: Vite pierde server.host de su configuración cuando se reinicia
# solo (p. ej. al cambiar las dependencias) y deja de ser accesible desde fuera del contenedor
command: ["npm", "run", "dev", "--", "--host", "0.0.0.0"]
environment:
API_PROXY_TARGET: http://backend:3000
VITE_USE_POLLING: ${RECARGA_POLLING:-false}
volumes:
- ./frontend:/app
- /app/node_modules
ports:
- "127.0.0.1:5173:5173"
depends_on:
- backend
logging: *logging
volumes:
db-data: