-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10213ec
commit de40713
Showing
1 changed file
with
25 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |