hrms-api-salary/docker/Dockerfile

38 lines
742 B
Text
Raw Normal View History

2024-12-03 13:38:14 +07:00
# Build Stage
FROM node:lts-alpine AS build-stage
# 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 . .
RUN npm run build
# Production Stage
FROM node:lts-alpine
2025-09-15 22:56:44 +07:00
ENV NODE_ENV=production
2024-12-03 13:38:14 +07:00
# Create app directory
WORKDIR /app
2025-09-15 22:56:44 +07:00
# Install only production dependencies as root first
COPY package*.json ./
RUN npm install --production && npm cache clean --force
2024-12-03 13:38:14 +07:00
# Copy built app from build stage
COPY --from=build-stage /app/dist ./dist
2025-09-15 22:56:44 +07:00
# Change ownership to node user and switch to node user
RUN chown -R node:node /app
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" ]