-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Dockerfile due to permission issues with npm
- Loading branch information
Showing
1 changed file
with
13 additions
and
3 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,19 +1,29 @@ | ||
# LTS version of Node.js | ||
FROM node:20.9.0-alpine | ||
|
||
# Create a new user and group for running the application | ||
RUN addgroup -S appgroup && adduser -S appuser -G appgroup | ||
|
||
RUN mkdir -p /app | ||
|
||
WORKDIR /app | ||
|
||
COPY package*.json ./ | ||
|
||
RUN npm install | ||
# Change ownership of the app directory | ||
RUN chown -R appuser:appgroup /app | ||
|
||
# Install npm dependencies as the non-root user | ||
USER appuser | ||
|
||
# Clear npm cache and install dependencies | ||
RUN npm cache clean --force && npm install | ||
|
||
COPY . . | ||
# Copy the rest of the application code | ||
COPY --chown=appuser:appgroup . . | ||
|
||
RUN npm run build | ||
|
||
EXPOSE 3000 | ||
|
||
# Start the app on port 4455 as recommended by ory | ||
CMD ["npm", "start", "--", "-p", "3000"] |