Skip to content

Commit

Permalink
build: containers via multi-platform Dockerfile (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
burningalchemist committed Apr 16, 2023
1 parent 4874efb commit 20b353b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,12 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: ^1.18

- name: Check out the repo
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand All @@ -82,6 +80,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.multi-arch
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
Expand Down
20 changes: 20 additions & 0 deletions Dockerfile.multi-arch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM --platform=$BUILDPLATFORM quay.io/prometheus/golang-builder AS builder

# Get sql_exporter
ADD . /go/src/github.com/burningalchemist/sql_exporter
WORKDIR /go/src/github.com/burningalchemist/sql_exporter

# Do makefile
ARG TARGETOS
ARG TARGETARCH

RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make

# Make image and copy build sql_exporter
FROM --platform=$TARGETPLATFORM quay.io/prometheus/busybox:latest
LABEL maintainer="The Prometheus Authors <prometheus-developers@googlegroups.com>"
COPY --from=builder /go/src/github.com/burningalchemist/sql_exporter/sql_exporter /bin/sql_exporter

EXPOSE 9399
USER nobody
ENTRYPOINT [ "/bin/sql_exporter" ]
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ style:

test:
@echo ">> running tests"
@$(GO) test -short -race $(pkgs)
@$(GO) test -short $(pkgs)

format:
@echo ">> formatting code"
Expand Down

0 comments on commit 20b353b

Please sign in to comment.