Skip to content

Commit d98e03f

Browse files
committed
build: select non root user at runtime
1 parent fe6b456 commit d98e03f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Containerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ ENV GO111MODULE=on \
1515
RUN go mod tidy && \
1616
go build -ldflags "-X 'main.version=${VERSION}'" -o /app/bin/gitlab-sync ./cmd/main.go
1717

18+
FROM alpine:latest as security_provider
19+
20+
RUN addgroup -S gitlab-sync \
21+
&& adduser -S gitlab-sync -G gitlab-sync
22+
1823
FROM scratch
1924

25+
COPY --from=security_provider /etc/passwd /etc/passwd
26+
27+
USER gitlab-sync
28+
2029
COPY --from=build /app/bin/gitlab-sync /usr/local/bin/gitlab-sync
2130

2231
ENTRYPOINT [ "/usr/local/bin/gitlab-sync" ]

0 commit comments

Comments
 (0)