Skip to content

Commit 7befc65

Browse files
committed
Dockerfile: updates
- Switch to golang 1.21. - Use less cryptic tags for docker images - it's clear now that golang:1.21-bookworm is based on debian:bookworm. - Sort the installed packages alphabetically. - Move python3 installation to the first `apt-get install` invocation. - Install python-is-python3 package, seems like gcloud still prefers python name instead of python3. - Refresh the line that installs google-cloud-sdk.
1 parent 36cf8ab commit 7befc65

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Dockerfile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
# Explicitly using an docker.io/amd64/ image to avoid binary translation (assuming the build host is amd64)
2-
# golang:1.20 is based on debian:12, this is important to ensure we have libc compatibility for the copied binary
3-
FROM --platform=linux/amd64 docker.io/amd64/golang:1.20 as builder-amd64
2+
#
3+
# golang:1.21-bookworm is based on debian:bookworm, this is important to ensure we have libc compatibility for the copied binary
4+
5+
FROM --platform=linux/amd64 docker.io/amd64/golang:1.21-bookworm as builder-amd64
46
# We use dynamic linking when possible to reduce compile time and binary size
57
ENV CGO_ENABLED=1
68
COPY . /usr/src/mantle
79
# Build both here because variable builder names (to avoid caching and reusing the wrong one) are only supported with buildkit
810
RUN bash -c 'cd /usr/src/mantle && ./build ; mv bin bin-amd64 ; CGO_ENABLED=0 GOARCH=arm64 ./build ; mv bin bin-arm64'
911

10-
# See comment above about golang:1.20 why debian:12 is set here
11-
FROM docker.io/library/debian:12
12-
RUN apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends -y qemu-utils qemu-system-x86 qemu-system-aarch64 qemu-efi-aarch64 seabios ovmf lbzip2 sudo dnsmasq gnupg2 git curl iptables nftables dns-root-data ca-certificates sqlite3 jq awscli azure-cli
12+
# See comment above about golang:1.21-bookworm why debian:bookworm is set here
13+
FROM docker.io/library/debian:bookworm
14+
RUN apt-get update && apt-get upgrade -y && apt-get install --no-install-recommends -y awscli azure-cli ca-certificates curl dns-root-data dnsmasq git gnupg2 iptables jq lbzip2 nftables ovmf python-is-python3 python3 qemu-efi-aarch64 qemu-system-aarch64 qemu-system-x86 qemu-utils seabios sqlite3 sudo
1315
# from https://cloud.google.com/storage/docs/gsutil_install#deb
14-
RUN echo "deb http://packages.cloud.google.com/apt cloud-sdk main" > /etc/apt/sources.list.d/google-cloud-sdk.list && curl -fsSLo /etc/apt/trusted.gpg.d/cloud.google.gpg https://dl.k8s.io/apt/doc/apt-key.gpg && apt-get update -y && apt-get install --no-install-recommends -y python3 && apt-get install -y google-cloud-cli
16+
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.asc] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | tee /usr/share/keyrings/cloud.google.asc && apt-get update -y && apt-get install google-cloud-sdk -y
1517
COPY --from=builder-amd64 /usr/src/mantle/bin-amd64 /usr/local/bin-amd64
1618
COPY --from=builder-amd64 /usr/src/mantle/bin-arm64 /usr/local/bin-arm64
1719
RUN bash -c 'if [ "$(uname -m)" == "x86_64" ]; then rm -rf /usr/local/bin /usr/local/bin-arm64 ; mv /usr/local/bin-amd64 /usr/local/bin ; else rm -rf /usr/local/bin /usr/local/bin-amd64 ; mv /usr/local/bin-arm64 /usr/local/bin ; fi'

0 commit comments

Comments
 (0)