From ec33b402b9451edfb11a70182b8f2ce268830d44 Mon Sep 17 00:00:00 2001 From: Paul-Christian Volkmer Date: Sat, 2 Sep 2023 14:53:50 +0200 Subject: [PATCH] Remove user creation and use UID/GID 8000 to run process --- Dockerfile | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 61046ef..c5a355f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,5 @@ FROM golang:1.20-alpine AS build-env -ENV USER=appuser -ENV UID=8000 - -RUN adduser \ - --disabled-password \ - --gecos "" \ - --home "/null" \ - --shell "/sbin/nologin" \ - --no-create-home \ - --uid "${UID}" \ - "${USER}" - WORKDIR /tmp/build ADD . /tmp/build # -ldlflags '-s' to strip binary @@ -21,15 +9,13 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app -ldflags '-w -s' FROM scratch -LABEL org.opencontainers.image.source = "https://github.com/pcvolkmer/idicon" -LABEL org.opencontainers.image.licenses = "MIT" -LABEL org.opencontainers.image.description = "Simple identicon service" +LABEL org.opencontainers.image.source="https://github.com/pcvolkmer/idicon" +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.description="Simple identicon service" -COPY --from=build-env /etc/passwd /etc/passwd -COPY --from=build-env /etc/group /etc/group COPY --from=build-env /tmp/build/app /idicon -USER appuser:appuser +USER 8000:8000 EXPOSE 8000