Skip to content

Commit

Permalink
setup none-root user in final image stage
Browse files Browse the repository at this point in the history
  • Loading branch information
Qingping Hou committed Aug 27, 2020
1 parent 05684bb commit 58eb4d4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
Dockerfile
*.md
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 58eb4d4

Please sign in to comment.