Skip to content

Commit c2c1863

Browse files
authored
Use scratch to support building for more archs (#167)
Support mips64le and 386
1 parent 08e17cd commit c2c1863

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ jobs:
7070
file: build/Dockerfile
7171
context: '.'
7272
target: local
73-
platforms: linux/arm,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x
73+
platforms: linux/arm,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x,linux/mips64le,linux/386
7474
cache-from: type=local,src=/tmp/.buildx-cache
7575
cache-to: type=local,dest=/tmp/.buildx-cache
7676
tags: nginx/nginx-prometheus-exporter:${{ github.sha }}
@@ -119,7 +119,7 @@ jobs:
119119
file: build/Dockerfile
120120
context: '.'
121121
target: local
122-
platforms: linux/arm,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x
122+
platforms: linux/arm,linux/arm64,linux/amd64,linux/ppc64le,linux/s390x,linux/mips64le,linux/386
123123
tags: |
124124
nginx/nginx-prometheus-exporter:latest
125125
nginx/nginx-prometheus-exporter:${{ steps.get_version.outputs.GIT_TAG }}

build/Dockerfile

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.16-alpine as builder
1+
FROM golang:1.16 as base
22
ARG VERSION
33
ARG GIT_COMMIT
44
ARG TARGETARCH
@@ -9,20 +9,23 @@ COPY vendor ./vendor
99
COPY go.mod go.sum ./
1010
COPY collector ./collector
1111
COPY client ./client
12+
13+
FROM base as builder
1214
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 .
1315

1416

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

1922

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

2326

24-
FROM base as local
27+
FROM intermediate as local
2528
ARG TARGETARCH
2629
ARG TARGETVARIANT
2730

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

0 commit comments

Comments
 (0)