Skip to content

Commit e40caf2

Browse files
author
Qi Xiao
committed
Build safe static binaries for production use (avoid glibc getaddrinfo panic)
1 parent a34dc43 commit e40caf2

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,12 @@ status:
3333

3434

3535
builder: status
36+
# alpine image libmusl is not compatible with golang race detector
37+
# also alpine libmusl is required for building static binaries to avoid glibc getaddrinfo panic
3638
docker build \
3739
--tag $(BUILDER):$(VERSION) \
3840
--tag $(BUILDER):latest \
39-
--build-arg BUILD_ARG=use_all_cores \
41+
--build-arg BUILD_ARG=release \
4042
-f docker/builder.Dockerfile \
4143
.
4244

@@ -183,6 +185,11 @@ client: bin/cql bin/cql.test bin/cql-fuse bin/cql-mysql-adapter bin/cql-faucet
183185

184186
all: bp miner client
185187

188+
build-release: bin/cqld bin/cql-minerd bin/cql bin/cql-fuse bin/cql-mysql-adapter bin/cql-faucet
189+
190+
release:
191+
make -j$(JOBS) build-release
192+
186193
clean:
187194
rm -rf bin/cql*
188195
rm -f *.cover.out

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Stage: all runner
2-
FROM frolvlad/alpine-glibc:latest
2+
FROM alpine:3.9
33

44
ARG COMMIT
55
ARG VERSION

docker/builder.Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Stage: builder
2-
FROM golang:1.11-stretch as builder
2+
FROM golang:1.11-alpine3.9 as builder
33

44
ARG BUILD_ARG
55

66
WORKDIR /go/src/github.com/CovenantSQL/CovenantSQL
77
COPY . .
8+
RUN apk --no-cache add build-base make git
89
RUN make clean
910
RUN GOOS=linux GOLDFLAGS="-linkmode external -extldflags -static" make ${BUILD_ARG}
10-
RUN rm -f bin/*.test
1111

0 commit comments

Comments
 (0)