Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use scratch to support building for more archs #167

Merged
merged 1 commit into from
Mar 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/