This repository has been archived by the owner on Mar 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Dockerfile
94 lines (65 loc) · 2.16 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# This file can be used directly with Docker.
#
# Prerequisites:
# go mod vendor
# bblfsh-sdk release
#
# However, the preferred way is:
# go run ./build.go driver:tag
#
# This will regenerate all necessary files before building the driver.
#==============================
# Stage 1: Native Driver Build
#==============================
FROM openjdk:8u181-slim as native
# install build dependencies
RUN apt update && apt install -y maven
ADD native /native
WORKDIR /native
# build native driver
RUN mvn install:install-file -Dfile=lib/org.eclipse.cdt.core_6.5.0.201807181141.jar -DgroupId=org.eclipse.cdt.core -DartifactId=cdtcore -Dversion=6.5.0 -Dpackaging=jar
RUN mvn package
#================================
# Stage 1.1: Native Driver Tests
#================================
FROM native as native_test
# run native driver tests
RUN mvn test
#=================================
# Stage 2: Go Driver Server Build
#=================================
FROM golang:1.13-alpine as driver
ENV DRIVER_REPO=github.com/bblfsh/cpp-driver
ENV DRIVER_REPO_PATH=/go/src/$DRIVER_REPO
ADD go.* $DRIVER_REPO_PATH/
ADD vendor $DRIVER_REPO_PATH/vendor
ADD driver $DRIVER_REPO_PATH/driver
WORKDIR $DRIVER_REPO_PATH/
ENV GO111MODULE=on GOFLAGS=-mod=vendor
# workaround for https://github.com/golang/go/issues/28065
ENV CGO_ENABLED=0
# build server binary
RUN go build -o /tmp/driver ./driver/main.go
# build tests
RUN go test -c -o /tmp/fixtures.test ./driver/fixtures/
#=======================
# Stage 3: Driver Build
#=======================
FROM openjdk:8u181-jre-alpine
LABEL maintainer="source{d}" \
bblfsh.language="cpp"
WORKDIR /opt/driver
# copy static files from driver source directory
ADD ./native/native.sh ./bin/native
# copy build artifacts for native driver
COPY --from=native /native/target/native-jar-with-dependencies.jar ./bin/
# copy driver server binary
COPY --from=driver /tmp/driver ./bin/
# copy tests binary
COPY --from=driver /tmp/fixtures.test ./bin/
# move stuff to make tests work
RUN ln -s /opt/driver ../build
VOLUME /opt/fixtures
# copy driver manifest and static files
ADD .manifest.release.toml ./etc/manifest.toml
ENTRYPOINT ["/opt/driver/bin/driver"]