Skip to content

Commit

Permalink
Merge pull request #152 from viccuad/main
Browse files Browse the repository at this point in the history
feat: Build image with scratch instead of distroless
  • Loading branch information
jvanz authored Dec 7, 2023
2 parents 446352e + 07d5a0c commit ae15f9b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ COPY internal/ internal/
# Build
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o audit-scanner .

# Use distroless as minimal base image to package the audit-scanner binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /workspace/audit-scanner .
USER 65532:65532
FROM alpine AS cfg
RUN echo "audit-scanner:x:65533:65533::/tmp:/sbin/nologin" >> /etc/passwd
RUN echo "audit-scanner:x:65533:audit-scanner" >> /etc/group

# Copy the statically-linked binary into a scratch container.
FROM scratch
COPY --from=cfg /etc/passwd /etc/passwd
COPY --from=cfg /etc/group /etc/group
COPY --from=builder --chmod=0755 /workspace/audit-scanner /audit-scanner
USER 65532:65532
ENTRYPOINT ["/audit-scanner"]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ build: fmt vet lint ## Build audit-scanner binary.

.PHONY: docker-build
docker-build: unit-tests
docker build -t ${IMG} .
DOCKER_BUILDKIT=1 docker build -t ${IMG} .

0 comments on commit ae15f9b

Please sign in to comment.