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 16
/
Dockerfile
90 lines (63 loc) · 2.04 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
# 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 python:3.6-alpine as native
ADD native /native
WORKDIR /native
# build native driver
RUN pip3 install -U --prefix=./.local ./python_package
#================================
# Stage 1.1: Native Driver Tests
#================================
FROM native as native_test
# run native driver tests
RUN cd ./python_package/test && PYTHONPATH=../../.local:$PYTHONPATH python3 -m unittest discover
#=================================
# Stage 2: Go Driver Server Build
#=================================
FROM golang:1.13-alpine as driver
ENV DRIVER_REPO=github.com/bblfsh/python-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 python:3.6-alpine
RUN apk add python2
LABEL maintainer="source{d}" \
bblfsh.language="python"
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/.local ./bin/.local
# 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"]