-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
144 lines (139 loc) · 6.04 KB
/
Copy pathdocker-compose.yml
File metadata and controls
144 lines (139 loc) · 6.04 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
name: newlife
services:
# ── Backend Web (admin-api) ──────────────────────────────────────
admin-api:
# newlife-admin-api.openlab.uninorte.edu.co
build:
context: ./backend/admin-api
dockerfile: Dockerfile
container_name: newlife-admin-api
ports:
- "5180:3001"
environment:
PORT: 3001
# ── Roble ─────────────────────────────────────────────────────
ROBLE_BASE_URL: ${ROBLE_BASE_URL}
ROBLE_PROJECT_TOKEN: ${ROBLE_PROJECT_TOKEN}
ROBLE_DB_NAME: ${ROBLE_DB_NAME}
ROBLE_SYSTEM_EMAIL: ${ROBLE_SYSTEM_EMAIL}
ROBLE_SYSTEM_PASSWORD: ${ROBLE_SYSTEM_PASSWORD}
# ── Admin Auth ────────────────────────────────────────────────
ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
ADMIN_JWT_EXPIRES_IN: ${ADMIN_JWT_EXPIRES_IN}
CORS_ORIGIN: ${CORS_ORIGIN}
# ── MinIO ─────────────────────────────────────────────────────
MINIO_ENDPOINT: http://minio:9000
MINIO_PUBLIC_ENDPOINT: ${MINIO_PUBLIC_ENDPOINT}
MINIO_REGION: ${MINIO_REGION}
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
MINIO_BUCKET_PUBLIC: ${MINIO_BUCKET_PUBLIC}
# ── Límites de upload ─────────────────────────────────────────
MEDIA_MAX_FILE_SIZE_MB: ${MEDIA_MAX_FILE_SIZE_MB}
MEDIA_MAX_IMAGE_DIMENSION: ${MEDIA_MAX_IMAGE_DIMENSION}
MEDIA_MIN_IMAGE_DIMENSION: ${MEDIA_MIN_IMAGE_DIMENSION}
# SAFE MODE: admin-api solo depende de minio levantado (sin health/init).
# Si minio-init falla, admin-api SIGUE arrancando (el upload no funcionara
# hasta que se arregle el bucket, pero el resto del sistema queda operativo).
depends_on:
- minio
restart: unless-stopped
# ── Backend Mobile (api) ─────────────────────────────────────────
api:
# newlife-mobile-api.openlab.uninorte.edu.co
build:
context: ./backend/mobile-api
dockerfile: Dockerfile
container_name: newlife-mobile-api
ports:
- "5181:3000"
env_file:
- .env
volumes:
- ./backend/mobile-api:/app
- /app/node_modules
environment:
- NODE_ENV=development
- MINIO_ENDPOINT=http://minio:9000
depends_on:
- minio
command: npm run start:dev
restart: unless-stopped
# ── Frontend Web (Next.js) ───────────────────────────────────────
frontend-web:
# newlife.openlab.uninorte.edu.co
build:
context: ./frontend/web
dockerfile: Dockerfile
container_name: newlife-frontend-web
ports:
- "5182:3000"
environment:
NODE_ENV: development
NEXT_PUBLIC_API_URL: https://newlife-admin-api.openlab.uninorte.edu.co
volumes:
- ./frontend/web:/app
- /app/node_modules
- /app/.next
depends_on:
- admin-api
restart: unless-stopped
# ── Almacenamiento de Media (MinIO) ──────────────────────────────
minio:
# newlife-media.openlab.uninorte.edu.co
image: minio/minio:latest
container_name: newlife-minio
ports:
- "5183:9000" # API compatible con S3
- "5184:9001" # Consola web (UI admin)
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
volumes:
- ./media-data:/data
command: server /data --console-address ":9001"
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "curl -sf http://localhost:9000/minio/health/live || exit 1"]
interval: 10s
timeout: 5s
retries: 10
start_period: 30s
# ── Inicialización de MinIO ──────────────────────────────────────
# Servicio efimero que configura MinIO automaticamente al arrancar:
# 1. Crea el bucket publico (si no existe).
# 2. Configura el bucket como publico (lectura anonima para imagenes).
# 3. Crea el usuario de servicio que usa el backend (admin-api).
# 4. Asigna policy readwrite al usuario del backend.
#
# IDEMPOTENTE: si el bucket o el usuario ya existen, no falla (|| true).
# En SAFE MODE: si este servicio falla, el admin-api SIGUE arrancando
# (porque admin-api NO tiene "condition: service_completed_successfully").
minio-init:
image: minio/mc:latest
container_name: newlife-minio-init
depends_on:
minio:
condition: service_healthy
environment:
MINIO_ROOT_USER: ${MINIO_ROOT_USER}
MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD}
MINIO_BUCKET_PUBLIC: ${MINIO_BUCKET_PUBLIC}
MINIO_ACCESS_KEY: ${MINIO_ACCESS_KEY}
MINIO_SECRET_KEY: ${MINIO_SECRET_KEY}
entrypoint: >
/bin/sh -c "
echo 'Configurando alias de MinIO...';
/usr/bin/mc alias set local http://minio:9000 \"$$MINIO_ROOT_USER\" \"$$MINIO_ROOT_PASSWORD\";
echo 'Creando bucket publico (si no existe)...';
/usr/bin/mc mb --ignore-existing local/$$MINIO_BUCKET_PUBLIC;
echo 'Configurando bucket como publico (lectura anonima)...';
/usr/bin/mc anonymous set download local/$$MINIO_BUCKET_PUBLIC;
echo 'Creando usuario de servicio del backend (si no existe)...';
/usr/bin/mc admin user add local \"$$MINIO_ACCESS_KEY\" \"$$MINIO_SECRET_KEY\" || true;
echo 'Asignando policy readwrite al usuario del backend...';
/usr/bin/mc admin policy attach local readwrite --user \"$$MINIO_ACCESS_KEY\" || true;
echo 'MinIO configurado correctamente. Saliendo.';
exit 0;
"
restart: "no"