This commit is contained in:
kittapath 2025-09-16 01:15:26 +07:00
parent 16426f1d0b
commit ec0aaf5b13

View file

@ -1,5 +1,5 @@
# Build Stage # Build Stage
FROM node:lts-alpine AS build-stage FROM node:22.17.1-alpine AS build-stage
# Create app directory # Create app directory
WORKDIR /app WORKDIR /app
@ -11,25 +11,24 @@ RUN npm install
# Copy source files and build the app # Copy source files and build the app
COPY . . COPY . .
#RUN npm ci
RUN npm run build RUN npm run build
# Production Stage # Production Stage
FROM node:lts-alpine FROM node:lts-alpine
ENV NODE_ENV=production ENV NODE_ENV production
# Create app directory # Create app directory
WORKDIR /app WORKDIR /app
# Install only production dependencies as root first
COPY package*.json ./
RUN npm install --production && npm cache clean --force
# Copy built app from build stage # Copy built app from build stage
COPY --from=build-stage /app/dist ./dist COPY --from=build-stage /app/dist ./dist
# Change ownership to node user and switch to node user # Install only production dependencies
RUN chown -R node:node /app COPY package*.json ./
#RUN npm ci --production
RUN npm install
USER node USER node
# Define the entrypoint and default command # Define the entrypoint and default command