Skip to content

Commit

Permalink
Update Dockerfile and CI for multi-platform builds (#6)
Browse files Browse the repository at this point in the history
* Use docker buildx in CI

* Update Dockerfile for buildx
  • Loading branch information
armsnyder authored Dec 4, 2022
1 parent 844efd3 commit b644781
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
with:
images: armsnyder/a2s-exporter

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

- name: Log in to Docker Hub
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v2
Expand Down
9 changes: 4 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# syntax=docker/dockerfile:1.4
FROM golang:1.19 AS builder
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
COPY internal internal
COPY *.go .
COPY . .
ARG BUILD_VERSION=development
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-w -s -X 'main.buildVersion=$BUILD_VERSION'" -o /bin/a2s-exporter .
ENV CGO_ENABLED=0
RUN --mount=type=cache,target=/root/.cache/go-build go build -ldflags="-w -s -X 'main.buildVersion=$BUILD_VERSION'" -o /bin/a2s-exporter .

FROM scratch
COPY --from=builder /bin/a2s-exporter /bin/a2s-exporter
Expand Down

0 comments on commit b644781

Please sign in to comment.