-
Notifications
You must be signed in to change notification settings - Fork 7
/
Dockerfile
89 lines (62 loc) · 2 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
# 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 microsoft/dotnet:2.1-sdk as native
ADD native /native
WORKDIR /native
# build native driver
RUN dotnet publish -c Release -o out
#================================
# Stage 1.1: Native Driver Tests
#================================
FROM native as native_test
# run native driver tests
#=================================
# Stage 2: Go Driver Server Build
#=================================
FROM golang:1.13 as driver
ENV DRIVER_REPO=github.com/bblfsh/csharp-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 microsoft/dotnet:2.1-runtime
LABEL maintainer="source{d}" \
bblfsh.language="csharp"
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/out/*.dll ./bin/
COPY --from=native /native/out/native.runtimeconfig.json ./bin/native.runtimeconfig.json
# 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"]