2024-12-03 13:38:14 +07:00
|
|
|
# Build Stage
|
2025-09-16 01:15:26 +07:00
|
|
|
FROM node:22.17.1-alpine AS build-stage
|
2024-12-03 13:38:14 +07:00
|
|
|
|
|
|
|
|
# Create app directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Install app dependencies
|
|
|
|
|
COPY package*.json ./
|
|
|
|
|
|
2025-09-15 22:32:13 +07:00
|
|
|
RUN npm install
|
2024-12-03 13:38:14 +07:00
|
|
|
|
|
|
|
|
# Copy source files and build the app
|
|
|
|
|
COPY . .
|
2025-09-16 01:15:26 +07:00
|
|
|
#RUN npm ci
|
2024-12-03 13:38:14 +07:00
|
|
|
RUN npm run build
|
|
|
|
|
|
|
|
|
|
# Production Stage
|
|
|
|
|
FROM node:lts-alpine
|
|
|
|
|
|
2025-09-16 01:15:26 +07:00
|
|
|
ENV NODE_ENV production
|
2024-12-03 13:38:14 +07:00
|
|
|
|
|
|
|
|
# Create app directory
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
# Copy built app from build stage
|
|
|
|
|
COPY --from=build-stage /app/dist ./dist
|
|
|
|
|
|
2025-09-16 01:15:26 +07:00
|
|
|
# Install only production dependencies
|
|
|
|
|
COPY package*.json ./
|
|
|
|
|
#RUN npm ci --production
|
|
|
|
|
RUN npm install
|
2025-09-15 22:56:44 +07:00
|
|
|
USER node
|
2024-12-03 13:38:14 +07:00
|
|
|
|
|
|
|
|
# Define the entrypoint and default command
|
|
|
|
|
# If you have a custom entrypoint script
|
|
|
|
|
CMD [ "node", "dist/app.js" ]
|