2024-12-03 13:37:54 +07:00
|
|
|
# Build Stage
|
2025-08-05 05:50:25 +00:00
|
|
|
FROM node:20.19.4-alpine AS build-stage
|
2024-12-03 13:37:54 +07:00
|
|
|
|
|
|
|
|
# Create app directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Install app dependencies
|
|
|
|
|
COPY package*.json ./
|
2025-08-05 06:15:52 +00:00
|
|
|
#RUN npm ci
|
|
|
|
|
RUN npm install
|
2024-12-03 13:37:54 +07:00
|
|
|
|
|
|
|
|
# Copy source files and build the app
|
|
|
|
|
COPY . .
|
|
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
# Production Stage
|
2025-08-05 05:50:25 +00:00
|
|
|
FROM node:20.19.4-alpine
|
|
|
|
|
ENV NODE_ENV=production
|
2024-12-03 13:37:54 +07:00
|
|
|
|
|
|
|
|
# Create app directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy built app from build stage
|
|
|
|
|
COPY --from=build-stage /app/dist ./dist
|
|
|
|
|
|
|
|
|
|
# Install only production dependencies
|
2025-08-05 13:09:53 +07:00
|
|
|
COPY package*.json ./
|
2025-08-05 06:15:52 +00:00
|
|
|
#RUN npm ci --production
|
|
|
|
|
RUN npm install
|
2025-08-05 05:54:13 +00:00
|
|
|
USER node
|
2024-12-03 13:37:54 +07:00
|
|
|
|
|
|
|
|
# Define the entrypoint and default command
|
|
|
|
|
# If you have a custom entrypoint script
|
2026-02-27 07:56:04 +07:00
|
|
|
CMD [ "node", "dist/app.js" ]
|