Skip to content

Commit d2abab3

Browse files
authored
Merge pull request #499 from jfontan/improvement/static-build
Static build
2 parents 6926641 + b8bb8fc commit d2abab3

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-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

docs/using-gitbase/getting-started.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ go get -u github.com/src-d/gitbase/...
4343

4444
#### Oniguruma support
4545

46+
**Note:** Oniguruma is enabled in the docker container and "static" linux binary.
47+
4648
On linux and macOS you can choose to build gitbase with oniguruma support, resulting in faster results for queries using the `language` UDF.
4749

4850
macOS:

0 commit comments

Comments
 (0)