Skip to content

Commit b4848e9

Browse files
committed
build: make static build with oniguruma enabled
Now the docker container is based on alpine to make it slimmer. It also generates a new linux binary with libxml2 and oniguruma statically linked. This build uses musl instead of glibc. It also generates a linux static package extracted from the docker image. Signed-off-by: Javi Fontan <[email protected]>
1 parent 6926641 commit b4848e9

File tree

3 files changed

+16
-12
lines changed

3 files changed

+16
-12
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ jobs:
3838

3939
before_deploy:
4040
- make packages
41-
42-
after_deploy:
4341
- DOCKER_PUSH_LATEST=1 make docker-push
42+
- make static-package
4443

4544
deploy:
4645
provider: releases

Dockerfile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
FROM golang:1.10 as builder
1+
FROM golang:1.11-alpine as builder
22

33
RUN mkdir -p /go/src/github.com/src-d/gitbase
44
WORKDIR /go/src/github.com/src-d/gitbase
55
COPY . .
66

7-
RUN apt-get update && apt-get install libxml2-dev -y
7+
RUN apk add --update libxml2-dev git make bash gcc g++ curl oniguruma-dev
88
RUN go get github.com/golang/dep/...
99
RUN dep ensure
1010
RUN cd vendor/gopkg.in/bblfsh/client-go.v2 && make dependencies
11-
RUN go install -v github.com/src-d/gitbase/...
11+
RUN go install -v -tags oniguruma -ldflags "-linkmode external -extldflags '-static -lz'" github.com/src-d/gitbase/...
1212

13-
FROM ubuntu:16.04
13+
FROM alpine:3.8
1414

1515
COPY --from=builder /go/bin/gitbase /bin
1616
RUN mkdir -p /opt/repos
@@ -21,14 +21,9 @@ ENV GITBASE_REPOS=/opt/repos
2121
EXPOSE 3306
2222

2323
ENV TINI_VERSION v0.17.0
24-
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
24+
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static /tini
2525
RUN chmod +x /tini
2626

27-
RUN apt-get update \
28-
&& apt-get install libxml2-dev git -y \
29-
&& apt-get clean \
30-
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
31-
3227
ENTRYPOINT ["/tini", "--"]
3328

3429
CMD gitbase server -v \

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,13 @@ dependencies: bblfsh-client
2424

2525
upgrade:
2626
go run tools/rev-upgrade/main.go -p $(UPGRADE_PRJ) -r $(UPGRADE_REV)
27+
28+
static-package:
29+
PACKAGE_NAME=gitbase_$(VERSION)_static_linux_amd64 ; \
30+
docker rm gitbase-temp ; \
31+
docker create --rm --name gitbase-temp $(DOCKER_ORG)/gitbase:$(VERSION) && \
32+
mkdir -p build/$${PACKAGE_NAME} && \
33+
docker cp gitbase-temp:/bin/gitbase build/$${PACKAGE_NAME} && \
34+
cd build && \
35+
tar czvf $${PACKAGE_NAME}.tar.gz $${PACKAGE_NAME} && \
36+
docker rm gitbase-temp

0 commit comments

Comments
 (0)