Skip to content

Commit e3ab110

Browse files
author
Jeff Peeler
committed
fix(build): make static build work
For the static build target, force only archive versions of the required dependent libraries to be used (and make sure to install those packages). Also, do not statically build grpc-health-probe. Use of the build tag netgo implies the intention of avoiding the cgo resolver (but really isn't required anymore). However, the go install command has been changed to mirror upstream's latest changes.
1 parent dca0cdd commit e3ab110

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM openshift/origin-release:golang-1.10 as builder
22

33
RUN yum update -y && \
4-
yum install -y make git sqlite && \
4+
yum install -y make git sqlite glibc-static openssl-static zlib-static && \
55
yum groupinstall -y "Development Tools" "Development Libraries"
66

77
ENV GOPATH /go
@@ -21,7 +21,7 @@ RUN mkdir -p /go/src/github.com/grpc-ecosystem && \
2121
cd /go/src/github.com/grpc-ecosystem/grpc_health_probe && \
2222
go get -u github.com/golang/dep/cmd/dep && \
2323
dep ensure -vendor-only -v && \
24-
go install -a -tags netgo -ldflags "-linkmode external -extldflags -static"
24+
CGO_ENABLED=0 go install -a -tags netgo -ldflags "-w"
2525

2626
FROM openshift/origin-base
2727

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $(CMDS):
1010

1111
build: clean $(CMDS)
1212

13-
static: extra_flags=-ldflags '-w -extldflags "-static"'
13+
static: extra_flags=-ldflags '-w -extldflags "-Wl,-Bstatic -ldl -lc -lpthread -lcrypto -lz -static"'
1414
static: build
1515

1616
unit:

configmap-registry.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ WORKDIR /go/src/$PROJECT
1919

2020
COPY --from=builder /go/src/github.com/operator-framework/operator-registry/vendor/$ORG/grpc-health-probe .
2121
RUN dep ensure -vendor-only -v && \
22-
go install -a -tags netgo -ldflags "-linkmode external -extldflags -static"
22+
CGO_ENABLED=0 go install -a -tags netgo -ldflags "-w"
2323

2424

2525
FROM scratch

upstream.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ WORKDIR /go/src/$PROJECT
2323

2424
COPY --from=builder /build/vendor/$ORG/grpc-health-probe .
2525
RUN dep ensure -vendor-only -v && \
26-
go install -a -tags netgo -ldflags "-linkmode external -extldflags -static"
26+
CGO_ENABLED=0 go install -a -tags netgo -ldflags "-w"
2727

2828
FROM scratch
2929
COPY --from=builder /build/bundles.db /bundles.db

0 commit comments

Comments
 (0)