From 1d545298bfab519708228fef8dbd6733cfe06b02 Mon Sep 17 00:00:00 2001 From: Callum Morris Date: Wed, 17 Dec 2025 09:45:58 +1300 Subject: [PATCH 1/2] feat: use CI_GO_IMAGE --- Dockerfile.tmplate | 5 +++-- cmd/fdsn-quake-consumer/Dockerfile | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Dockerfile.tmplate b/Dockerfile.tmplate index 3a5e7be..e69db8e 100644 --- a/Dockerfile.tmplate +++ b/Dockerfile.tmplate @@ -1,8 +1,8 @@ -ARG BUILDER_IMAGE=ghcr.io/geonet/base-images/golang:1.23.5-alpine3.21 +ARG CI_GO_IMAGE=ghcr.io/geonet/base-images/golang:1.23.5-alpine3.21 ARG RUNNER_IMAGE=ghcr.io/geonet/base-images/static:latest ARG RUN_USER=nobody # Only support image based on AlpineLinux -FROM ${BUILDER_IMAGE} as builder +FROM ${CI_GO_IMAGE} as builder # Obtain ca-cert and tzdata, which we will add to the container RUN apk add --no-cache --update gcc make musl-dev @@ -25,6 +25,7 @@ ENV GOPATH /usr/src/go ENV GOFLAGS -mod=vendor ENV GOOS linux ENV GOARCH amd64 +ENV GOTOOLCHAIN=local RUN CGO_ENABLED=0 go install -a -ldflags "-X main.Prefix=${BUILD}/${GIT_COMMIT_SHA} -extldflags -static" /repo/cmd/${BUILD} FROM ${RUNNER_IMAGE} diff --git a/cmd/fdsn-quake-consumer/Dockerfile b/cmd/fdsn-quake-consumer/Dockerfile index d50fa59..49651f3 100644 --- a/cmd/fdsn-quake-consumer/Dockerfile +++ b/cmd/fdsn-quake-consumer/Dockerfile @@ -1,6 +1,7 @@ -ARG BUILDER_IMAGE=ghcr.io/geonet/base-images/golang:1.23.5-alpine3.21 +ARG CI_GO_IMAGE=ghcr.io/geonet/base-images/golang:1.23.5-alpine3.21 + +FROM ${CI_GO_IMAGE} as builder -FROM ${BUILDER_IMAGE} as builder # Obtain ca-cert and tzdata, which we will add to the container # Git commit SHA ARG GIT_COMMIT_SHA @@ -15,6 +16,7 @@ ENV GOFLAGS -mod=vendor ENV GOOS linux ENV GOARCH amd64 ENV CGO_ENABLED 0 +ENV GOTOOLCHAIN=local RUN go install -a -ldflags "-X main.Prefix=${BUILD}/${GIT_COMMIT_SHA}" /repo/cmd/fdsn-quake-consumer FROM ghcr.io/geonet/base-images/alpine-xslt:3.18 From 304f18a40f0c5b4ed395bdd12026c43d862a0c4b Mon Sep 17 00:00:00 2001 From: Callum Morris Date: Wed, 17 Dec 2025 10:19:16 +1300 Subject: [PATCH 2/2] fix: docker build warnings --- Dockerfile.tmplate | 14 +++++++------- cmd/fdsn-quake-consumer/Dockerfile | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Dockerfile.tmplate b/Dockerfile.tmplate index e69db8e..37512b2 100644 --- a/Dockerfile.tmplate +++ b/Dockerfile.tmplate @@ -2,7 +2,7 @@ ARG CI_GO_IMAGE=ghcr.io/geonet/base-images/golang:1.23.5-alpine3.21 ARG RUNNER_IMAGE=ghcr.io/geonet/base-images/static:latest ARG RUN_USER=nobody # Only support image based on AlpineLinux -FROM ${CI_GO_IMAGE} as builder +FROM ${CI_GO_IMAGE} AS builder # Obtain ca-cert and tzdata, which we will add to the container RUN apk add --no-cache --update gcc make musl-dev @@ -20,11 +20,11 @@ COPY vendor /repo/vendor COPY cmd/$BUILD /repo/cmd/$BUILD # Set a bunch of go env flags -ENV GOBIN /repo/gobin -ENV GOPATH /usr/src/go -ENV GOFLAGS -mod=vendor -ENV GOOS linux -ENV GOARCH amd64 +ENV GOBIN=/repo/gobin +ENV GOPATH=/usr/src/go +ENV GOFLAGS=-mod=vendor +ENV GOOS=linux +ENV GOARCH=amd64 ENV GOTOOLCHAIN=local RUN CGO_ENABLED=0 go install -a -ldflags "-X main.Prefix=${BUILD}/${GIT_COMMIT_SHA} -extldflags -static" /repo/cmd/${BUILD} @@ -38,7 +38,7 @@ EXPOSE $EXPOSE_PORT # Same ARG as before ARG BUILD # Need to make this an env for it to be interpolated by the shell -ENV TZ Pacific/Auckland +ENV TZ=Pacific/Auckland ENV BUILD_BIN=${BUILD} # We have to make our binary have a fixed name, otherwise, we cannot run it without a shell COPY --from=builder /repo/gobin/${BUILD} /${BUILD} diff --git a/cmd/fdsn-quake-consumer/Dockerfile b/cmd/fdsn-quake-consumer/Dockerfile index 49651f3..08214c4 100644 --- a/cmd/fdsn-quake-consumer/Dockerfile +++ b/cmd/fdsn-quake-consumer/Dockerfile @@ -1,6 +1,6 @@ ARG CI_GO_IMAGE=ghcr.io/geonet/base-images/golang:1.23.5-alpine3.21 -FROM ${CI_GO_IMAGE} as builder +FROM ${CI_GO_IMAGE} AS builder # Obtain ca-cert and tzdata, which we will add to the container # Git commit SHA @@ -10,12 +10,12 @@ ADD ./ /repo WORKDIR /repo # Set a bunch of go env flags -ENV GOBIN /repo/gobin -ENV GOPATH /usr/src/go -ENV GOFLAGS -mod=vendor -ENV GOOS linux -ENV GOARCH amd64 -ENV CGO_ENABLED 0 +ENV GOBIN=/repo/gobin +ENV GOPATH=/usr/src/go +ENV GOFLAGS=-mod=vendor +ENV GOOS=linux +ENV GOARCH=amd64 +ENV CGO_ENABLED=0 ENV GOTOOLCHAIN=local RUN go install -a -ldflags "-X main.Prefix=${BUILD}/${GIT_COMMIT_SHA}" /repo/cmd/fdsn-quake-consumer