Skip to content

Commit e79673d

Browse files
committedApr 24, 2020
Bug 1820438: Slim down upstream builder
With the static build fix for index images committed (operator-framework#173), we introduced a side effect of index images including all the build layers included in the build image. That bloated the index images using the default from image by over 1gb in size. To resolve this, this commit introduces two changes. First, it adds a multistage build to the upstream builder to just copy the output of the build into a scratch image rather than include all the layers from the base alpine image. Second, it adds a new opm dockerfile with the same format except that only the binaries needed to host index images are included. After this commit is merged, a release should be cut and the dockerfile generator needs to be updated to point to a new opm builder as the default from index
1 parent 2bdcd07 commit e79673d

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed
 

‎upstream-builder.Dockerfile

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.13-alpine
1+
FROM golang:1.13-alpine AS builder
22

33
RUN apk update && apk add sqlite build-base git mercurial bash
44
WORKDIR /build
@@ -12,8 +12,11 @@ RUN make static
1212
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.1 && \
1313
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-$(go env GOARCH) && \
1414
chmod +x /bin/grpc_health_probe
15-
RUN cp /build/bin/opm /bin/opm && \
16-
cp /build/bin/initializer /bin/initializer && \
17-
cp /build/bin/appregistry-server /bin/appregistry-server && \
18-
cp /build/bin/configmap-server /bin/configmap-server && \
19-
cp /build/bin/registry-server /bin/registry-server
15+
16+
FROM scratch
17+
COPY --from=builder /build/bin/opm /bin/opm
18+
COPY --from=builder /build/bin/initializer /bin/initializer
19+
COPY --from=builder /build/bin/appregistry-server /bin/appregistry-server
20+
COPY --from=builder /build/bin/configmap-server /bin/configmap-server
21+
COPY --from=builder /build/bin/registry-server /bin/registry-server
22+
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe

‎upstream-opm-builder.Dockerfile

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM golang:1.13-alpine AS builder
2+
3+
RUN apk update && apk add sqlite build-base git mercurial bash
4+
WORKDIR /build
5+
6+
COPY vendor vendor
7+
COPY cmd cmd
8+
COPY pkg pkg
9+
COPY Makefile Makefile
10+
COPY go.mod go.mod
11+
RUN make static
12+
RUN GRPC_HEALTH_PROBE_VERSION=v0.2.1 && \
13+
wget -qO/bin/grpc_health_probe https://github.com/grpc-ecosystem/grpc-health-probe/releases/download/${GRPC_HEALTH_PROBE_VERSION}/grpc_health_probe-linux-$(go env GOARCH) && \
14+
chmod +x /bin/grpc_health_probe
15+
16+
FROM scratch
17+
COPY --from=builder /build/bin/opm /bin/opm
18+
COPY --from=builder /bin/grpc_health_probe /bin/grpc_health_probe

0 commit comments

Comments
 (0)
Please sign in to comment.