|
1 | 1 | FROM arm64v8/golang:1.10.7-alpine3.8 as builder
|
2 | 2 |
|
| 3 | +# we want a static binary |
| 4 | +ENV CGO_ENABLED=0 |
| 5 | + |
| 6 | +RUN apk add --update wget git make gcc linux-headers libc-dev |
| 7 | + |
| 8 | +COPY . /go/src/github.com/contiv/vpp |
| 9 | + |
3 | 10 | # we need the loopback binary from CNI
|
4 | 11 | # this binary can be obtained from the cni tarball
|
5 |
| -RUN apk add --update wget \ |
6 |
| - && export CNI_VERSION=0.5.1 \ |
7 |
| - && wget https://github.com/containernetworking/cni/releases/download/v$CNI_VERSION/cni-arm64-v$CNI_VERSION.tgz \ |
8 |
| - -O /cni.tgz \ |
| 12 | +RUN export CNI_VERSION=0.5.1 \ |
| 13 | + && wget https://github.com/containernetworking/cni/releases/download/v$CNI_VERSION/cni-arm64-v$CNI_VERSION.tgz -O /cni.tgz \ |
9 | 14 | && mkdir /cni \
|
10 |
| - && tar -xvf /cni.tgz -C /cni \ |
11 |
| - && rm /cni.tgz |
12 |
| -COPY . /go/src/github.com/contiv/vpp |
| 15 | + && tar -xvf /cni.tgz -C /cni |
13 | 16 |
|
14 | 17 | # Build a custom version of the portmap plugin, modified for VPP-based networking.
|
15 |
| -RUN apk add --update git gcc linux-headers libc-dev \ |
16 |
| - && export CGO_ENABLED=0 \ |
17 |
| - && export CNI_PLUGIN_VERSION=0.7 \ |
| 18 | +RUN export CNI_PLUGIN_VERSION=0.7 \ |
18 | 19 | && mkdir -p /go/src/github.com/containernetworking \
|
19 | 20 | && cd /go/src/github.com/containernetworking \
|
20 | 21 | && git clone https://github.com/containernetworking/plugins.git -b v$CNI_PLUGIN_VERSION \
|
21 | 22 | && cd plugins/plugins/meta/portmap/ \
|
22 | 23 | && git apply /go/src/github.com/contiv/vpp/docker/vpp-cni/portmap.diff \
|
23 | 24 | && go build -ldflags '-s -w' -o /portmap
|
24 | 25 |
|
25 |
| -WORKDIR /go/src/github.com/contiv/vpp/cmd/contiv-cni |
| 26 | +WORKDIR /go/src/github.com/contiv/vpp |
| 27 | + |
| 28 | +# build contiv-cni |
| 29 | +RUN make contiv-cni |
26 | 30 |
|
27 | 31 | # we collect & store all files in one folder to make the resulting
|
28 | 32 | # image smaller when we copy them all in one single operation
|
29 |
| -RUN export CGO_ENABLED=0 \ |
30 |
| - && mkdir /output/ \ |
31 |
| - && cp /cni/loopback /output/ \ |
32 |
| - && cp /go/src/github.com/contiv/vpp/docker/vpp-cni/10-contiv-vpp.conflist /output/ \ |
33 |
| - && cp /go/src/github.com/contiv/vpp/docker/vpp-cni/install.sh /output/ \ |
34 |
| - && cp /portmap /output/ \ |
35 |
| - && go build -ldflags '-s -w' -o /output/contiv-cni contiv_cni.go |
36 |
| - |
| 33 | +RUN mkdir -p /output/cni/bin && mkdir -p /output/cni/cfg \ |
| 34 | + && cp cmd/contiv-cni/contiv-cni /output/cni/bin/ \ |
| 35 | + && cp /cni/loopback /output/cni/bin/ \ |
| 36 | + && cp /portmap /output/cni/bin/ \ |
| 37 | + && cp /go/src/github.com/contiv/vpp/docker/vpp-cni/install.sh /output/cni/ \ |
| 38 | + && cp /go/src/github.com/contiv/vpp/docker/vpp-cni/10-contiv-vpp.conflist /output/cni/cfg/ |
37 | 39 |
|
38 | 40 | FROM arm64v8/alpine:3.8
|
39 | 41 |
|
40 |
| -# set work directory |
41 |
| -WORKDIR /root/ |
42 |
| - |
43 |
| -COPY --from=builder /output/* /root/ |
| 42 | +COPY --from=builder /output/cni /cni |
44 | 43 |
|
45 | 44 | # run install script by default
|
46 |
| -CMD ["/root/install.sh"] |
| 45 | +CMD ["/cni/install.sh"] |
0 commit comments