Skip to content

Commit

Permalink
fixed code smell and docker
Browse files Browse the repository at this point in the history
  • Loading branch information
santoshshinde2012 committed Nov 17, 2024
1 parent 10213ec commit de40713
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
# Use the official Node.js slim image
FROM node:20.16.0-slim

# Set environment variables
ENV NODE_ENV=production

# Create and set the working directory
WORKDIR /home/nodeuser/app
COPY package.json ./

# Create a non-root user
RUN useradd -m -s /bin/bash nodeuser && chown -R nodeuser:nodeuser /home/nodeuser

# Copy package.json and package-lock.json first for better caching
COPY package.json package-lock.json ./

# Install only production dependencies
RUN npm install --ignore-scripts --only=production

# Copy the rest of the application code
COPY tsconfig.json ./
COPY swagger.json ./
COPY .env ./
COPY src/ ./src
RUN npm install --ignore-scripts

# Build the project
RUN npm run build
EXPOSE 8082

# Change to the non-root user
USER nodeuser

# Expose the port the app runs on
EXPOSE 8082

# Set the command to start the application
CMD ["npm", "start"]

0 comments on commit de40713

Please sign in to comment.