48 lines
1.4 KiB
Docker
48 lines
1.4 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
FROM node:20-alpine AS base
|
|
|
|
# Change Alpine repo
|
|
# RUN sed -i 's|https://dl-cdn.alpinelinux.org/alpine|https://mirror.de.velop.ir/alpine|g' /etc/apk/repositories
|
|
|
|
# Configure npm registry mirror (Liara)
|
|
# ENV NPM_CONFIG_REGISTRY=https://mirror-npm.runflare.com
|
|
# RUN npm config set registry https://mirror-npm.runflare.com
|
|
|
|
# Install tzdata to support timezone settings
|
|
# RUN apk add --no-cache tzdata && \
|
|
# cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime && \
|
|
# echo "Asia/Tehran" > /etc/timezone
|
|
|
|
WORKDIR /app
|
|
ENV NEXT_TELEMETRY_DISABLED=1 \
|
|
npm_config_update_notifier=false
|
|
|
|
FROM base AS deps
|
|
COPY package.json package-lock.json ./
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci --legacy-peer-deps --prefer-offline
|
|
|
|
FROM base AS builder
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
ARG NEXT_PUBLIC_API_BASE_URL=https://api.danakcorp.com/
|
|
ENV NEXT_PUBLIC_API_BASE_URL=$NEXT_PUBLIC_API_BASE_URL
|
|
RUN --mount=type=cache,target=/app/.next/cache \
|
|
npm run build
|
|
|
|
FROM base AS runner
|
|
ENV NODE_ENV=production \
|
|
PORT=3000 \
|
|
HOSTNAME=0.0.0.0
|
|
|
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
|
|
COPY --from=builder --chown=appuser:appgroup /app/public ./public
|
|
COPY --from=builder --chown=appuser:appgroup /app/.next/standalone ./
|
|
COPY --from=builder --chown=appuser:appgroup /app/.next/static ./.next/static
|
|
|
|
USER appuser
|
|
EXPOSE 3000
|
|
CMD ["node", "server.js"]
|