From 9fcc8e36b0fae81571f354708754a19e2eb2145b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Loun=C3=A8s=20Ksouri?= Date: Sat, 26 Mar 2022 15:08:24 +0000 Subject: [PATCH] set app user gid/uid to 1000 --- Dockerfile | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 502db71b..53220098 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,41 +4,57 @@ # License https://gitlab.com/timvisee/send/blob/master/LICENSE ## - # Build project FROM node:16.13-alpine3.13 AS builder + +RUN set -x \ + # Change node uid/gid + && apk --no-cache add shadow \ + && groupmod -g 1001 node \ + && usermod -u 1001 -g 1001 node + RUN set -x \ # Add user - && addgroup --gid 10001 app \ + && addgroup --gid 1000 app \ && adduser --disabled-password \ --gecos '' \ --ingroup app \ --home /app \ - --uid 10001 \ + --uid 1000 \ app + COPY --chown=app:app . /app + USER app WORKDIR /app + RUN set -x \ # Build && PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm ci \ && npm run build - # Main image FROM node:16.13-alpine3.13 + +RUN set -x \ + # Change node uid/gid + && apk --no-cache add shadow \ + && groupmod -g 1001 node \ + && usermod -u 1001 -g 1001 node + RUN set -x \ # Add user - && addgroup --gid 10001 app \ + && addgroup --gid 1000 app \ && adduser --disabled-password \ --gecos '' \ --ingroup app \ --home /app \ - --uid 10001 \ + --uid 1000 \ app USER app WORKDIR /app + COPY --chown=app:app package*.json ./ COPY --chown=app:app app app COPY --chown=app:app common common