Files
evidencija-rezija/mailgun-webhook/Dockerfile
Nikola Derežić 45d5507bf9 refactor: delegate security to CloudFlare and clean up mailgun-webhook
Remove application-level CORS and IP whitelisting as security is now handled at CloudFlare edge. CORS is not applicable for backend webhook service, and IP whitelisting is more effectively managed at infrastructure layer. Also translate Dockerfile comments to English and add registry URL to build script.

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-07 12:47:07 +01:00

67 lines
1.6 KiB
Docker

#--------------------------------------------
# Stage: building TypeScript
#--------------------------------------------
FROM node:20 AS build-stage
ENV WORKDIR=/app
WORKDIR /app
COPY ./package*.json ./
# instaliram pakete
RUN npm i && npm cache clean --force
COPY ./tsconfig.json ./
COPY ./src ./src
RUN npm run build
#--------------------------------------------
# Stage: installing production node_modules
#--------------------------------------------
FROM node:20 AS package-stage
WORKDIR /app
COPY ./package*.json ./
# install ONLY production dependencies
RUN npm i --omit=dev && npm cache clean --force
#--------------------------------------------
# Stage: preparing final image
#--------------------------------------------
FROM gcr.io/distroless/nodejs:20 AS assembly-stage
WORKDIR /app
ARG PORT
ENV PORT=${PORT}
# (optional) App label to be used in Prometheus (Grafana)
ARG PROMETHEUS_APP_LABEL
ENV PROMETHEUS_APP_LABEL=${PROMETHEUS_APP_LABEL}=${PROMETHEUS_APP_LABEL}
# (optional) Prometheus histogram bucket sizes (grafana)
ARG PROMETHEUS_HISTOGRAM_BUCKETS
ENV PROMETHEUS_HISTOGRAM_BUCKETS=${PROMETHEUS_HISTOGRAM_BUCKETS}=${PROMETHEUS_HISTOGRAM_BUCKETS}
# (optional) enables logging to stdout
ARG DEBUG
ENV DEBUG=${DEBUG}
# copying node_modules
COPY --from=package-stage /app/package*.json ./
COPY --from=package-stage /app/node_modules ./node_modules
# copying built files
COPY --from=build-stage /app/build ./server
# running the server under limited "nobody" user
USER nobody:nobody
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
CMD ["/nodejs/bin/node", "./server/healthcheck.js"]
# starting the server
CMD ["./server/entry.js"]