diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b96c113..1f77dd0 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 diff --git a/Dockerfile b/Dockerfile index a08092e..140d2bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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