Skip to content

Commit

Permalink
Merge pull request #440 from bcgov/bug/node-root-user
Browse files Browse the repository at this point in the history
Update Dockerfile
  • Loading branch information
barrfalk authored Dec 13, 2023
2 parents d443a46 + da3e43f commit f852e52
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
FROM docker.io/node:16.15.1-alpine

# Set environment variable to avoid update notifications
ENV NO_UPDATE_NOTIFIER=true

# Set a custom npm cache directory
ENV NPM_CONFIG_CACHE=/opt/app-root/src/app/.npm-cache

# Set working directory
WORKDIR /opt/app-root/src/app

# Copy application source code and set ownership
COPY . /opt/app-root/src

# Create the npm cache directory and ensure the correct ownership
RUN mkdir -p $NPM_CONFIG_CACHE && chown -R 1001:1001 /opt/app-root/src/app

# Switch to a non-root user with UID and GID 1001
USER 1001:1001

# Install dependencies and build the application
RUN npm run all:ci \
&& npm run all:build \
&& npm run client:purge
&& npm run all:build \
&& npm run client:purge

# Expose the port the app runs on
EXPOSE 8000

# Start the application
CMD ["npm", "run", "start"]

0 comments on commit f852e52

Please sign in to comment.