fase 3: Dockerfile multi-stage (node:22-alpine)
Build TS con devDeps y runtime solo con deps de produccion, USER node, healthcheck por proceso (deuda: anadir /healthz), secretos siempre por entorno/ficheros montados. Imagen verificada con docker build.
This commit is contained in:
parent
d1fc6798dc
commit
3596f7abed
2 changed files with 35 additions and 0 deletions
11
.dockerignore
Normal file
11
.dockerignore
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
test
|
||||||
|
docs
|
||||||
|
deploy
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
!.env.example
|
||||||
|
config.json
|
||||||
|
*.log
|
||||||
|
.git
|
||||||
24
Dockerfile
Normal file
24
Dockerfile
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
# tcef-notifications — imagen de producción (fase 3, Docker Compose).
|
||||||
|
# Multi-stage: build TS con devDeps, runtime solo con deps de producción.
|
||||||
|
# Secretos SIEMPRE por entorno/ficheros montados — nunca dentro de la imagen.
|
||||||
|
|
||||||
|
FROM node:22-alpine AS build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package.json package-lock.json ./
|
||||||
|
RUN npm ci
|
||||||
|
COPY tsconfig.json ./
|
||||||
|
COPY scripts ./scripts
|
||||||
|
COPY src ./src
|
||||||
|
RUN npm run build && npm prune --omit=dev
|
||||||
|
|
||||||
|
FROM node:22-alpine
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=build --chown=node:node /app/node_modules ./node_modules
|
||||||
|
COPY --from=build --chown=node:node /app/dist ./dist
|
||||||
|
COPY --chown=node:node package.json ./
|
||||||
|
USER node
|
||||||
|
# Deuda: el servicio no expone endpoint HTTP de salud; healthcheck por proceso.
|
||||||
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s \
|
||||||
|
CMD pgrep -f "dist/index.js" > /dev/null || exit 1
|
||||||
|
CMD ["node", "--enable-source-maps", "dist/index.js"]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue