55 lines
1.2 KiB
Docker
55 lines
1.2 KiB
Docker
# syntax=docker/dockerfile:1
|
|
|
|
FROM node:20-alpine AS base
|
|
|
|
RUN apk add --no-cache tzdata \
|
|
&& cp /usr/share/zoneinfo/Asia/Tehran /etc/localtime \
|
|
&& echo "Asia/Tehran" > /etc/timezone
|
|
|
|
FROM base AS deps
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json ./
|
|
|
|
RUN --mount=type=cache,target=/root/.npm \
|
|
npm ci
|
|
|
|
FROM base AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json nuxt.config.js ./
|
|
COPY --from=deps /app/node_modules ./node_modules
|
|
COPY . .
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
RUN npm run build \
|
|
&& npm prune --omit=dev
|
|
|
|
FROM base AS runner
|
|
|
|
WORKDIR /app
|
|
|
|
ENV NODE_ENV=production \
|
|
NUXT_TELEMETRY_DISABLED=1 \
|
|
PORT=3000 \
|
|
HOSTNAME=0.0.0.0
|
|
|
|
RUN addgroup -S appgroup \
|
|
&& adduser -S appuser -G appgroup
|
|
|
|
COPY --from=builder --chown=appuser:appgroup /app/package.json ./
|
|
COPY --from=builder --chown=appuser:appgroup /app/node_modules ./node_modules
|
|
COPY --from=builder --chown=appuser:appgroup /app/.nuxt ./.nuxt
|
|
COPY --from=builder --chown=appuser:appgroup /app/nuxt.config.js ./
|
|
COPY --from=builder --chown=appuser:appgroup /app/static ./static
|
|
COPY --from=builder --chown=appuser:appgroup /app/server ./server
|
|
|
|
USER appuser
|
|
|
|
EXPOSE 3000
|
|
|
|
CMD ["node", "node_modules/nuxt/bin/nuxt.js", "start"]
|