Files
dmail-api/Dockerfile
T
morteza 0691b0ea06
Build and Deploy Docker Images / build_and_deploy (push) Has been cancelled
up
2026-06-11 10:41:34 +03:30

46 lines
1.1 KiB
Docker
Executable File

# Stage 1: Build Stage
FROM node:22-alpine AS base
# Use Alpine mirror
# RUN sed -i 's|https://dl-cdn.alpinelinux.org/alpine|https://mirror.de.velop.ir/alpine|g' /etc/apk/repositories
# Configure npm registry mirror
ENV NPM_CONFIG_REGISTRY=https://registry.npmmirror.com
# Install tzdata to support timezone settings
RUN apk add --no-cache tzdata
ENV TZ=Asia/Tehran
# Set the timezone to Asia/Tehran
RUN cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && echo "Asia/Tehran" > /etc/timezone
FROM base AS deps
WORKDIR /temp-deps
COPY .npmrc package*.json package-lock.json ./
RUN npm ci --loglevel info
FROM base AS builder
WORKDIR /build
COPY . ./
COPY --from=deps /temp-deps/node_modules ./node_modules
RUN if [ -f package.json ] && grep -q '"build":' package.json; then npm run build; fi
RUN npm prune --omit=dev
FROM base AS runner
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
WORKDIR /app
COPY . ./
COPY --from=builder --chown=appuser:appgroup /build/ ./
RUN chown -R appuser:appgroup /app
USER appuser
ENV NODE_ENV=production
EXPOSE 4000
CMD ["npm", "start"]