Skip to content

Commit

Permalink
build docker image from scratch to reduce runtime dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrossbach committed Jul 29, 2024
1 parent 5a863bf commit 99194db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
# Go workspace file
go.work
go.work.sum
.idea
.idea
/noah-mqtt
12 changes: 10 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
FROM golang:alpine

FROM registry.access.redhat.com/ubi8/ubi-minimal AS builder
RUN microdnf install -y shadow-utils && microdnf clean all
RUN set -o pipefail && groupadd -r -g 1000 gouser && useradd -r -u 1000 -g gouser -m -d /opt/gouser -s /bin/bash gouser && cat /etc/passwd | grep gouser > /etc/passwd_gouser

FROM scratch
ARG VERSION
ENV VERSION=${VERSION}
ENTRYPOINT ["/noah-mqtt"]
COPY noah-mqtt /
COPY LICENSE /
COPY --from=builder /etc/pki/tls/certs/ca-bundle.crt /etc/pki/tls/certs/
COPY --from=builder /etc/passwd_gouser /etc/passwd
USER gouser
ENTRYPOINT ["/noah-mqtt"]

0 comments on commit 99194db

Please sign in to comment.