Skip to content

Commit

Permalink
Use scratch to support building for more archs (#167)
Browse files Browse the repository at this point in the history
Support mips64le and 386
  • Loading branch information
lucacome authored Mar 22, 2021
1 parent 08e17cd commit c2c1863
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
file: build/Dockerfile
context: '.'
target: local
platforms: linux/arm,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x
platforms: linux/arm,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x,linux/mips64le,linux/386
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
tags: nginx/nginx-prometheus-exporter:${{ github.sha }}
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
file: build/Dockerfile
context: '.'
target: local
platforms: linux/arm,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x
platforms: linux/arm,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x,linux/mips64le,linux/386
tags: |
nginx/nginx-prometheus-exporter:latest
nginx/nginx-prometheus-exporter:${{ steps.get_version.outputs.GIT_TAG }}
Expand Down
13 changes: 8 additions & 5 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.16-alpine as builder
FROM golang:1.16 as base
ARG VERSION
ARG GIT_COMMIT
ARG TARGETARCH
Expand All @@ -9,20 +9,23 @@ COPY vendor ./vendor
COPY go.mod go.sum ./
COPY collector ./collector
COPY client ./client

FROM base as builder
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=$TARGETARCH go build -mod=vendor -a -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${GIT_COMMIT}" -o nginx-prometheus-exporter .


FROM gcr.io/distroless/static-debian10:nonroot as base
FROM scratch as intermediate
COPY --from=base /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
USER 1001:1001
ENTRYPOINT [ "/usr/bin/nginx-prometheus-exporter" ]


FROM base as container
FROM intermediate as container
COPY --from=builder /go/src/github.com/nginxinc/nginx-prometheus-exporter/nginx-prometheus-exporter /usr/bin/


FROM base as local
FROM intermediate as local
ARG TARGETARCH
ARG TARGETVARIANT

COPY dist/nginx-prometheus-exporter_linux_$TARGETARCH${TARGETVARIANT:+_7}/nginx-prometheus-exporter /usr/bin
COPY dist/nginx-prometheus-exporter_linux_$TARGETARCH${TARGETVARIANT:+_7}*/nginx-prometheus-exporter /usr/bin/

0 comments on commit c2c1863

Please sign in to comment.