1+ # Prerequisites:
2+ # dep ensure --vendor-only
3+ # bblfsh-sdk release
4+
5+ # ==============================
6+ # Stage 1: Native Driver Build
7+ # ==============================
8+ FROM openjdk:8-slim as native
9+
10+ # install build dependencies
11+ RUN apt update && apt install -y maven
12+
13+
14+ ADD native /native
15+ WORKDIR /native
16+
17+ # build native driver
18+ RUN mvn package
19+
20+
21+ # ================================
22+ # Stage 1.1: Native Driver Tests
23+ # ================================
24+ FROM native as native_test
25+ # run native driver tests
26+ RUN mvn test
27+
28+
29+ # =================================
30+ # Stage 2: Go Driver Server Build
31+ # =================================
32+ FROM golang:1.10-alpine as driver
33+
34+ ENV DRIVER_REPO=github.com/bblfsh/java-driver
35+ ENV DRIVER_REPO_PATH=/go/src/$DRIVER_REPO
36+
37+ ADD vendor $DRIVER_REPO_PATH/vendor
38+ ADD driver $DRIVER_REPO_PATH/driver
39+
40+ WORKDIR $DRIVER_REPO_PATH/
41+
42+ # build tests
43+ RUN go test -c -o /tmp/fixtures.test ./driver/fixtures/
44+ # build server binary
45+ RUN go build -o /tmp/driver ./driver/main.go
46+
47+ # =======================
48+ # Stage 3: Driver Build
49+ # =======================
50+ FROM openjdk:8-jre-alpine
51+
52+ LABEL maintainer="source{d}" \
53+ bblfsh.language="java"
54+
55+ WORKDIR /opt/driver
56+
57+ # copy driver manifest and static files
58+ ADD .manifest.release.toml ./etc/manifest.toml
59+
60+ # copy static files from driver source directory
61+ ADD ./native/src/main/sh/native.sh ./bin/native
62+
63+
64+ # copy build artifacts for native driver
65+ COPY --from=native /native/target/native-jar-with-dependencies.jar ./bin/
66+
67+
68+ # copy tests binary
69+ COPY --from=driver /tmp/fixtures.test ./bin/
70+ # move stuff to make tests work
71+ RUN ln -s /opt/driver ../build
72+ VOLUME /opt/fixtures
73+
74+ # copy driver server binary
75+ COPY --from=driver /tmp/driver ./bin/
76+
77+ ENTRYPOINT ["/opt/driver/bin/driver" ]
0 commit comments