From d553710b84f0bb7feb5613ad6d7173e1520ce3ea Mon Sep 17 00:00:00 2001 From: barrfalk Date: Thu, 11 Jan 2024 11:23:49 -0800 Subject: [PATCH] Update Dockerfile --- Dockerfile | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7e8f4f1..967c990 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,12 +9,18 @@ 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 application source code COPY . /opt/app-root/src +# Switch to root user to change ownership +USER root + # 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 back to non-root user +USER 1001:1001 + # Install dependencies and build the application RUN npm run all:ci \ && npm run all:build \ @@ -24,4 +30,4 @@ RUN npm run all:ci \ EXPOSE 8000 # Start the application -CMD ["sh", "-c", "chown -R 1001:1001 /opt/app-root/src/app/.npm-cache && npm run start"] +CMD ["npm", "run", "start"] \ No newline at end of file