Skip to content

Commit

Permalink
feat: use distroless image
Browse files Browse the repository at this point in the history
Signed-off-by: zufardhiyaulhaq <[email protected]>
  • Loading branch information
zufardhiyaulhaq committed Jun 6, 2024
1 parent 9c9437f commit e29d6b3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
29 changes: 5 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,36 +1,17 @@
#################
# Builder image
#################
FROM alpine:3.16 as base

USER root

RUN apk --no-cache add ca-certificates \
&& update-ca-certificates

RUN addgroup -g 10001 istio-upgrade-consumer && \
adduser --disabled-password --system --gecos "" --home "/home/istio-upgrade-consumer" --shell "/sbin/nologin" --uid 10001 istio-upgrade-consumer && \
mkdir -p "/home/istio-upgrade-consumer" && \
chown istio-upgrade-consumer:0 /home/istio-upgrade-consumer && \
chmod g=u /home/istio-upgrade-consumer && \
chmod g=u /etc/passwd

ENV USER=istio-upgrade-consumer
USER 10001
WORKDIR /home/istio-upgrade-consumer

#################
# Builder image
#################
FROM golang:1.22-bullseye AS builder

WORKDIR /app
COPY . .
RUN make build.binaries
RUN CGO_ENABLED=0 go build main.go

#################
# Final image
#################
FROM base
FROM gcr.io/distroless/base

COPY --from=builder /app/main /

COPY --from=builder /app/bin/istio-upgrade-consumer /usr/local/bin
CMD ["/main"]
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.22

require (
cloud.google.com/go/pubsub v1.36.1
github.com/kelseyhightower/envconfig v1.4.0
k8s.io/api v0.29.2
k8s.io/apimachinery v0.29.2
k8s.io/client-go v0.29.2
Expand Down Expand Up @@ -33,7 +34,6 @@ require (
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kelseyhightower/envconfig v1.4.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand Down

0 comments on commit e29d6b3

Please sign in to comment.