From 5a12b3120115b01a3a4f791fffe1a3a11f19d717 Mon Sep 17 00:00:00 2001 From: SevLG Date: Wed, 10 Jan 2024 10:07:38 +0100 Subject: [PATCH] Modifying Dockerfile to run node as non-root user --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e2ff0cf..b331a2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,10 @@ -FROM node:20-alpine AS development +FROM node:21-alpine AS development ENV NODE_ENV development # Add a work directory WORKDIR /usr/app +# copy files as a non-root user. The 'node' user is built in the Node image. +RUN chown node:node ./ +USER node # Cache and Install dependencies COPY ./react-app/package.json . COPY ./react-app/package-lock.json .