Skip to content

Commit 6e44bb1

Browse files
author
kuba--
committed
multi-stage docker file
Signed-off-by: kuba-- <[email protected]>
1 parent 87dd0b3 commit 6e44bb1

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

Dockerfile

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1+
#================================
2+
# Stage 1: Build Gitbase
3+
#================================
4+
FROM golang:1.11-alpine as gitbase-build
5+
6+
ENV GITBASE_REPO=github.com/src-d/gitbase
7+
ENV GITBASE_PATH=$GOPATH/src/$GITBASE_REPO
8+
9+
COPY . $GITBASE_PATH
10+
WORKDIR $GITBASE_PATH
11+
RUN go build -ldflags="-s -w" -o /bin/gitbase ./cmd/gitbase
12+
13+
#=================================
14+
# Stage 2: Start Gitbase Server
15+
#=================================
116
FROM alpine:3.8
217

3-
COPY build/bin/gitbase /bin
418
RUN mkdir -p /opt/repos
519

620
ENV GITBASE_USER=root
@@ -11,12 +25,12 @@ EXPOSE 3306
1125
ENV TINI_VERSION v0.18.0
1226
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-static-amd64 /tini
1327
RUN chmod +x /tini
14-
15-
RUN apk --no-cache add libxml2 git oniguruma libc6-compat
16-
1728
ENTRYPOINT ["/tini", "--"]
1829

19-
CMD gitbase server -v \
30+
# copy build artifacts
31+
COPY --from=gitbase-build /bin/gitbase /bin/gitbase
32+
33+
CMD /bin/gitbase server -v \
2034
--host=0.0.0.0 \
2135
--port=3306 \
2236
--user="$GITBASE_USER" \

0 commit comments

Comments
 (0)