Skip to content

Commit

Permalink
build for arm in addition to x86 (#9)
Browse files Browse the repository at this point in the history
Signed-off-by: Sarah Funkhouser <[email protected]>
  • Loading branch information
golanglemonade authored Sep 25, 2024
1 parent 83742a5 commit 84da28a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
30 changes: 27 additions & 3 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
env:
APP_NAME: ${BUILDKITE_PIPELINE_SLUG}
IMAGE_REPO: ghcr.io/theopenlane/${APP_NAME}
IMAGE_TAG: ${BUILDKITE_BUILD_NUMBER}-${BUILDKITE_COMMIT:0:8}
SONAR_HOST: "https://sonarcloud.io"

steps:
- group: ":test_tube: Tests"
key: "tests"
Expand Down Expand Up @@ -93,6 +95,11 @@ steps:
key: "docker-pr-build"
cancel_on_build_failing: true
if: build.branch != "main" && build.tag == null
matrix:
setup:
platform:
- amd64
- arm64
commands: |
#!/bin/bash
ls
Expand All @@ -102,9 +109,11 @@ steps:
- "${IMAGE_REPO}"
extra_tags:
- "${IMAGE_TAG}"
- theopenlane/container-build#v1.0.0:
tag_prefix: "{{matrix.platform}}-"
- theopenlane/container-build#v1.1.0:
dockerfile: docker/Dockerfile
push: false
platforms: linux/{{matrix.platform}}
build-args:
- NAME=${APP_NAME}
- equinixmetal-buildkite/trivy#v1.18.5:
Expand All @@ -115,6 +124,11 @@ steps:
- label: ":docker: docker build and publish"
key: "docker-build"
cancel_on_build_failing: true
matrix:
setup:
platform:
- amd64
- arm64
if: build.branch == "main"
commands: |
#!/bin/bash
Expand All @@ -129,9 +143,12 @@ steps:
- "${IMAGE_REPO}"
extra_tags:
- "${IMAGE_TAG}"
- theopenlane/container-build#v1.0.0:
- latest
tag_prefix: "{{matrix.platform}}-"
- theopenlane/container-build#v1.1.0:
dockerfile: docker/Dockerfile
push: true
platforms: linux/{{matrix.platform}}
build-args:
- NAME=${APP_NAME}
- equinixmetal-buildkite/trivy#v1.18.5:
Expand All @@ -142,6 +159,11 @@ steps:
- label: ":docker: docker build and publish"
key: "docker-build-and-tag"
if: build.tag != null
matrix:
setup:
platform:
- amd64
- arm64
commands: |
#!/bin/bash
plugins:
Expand All @@ -154,9 +176,11 @@ steps:
- "${IMAGE_REPO}"
extra_tags:
- "${BUILDKITE_TAG}"
- theopenlane/container-build#v1.0.0:
tag_prefix: "{{matrix.platform}}-"
- theopenlane/container-build#v1.1.0:
dockerfile: docker/Dockerfile
push: true
platforms: linux/{{matrix.platform}}
build-args:
- NAME=${APP_NAME}
- equinixmetal-buildkite/trivy#v1.18.5:
Expand Down
7 changes: 5 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
FROM golang:1.23.1 AS builder
FROM --platform=$BUILDPLATFORM golang:1.23.1 AS builder

ARG TARGETOS
ARG TARGETARCH

WORKDIR /go/src/app
COPY . .

RUN CGO_ENABLED=1 GOOS=linux go build -o /go/bin/riverboat -a -ldflags '-linkmode external -extldflags "-static"' .
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o /go/bin/riverboat .

FROM gcr.io/distroless/static:nonroot

Expand Down

0 comments on commit 84da28a

Please sign in to comment.