Files
trenes/backend/Dockerfile
Millaguie 34c0cb50c7
Some checks failed
Auto Tag on Merge to Main / auto-tag (push) Successful in 27s
CI - Lint and Build / lint-backend (push) Failing after 30s
CI - Lint and Build / lint-frontend (push) Failing after 2s
CI - Lint and Build / build-frontend (push) Has been skipped
CI - Lint and Build / docker-build-test (push) Has been skipped
feat: Initial commit - Train tracking system
Complete real-time train tracking system for Spanish railways (Renfe/Cercanías):

- Backend API (Node.js/Express) with GTFS-RT polling workers
- Frontend dashboard (React/Vite) with Leaflet maps
- Real-time updates via Socket.io WebSocket
- PostgreSQL/PostGIS database with Flyway migrations
- Redis caching layer
- Docker Compose configuration for development and production
- Gitea CI/CD workflows (lint, auto-tag, release)
- Production deployment with nginx + Let's Encrypt SSL

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 00:21:15 +01:00

87 lines
1.6 KiB
Docker

# Multi-stage Dockerfile para Backend (API + Worker)
FROM node:20-alpine AS base
# Instalar dependencias del sistema
RUN apk add --no-cache \
python3 \
make \
g++ \
curl \
wget
WORKDIR /app
# Copiar archivos de dependencias
COPY package*.json ./
# Instalar dependencias
RUN npm install --omit=dev && \
npm cache clean --force
# Copiar código fuente
COPY . .
# ================================
# Stage para API
# ================================
FROM base AS api
ENV NODE_ENV=production
ENV PORT=3000
# Crear usuario no-root
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001
USER nodejs
EXPOSE 3000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget --quiet --tries=1 --spider http://localhost:3000/health || exit 1
CMD ["node", "src/api/server.js"]
# ================================
# Stage para Worker
# ================================
FROM base AS worker
ENV NODE_ENV=production
# Crear usuario no-root
RUN addgroup -g 1001 -S nodejs && \
adduser -S nodejs -u 1001
USER nodejs
# Health check para worker (verifica que el proceso esté corriendo)
HEALTHCHECK --interval=60s --timeout=10s --start-period=40s --retries=3 \
CMD pgrep -f "node.*worker" || exit 1
CMD ["node", "src/worker/gtfs-poller.js"]
# ================================
# Stage de desarrollo (opcional)
# ================================
FROM node:20-alpine AS development
RUN apk add --no-cache \
python3 \
make \
g++ \
curl \
wget
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
ENV NODE_ENV=development
CMD ["npm", "run", "dev"]