This commit is contained in:
+29
-26
@@ -1,47 +1,50 @@
|
||||
FROM node:20-alpine AS base
|
||||
|
||||
ENV TZ=Asia/Tehran
|
||||
RUN apk add --no-cache tzdata
|
||||
|
||||
# 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
|
||||
WORKDIR /deps
|
||||
COPY package*.json ./
|
||||
RUN npm install
|
||||
RUN --mount=type=cache,target=/root/.npm \
|
||||
npm ci
|
||||
|
||||
FROM base AS prod-deps
|
||||
WORKDIR /deps
|
||||
COPY package*.json ./
|
||||
RUN --mount=type=cache,target=/root/.npm \
|
||||
npm ci --omit=dev
|
||||
|
||||
FROM base AS builder
|
||||
WORKDIR /build
|
||||
COPY . ./
|
||||
COPY --from=deps /temp-deps/node_modules ./node_modules
|
||||
COPY . .
|
||||
COPY --from=deps /deps/node_modules ./node_modules
|
||||
RUN npm run build
|
||||
RUN npm install --omit=dev
|
||||
|
||||
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
ENV NUXT_TELEMETRY_DISABLED=1
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
|
||||
RUN addgroup -S appgroup && \
|
||||
adduser -S appuser -G appgroup && \
|
||||
chown appuser:appgroup /app
|
||||
|
||||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
||||
RUN chown -R appuser:appgroup /app
|
||||
|
||||
# COPY --from=builder --chown=appuser:appgroup /build/.nuxt ./.nuxt
|
||||
# COPY --from=builder --chown=appuser:appgroup /build/static ./static
|
||||
# COPY --from=builder --chown=appuser:appgroup /build/package.json ./
|
||||
# COPY --from=builder --chown=appuser:appgroup /build/node_modules/ ./node_modules/
|
||||
COPY --from=builder --chown=appuser:appgroup /build ./
|
||||
|
||||
COPY --from=builder --chown=appuser:appgroup /build/.nuxt ./.nuxt
|
||||
COPY --from=builder --chown=appuser:appgroup /build/static ./static
|
||||
COPY --from=builder --chown=appuser:appgroup /build/server ./server
|
||||
COPY --from=builder --chown=appuser:appgroup /build/nuxt.config.js ./
|
||||
COPY --from=prod-deps --chown=appuser:appgroup /deps/node_modules ./node_modules
|
||||
COPY --from=prod-deps --chown=appuser:appgroup /deps/package.json ./package.json
|
||||
|
||||
USER appuser
|
||||
|
||||
# Set environment variables
|
||||
ENV NODE_ENV=production
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME="0.0.0.0"
|
||||
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
# Start the Nuxt 2 app
|
||||
CMD ["npm", "start"]
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||||
CMD node -e "require('http').get('http://127.0.0.1:3000/',r=>process.exit(r.statusCode<500?0:1)).on('error',()=>process.exit(1))"
|
||||
|
||||
CMD ["node", "node_modules/nuxt/bin/nuxt.js", "start"]
|
||||
|
||||
Reference in New Issue
Block a user