Files
shop-front/Dockerfile
T
Mehdi Mehrmanesh 8bc5930bd6 add gitlab-ci file
2026-02-21 13:30:00 +03:30

63 lines
1.3 KiB
Docker

# ------------------------
# Base image
# ------------------------
FROM node:22-alpine AS base
RUN apk add --no-cache tzdata \
&& cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime \
&& echo "Asia/Tehran" > /etc/timezone
WORKDIR /app
# ------------------------
# Dependencies stage
# ------------------------
FROM base AS deps
RUN apk add --no-cache libc6-compat git
COPY package*.json ./
RUN npm ci
# ------------------------
# Builder stage
# ------------------------
FROM base AS builder
WORKDIR /build
COPY --from=deps /app/node_modules ./node_modules
COPY . .
RUN NEXT_TELEMETRY_DISABLED=1 npm run build -- --no-lint || true
# ------------------------
# Runner stage (production)
# ------------------------
FROM base AS runner
WORKDIR /app
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME="0.0.0.0"
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
RUN mkdir .next && chown appuser:appgroup .next
COPY --from=builder --chown=appuser:appgroup /build/.next/standalone ./
COPY --from=builder --chown=appuser:appgroup /build/.next/static ./.next/static
COPY --from=builder --chown=appuser:appgroup /build/public ./public
COPY --from=builder --chown=appuser:appgroup /build/package.json ./package.json
USER appuser
# expose port
EXPOSE 3000
CMD ["node", "server.js"]