Skip to content

Commit 5386887

Browse files
committed
*: modify Dockerfile and Makefile to build a static binary with version of gitbase
Signed-off-by: Manuel Carmona <[email protected]>
1 parent a124ad4 commit 5386887

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,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 VERSION=$(git describe --exact-match --tags 2>/dev/null || \
12-
echo dev-$(git rev-parse --short HEAD)$(test -n "`git status --porcelain`" && echo "-dirty" || true)); \
13-
go install -v -tags oniguruma -ldflags "-linkmode external -extldflags '-static -lz' -X main.version=$VERSION" \
14-
github.com/src-d/gitbase/...
11+
RUN make static-build
1512

1613
FROM alpine:3.8
1714

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ static-package:
3434
cd build && \
3535
tar czvf $${PACKAGE_NAME}.tar.gz $${PACKAGE_NAME} && \
3636
docker rm gitbase-temp
37+
38+
# target used in the Dockerfile to build the static binary
39+
static-build: VERSION = $(shell git describe --exact-match --tags 2>/dev/null || dev-$(git rev-parse --short HEAD)$(test -n "`git status --porcelain`" && echo "-dirty" || true))
40+
static-build: LD_FLAGS += -linkmode external -extldflags '-static -lz'
41+
static-build: GO_BUILD_ARGS += -tags oniguruma
42+
static-build:
43+
go install -v $(GO_BUILD_ARGS) github.com/src-d/gitbase/...

0 commit comments

Comments
 (0)