docs: enterprise refactor plan with ralph specs
This commit is contained in:
102
.ralph/specs/legacy/docker.md
Normal file
102
.ralph/specs/legacy/docker.md
Normal file
@@ -0,0 +1,102 @@
|
||||
# ABE — Docker Specification
|
||||
|
||||
## Objetivo
|
||||
Permitir arrancar todo el proyecto (backend + frontend) con un solo comando:
|
||||
docker-compose up --build
|
||||
|
||||
## Backend Dockerfile (raíz del proyecto)
|
||||
```dockerfile
|
||||
FROM node:20-alpine
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
EXPOSE 3001
|
||||
CMD ["node", "dist/server/index.js"]
|
||||
```
|
||||
|
||||
## Frontend Dockerfile (frontend/Dockerfile)
|
||||
|
||||
Usa build multistage: primero compila con Node, luego sirve con nginx.
|
||||
```dockerfile
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
COPY . .
|
||||
RUN npm run build
|
||||
|
||||
FROM nginx:alpine
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
```
|
||||
|
||||
## nginx.conf (frontend/nginx.conf)
|
||||
|
||||
Necesario para que React Router funcione correctamente (todas las rutas apuntan a index.html):
|
||||
```nginx
|
||||
server {
|
||||
listen 80;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /api {
|
||||
proxy_pass http://backend:3001;
|
||||
}
|
||||
|
||||
location /socket.io {
|
||||
proxy_pass http://backend:3001;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## docker-compose.yml (raíz)
|
||||
```yaml
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
backend:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "3001:3001"
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3001
|
||||
volumes:
|
||||
- ./reports:/app/reports
|
||||
- ./logs:/app/logs
|
||||
networks:
|
||||
- abe-network
|
||||
|
||||
frontend:
|
||||
build:
|
||||
context: ./frontend
|
||||
dockerfile: Dockerfile
|
||||
ports:
|
||||
- "5173:80"
|
||||
depends_on:
|
||||
- backend
|
||||
networks:
|
||||
- abe-network
|
||||
|
||||
networks:
|
||||
abe-network:
|
||||
driver: bridge
|
||||
```
|
||||
|
||||
## Notas importantes
|
||||
- El frontend en producción (nginx) hace proxy de /api y /socket.io al backend
|
||||
- Los volúmenes reports/ y logs/ persisten datos entre reinicios del contenedor
|
||||
- El frontend se accede en http://localhost:5173
|
||||
- El backend se accede en http://localhost:3001
|
||||
Reference in New Issue
Block a user