From 0962aa29ba6c700408874158e137db44cd380f3b Mon Sep 17 00:00:00 2001 From: Akhil Gupta Date: Wed, 7 Oct 2020 14:52:05 +0530 Subject: [PATCH] new user in docker --- Dockerfile | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0eb113f..3056560 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,8 @@ ARG GO_VERSION=1.15.2 +ENV UID=998 +ENV GID=100 +ENV CONFIG=/config +ENV DATA=/assets FROM golang:${GO_VERSION}-alpine AS builder @@ -22,12 +26,17 @@ RUN mkdir -p /api WORKDIR /api COPY --from=builder /api/app . COPY client ./client -RUN mkdir /config -RUN mkdir /assets -ENV CONFIG=/config -ENV DATA=/assets -RUN chmod 777 /assets; \ - chmod 777 /config; +RUN mkdir /config; \ + mkdir /assets + +RUN groupadd -g ${GID} poduser &&\ + useradd -l -u ${UID} -g poduser poduser &&\ + chown --changes --silent --no-dereference --recursive \ + ${UID}:${GID} \ + /assets \ + /config + +USER poduser EXPOSE 8080 VOLUME ["/config", "/assets"]