This commit is contained in:
2026-03-05 17:37:30 +01:00
commit 37e41a0130
14 changed files with 2366 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
# Stage base para coordinar las fases de build y ejecucion
FROM node:22-alpine AS base
# Hace falta para la herramienta de migraciones, cuando se publique se
# sustituira por el paquete de npm
RUN apk --no-cache add git=latest
WORKDIR /usr/local/app
COPY ./package.json ./package.lock ./
# copia el codigo en general
COPY tsconfig*.json ./
COPY .env* ./
COPY ./.yarnrc.yml ./
COPY ./deployment/local/docker/start.sh ./
# Copiar el archivo de migrations? porque ahora no creo que se esté lanzando nada
COPY ./deployment/database/migrations ./deployment/database/migrations
RUN npm install --production && \
npm build && \
chmod +x start.sh
EXPOSE ${PORT}
ENTRYPOINT [ "./start.sh" ]

View File

@@ -0,0 +1,57 @@
name: sf-nfc-server
networks:
default:
driver: bridge
name: network-test # Tiene que coincidir con el compose objetivo
services:
sf-nfc-api:
container_name: sf-nfc-api
image: sf-nfc-api
build:
context: ./
dockerfile: deployment/local/docker/Dockerfile.local
args:
PORT: "${PORT:-3000}"
develop:
watch:
- path: ./src
action: sync
target: /usr/local/app/packages
- path: ./package.json
action: rebuild
ports:
- ${PORT}:${PORT}
env_file:
- .env
restart: unless-stopped
healthcheck:
test:
[
"CMD-SHELL",
'node -e "fetch(''http://localhost:'' + (process.env.PORT || 3000) + ''/health'').then(r => { if (!r.ok) process.exit(1) }).catch(() => process.exit(1))"',
]
interval: 10s
timeout: 5s
retries: 5
start_period: 15s
depends_on:
postgresql-nfc:
condition: service_healthy
postgresql-nfc:
container_name: postgresql-nfc
image: postgres:16.1
env_file:
- .env
ports:
- "${POSTGRES_PORT}:${POSTGRES_PORT}"
volumes:
- ./sql-data/:/var/lib/postgres/data
- ./deployment/database/init.sql:/docker-entrypoint-initdb.d/init.sql
healthcheck:
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
interval: 5s
retries: 5
start_period: 5s
timeout: 5s