This commit is contained in:
2026-06-19 23:48:35 +03:30
parent 76f23a73e2
commit 1bb4c7efcc
+19 -21
View File
@@ -1,49 +1,47 @@
FROM node:20 AS base
FROM node:20-alpine AS base
# ENV NPM_CONFIG_REGISTRY=https://mirror-npm.runflare.com
ENV TZ=Asia/Tehran
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y --no-install-recommends \
tzdata \
python3 \
make \
g++ \
&& rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache tzdata
FROM base AS deps
WORKDIR /temp-deps
COPY package*.json ./
RUN npm install
FROM base AS builder
WORKDIR /build
COPY . ./
COPY --from=deps /temp-deps/node_modules ./node_modules
RUN npm run build
RUN npm install --omit=dev
# Remove dev dependencies
RUN npm prune --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
# Debian-compatible user creation
RUN groupadd -r appgroup && \
useradd -r -g appgroup appuser
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 ./
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"]