-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocker-compose.dev.yml
More file actions
112 lines (106 loc) · 3.29 KB
/
docker-compose.dev.yml
File metadata and controls
112 lines (106 loc) · 3.29 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
services:
# One-shot DB bootstrap (dev)
# Ensures DB_NAME exists inside the external postgres-local container.
db-init:
image: postgres:15-alpine
container_name: malafama-db-init
restart: "no"
profiles: ["tools"]
env_file:
- ./.env
environment:
PGPASSWORD: ${DB_PASSWORD}
networks:
- red-desarrollo
command:
- sh
- -c
- |
set -e
echo "[db-init] Waiting for postgres-local..."
until pg_isready -h ${DB_HOST_DOCKER:-postgres-local} -p ${DB_PORT_DOCKER:-5432} -U ${DB_USER:-postgres}; do
sleep 1
done
echo "[db-init] Ensuring database '${DB_NAME:-malafama}' exists..."
psql -h ${DB_HOST_DOCKER:-postgres-local} -p ${DB_PORT_DOCKER:-5432} -U ${DB_USER:-postgres} -d postgres -tc "SELECT 1 FROM pg_database WHERE datname='${DB_NAME:-malafama}'" | grep -q 1 \
|| psql -h ${DB_HOST_DOCKER:-postgres-local} -p ${DB_PORT_DOCKER:-5432} -U ${DB_USER:-postgres} -d postgres -c "CREATE DATABASE \"${DB_NAME:-malafama}\";"
echo "[db-init] Done."
# Backend API (dev)
backend:
build:
context: ./backend
dockerfile: Dockerfile.dev
container_name: malafama-backend
restart: unless-stopped
env_file:
- ./.env
environment:
# Usar el Postgres Docker llamado "postgres-local" (contenedor existente).
# Este contenedor vive en la red "red-desarrollo".
DB_HOST: ${DB_HOST_DOCKER:-postgres-local}
DB_PORT: ${DB_PORT_DOCKER:-5432}
LOG_SQL: ${LOG_SQL:-false}
RUN_MIGRATIONS: ${RUN_MIGRATIONS:-true}
DB_WAIT_RETRIES: ${DB_WAIT_RETRIES:-60}
DB_WAIT_SECONDS: ${DB_WAIT_SECONDS:-2}
ports:
- "${PORT:-5000}:${PORT:-5000}"
volumes:
- ./backend/uploads:/app/uploads
- ./backend/src:/app/src
- /app/node_modules
networks:
- malafama-network
- red-desarrollo
command: ["npm", "run", "dev"]
# One-shot Platform Admin bootstrap
# - runs migrations (creates tenants table)
# - ensures admin@supernovatel.com exists as platform_admin
platform-admin-init:
build:
context: ./backend
dockerfile: Dockerfile.dev
container_name: malafama-platform-admin-init
restart: "no"
profiles: ["tools"]
env_file:
- ./.env
environment:
DB_HOST: ${DB_HOST_DOCKER:-postgres-local}
DB_PORT: ${DB_PORT_DOCKER:-5432}
LOG_SQL: ${LOG_SQL:-false}
NODE_ENV: ${NODE_ENV:-development}
networks:
- red-desarrollo
depends_on:
db-init:
condition: service_completed_successfully
command: ["sh", "-c", "npm run db:migrate && node scripts/init-platform-admin.js"]
# Frontend Web (dev)
frontend:
image: node:18-alpine
container_name: malafama-frontend
restart: unless-stopped
env_file:
- ./.env
environment:
VITE_API_URL: ${VITE_API_URL:-http://localhost:5000/api/v1}
ports:
- "${FRONTEND_PORT:-3000}:3000"
volumes:
- ./frontend:/app
- /app/node_modules
working_dir: /app
depends_on:
- backend
networks:
- malafama-network
command: ["sh", "-c", "npm install && npm run dev -- --host 0.0.0.0 --port 3000"]
volumes:
postgres_data:
networks:
malafama-network:
name: red-interna
red-desarrollo:
external: true
name: red-desarrollo