setup none-root user in final image stage

This commit is contained in:
Qingping Hou 2020-08-27 11:47:55 -07:00
parent 05684bb5dc
commit 58eb4d49d2
2 changed files with 7 additions and 4 deletions

3
.dockerignore Normal file
View File

@ -0,0 +1,3 @@
dist
Dockerfile
*.md

View File

@ -1,13 +1,13 @@
FROM golang:1.13.1 as build
RUN groupadd -g 1000 1000 && \
useradd -r -u 1000 -g 1000 1000
ADD . /app
RUN chown 1000 app
WORKDIR /app
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-extldflags "-static"'
FROM alpine:3.10.1
RUN addgroup --gid 1000 app && \
adduser --system --uid 1000 --ingroup app app
USER app
COPY --from=build /app/objinsync /bin/objinsync
USER 1000