-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup none-root user in final image stage
- Loading branch information
Qingping Hou
committed
Aug 27, 2020
1 parent
05684bb
commit 58eb4d4
Showing
2 changed files
with
7 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
dist | ||
Dockerfile | ||
*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |