forked from merbridge/merbridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
48 lines (32 loc) · 1.32 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
# set default platform for docker build
ARG BUILDPLATFORM=linux/amd64
FROM --platform=$BUILDPLATFORM golang:1.19.2 as mbctl
ARG TARGETOS
ARG TARGETARCH
WORKDIR /app
ADD go.mod .
ADD go.sum .
RUN go mod download
ADD . .
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "-s -w" -o ./dist/mbctl ./app/main.go
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "-s -w" -o ./dist/merbridge-cni ./app/cni/main.go
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -ldflags "-s -w" -o ./dist/merbridge-fd-back ./app/fd-back/main.go
FROM ubuntu:20.04 as compiler
WORKDIR /app
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update &&\
apt-get install -y git cmake make gcc python3 libncurses-dev gawk flex bison openssl \
libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf
RUN git clone -b v5.4 https://github.com/torvalds/linux.git --depth 1
RUN cd /app/linux/tools/bpf/bpftool && \
make && make install
FROM ubuntu:20.04
WORKDIR /app
RUN apt-get update && apt-get install -y libelf-dev make sudo clang iproute2 ethtool
COPY --from=compiler /usr/local/sbin/bpftool /usr/local/sbin/bpftool
COPY bpf bpf
COPY Makefile Makefile
COPY --from=mbctl /app/dist/mbctl mbctl
COPY --from=mbctl /app/dist/merbridge-cni merbridge-cni
COPY --from=mbctl /app/dist/merbridge-fd-back merbridge-fd-back
CMD /app/mbctl