From f4579b120750565b26aa985f816b97deea506640 Mon Sep 17 00:00:00 2001 From: Danny Clark Date: Fri, 15 Nov 2024 16:56:02 +0000 Subject: [PATCH] fix: correct typo in Dockerfiles for TARGETARCH We also enable the go-synethetic example application to run cross-platform to match the rest of our binary Dockerfiles. --- cmd/config-reloader/Dockerfile | 2 +- cmd/datasource-syncer/Dockerfile | 2 +- cmd/operator/Dockerfile | 2 +- cmd/rule-evaluator/Dockerfile | 2 +- examples/instrumentation/go-synthetic/Dockerfile | 12 ++++++++++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/config-reloader/Dockerfile b/cmd/config-reloader/Dockerfile index ef93b4b9ca..aff1b1291b 100644 --- a/cmd/config-reloader/Dockerfile +++ b/cmd/config-reloader/Dockerfile @@ -14,7 +14,7 @@ FROM --platform=$BUILDPLATFORM google-go.pkg.dev/golang:1.23.2@sha256:335533a0cbaa2e5b0dc038ac7023418ac68c3bb22b8828fc354088bb0340019b AS buildbase ARG TARGETOS -ARG TAGETARCH +ARG TARGETARCH WORKDIR /app COPY go.mod go.mod COPY go.sum go.sum diff --git a/cmd/datasource-syncer/Dockerfile b/cmd/datasource-syncer/Dockerfile index 7e89b0ef81..f8f9f245f3 100644 --- a/cmd/datasource-syncer/Dockerfile +++ b/cmd/datasource-syncer/Dockerfile @@ -14,7 +14,7 @@ FROM --platform=$BUILDPLATFORM google-go.pkg.dev/golang:1.23.2@sha256:335533a0cbaa2e5b0dc038ac7023418ac68c3bb22b8828fc354088bb0340019b AS buildbase ARG TARGETOS -ARG TAGETARCH +ARG TARGETARCH WORKDIR /app COPY . ./ diff --git a/cmd/operator/Dockerfile b/cmd/operator/Dockerfile index eb802ac03a..d35816d678 100644 --- a/cmd/operator/Dockerfile +++ b/cmd/operator/Dockerfile @@ -14,7 +14,7 @@ FROM --platform=$BUILDPLATFORM google-go.pkg.dev/golang:1.23.2@sha256:335533a0cbaa2e5b0dc038ac7023418ac68c3bb22b8828fc354088bb0340019b AS buildbase ARG TARGETOS -ARG TAGETARCH +ARG TARGETARCH WORKDIR /app COPY go.mod go.mod COPY go.sum go.sum diff --git a/cmd/rule-evaluator/Dockerfile b/cmd/rule-evaluator/Dockerfile index 9a61e89d7e..65ac7f6325 100644 --- a/cmd/rule-evaluator/Dockerfile +++ b/cmd/rule-evaluator/Dockerfile @@ -14,7 +14,7 @@ FROM --platform=$BUILDPLATFORM google-go.pkg.dev/golang:1.23.2@sha256:335533a0cbaa2e5b0dc038ac7023418ac68c3bb22b8828fc354088bb0340019b AS buildbase ARG TARGETOS -ARG TAGETARCH +ARG TARGETARCH WORKDIR /app COPY go.mod go.mod COPY go.sum go.sum diff --git a/examples/instrumentation/go-synthetic/Dockerfile b/examples/instrumentation/go-synthetic/Dockerfile index 86ea78f045..b8b2e4595f 100644 --- a/examples/instrumentation/go-synthetic/Dockerfile +++ b/examples/instrumentation/go-synthetic/Dockerfile @@ -12,13 +12,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM google-go.pkg.dev/golang:1.23.2@sha256:335533a0cbaa2e5b0dc038ac7023418ac68c3bb22b8828fc354088bb0340019b AS buildbase +FROM --platform=$BUILDPLATFORM google-go.pkg.dev/golang:1.23.2@sha256:335533a0cbaa2e5b0dc038ac7023418ac68c3bb22b8828fc354088bb0340019b AS buildbase +ARG TARGETOS +ARG TARGETARCH WORKDIR /app COPY . ./ FROM buildbase AS appbase -RUN CGO_ENABLED=0 GOEXPERIMENT=boringcrypto go build -o go-synthetic ./examples/instrumentation/go-synthetic +RUN if [ "${TARGETARCH}" = "arm64" ] && [ "${BUILDARCH}" != "arm64" ]; then \ + apt install -y --no-install-recommends \ + gcc-aarch64-linux-gnu libc6-dev-arm64-cross; \ + CC=aarch64-linux-gnu-gcc; \ + fi && \ + GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=1 CC=${CC} \ + go build -tags boring -mod=vendor -o go-synthetic -ldflags='-linkmode=external -extldflags=-static' ./examples/instrumentation/go-synthetic FROM gcr.io/distroless/static-debian11:latest COPY --from=appbase /app/go-synthetic /bin/go-synthetic