1- FROM golang:1.13 as build
1+ # Build the traceroute-caller binary
2+ FROM golang:1.13 as build_caller
23ADD . /go/src/github.com/m-lab/traceroute-caller
4+ RUN rm /go/src/github.com/m-lab/traceroute-caller/Dockerfile
35ENV GOARCH amd64
46ENV CGO_ENABLED 0
57ENV GOOS linux
@@ -10,35 +12,68 @@ RUN go get -v \
1012RUN chmod -R a+rx /go/bin/traceroute-caller
1113
1214
13- FROM ubuntu:latest
14- # Install all the standard packages we need and then remove the apt-get lists.
15+ # Build the binaries that are called by traceroute-caller
16+ FROM ubuntu:latest as build_tracers
17+ # Install all the packages we need and then remove the apt-get lists.
18+ # iproute2 gives us ss
19+ # all the other packages are for the build processes.
1520RUN apt-get update && \
16- apt-get install -y python python-pip make iproute2 coreutils autoconf libtool git build-essential && \
21+ apt-get install -y make coreutils autoconf libtool git build-essential && \
1722 apt-get clean && \
1823 rm -rf /var/lib/apt/lists/*
1924
25+ # Build and install scamper
2026RUN ls -l
2127RUN mkdir /scamper-src
2228ADD ./vendor/scamper/ /scamper-src
2329RUN chmod +x /scamper-src/scamper-cvs-20190916/configure
2430WORKDIR /scamper-src/scamper-cvs-20190916/
25- RUN ./configure
31+ RUN ./configure --prefix=/scamper
2632RUN make -j 8
2733RUN make install
28- RUN ldconfig
2934
35+ # Build and install paris-traceroute
3036RUN mkdir /pt-src
3137ADD ./vendor/libparistraceroute/ /pt-src
3238WORKDIR /pt-src
33- RUN mkdir m4
39+ RUN mkdir -p m4
3440RUN ./autogen.sh
35- RUN ./configure
41+ RUN ./configure --prefix=/paris-traceroute
3642RUN make -j 8
3743RUN make install
44+
45+ # Create an image for the binaries that are called by traceroute-caller without
46+ # any of the build tools.
47+ FROM ubuntu:latest
48+ # Install all the packages we need and then remove the apt-get lists.
49+ # iproute2 gives us ss
50+ RUN apt-get update && \
51+ apt-get install -y iproute2 && \
52+ apt-get clean && \
53+ rm -rf /var/lib/apt/lists/*
54+
55+ # Bring the statically-linked traceroute-caller binary from the go build image.
56+ COPY --from=build_caller /go/bin/traceroute-caller /
57+
58+ # Bring the dynamically-linked traceroute binaries from their build image.
59+ COPY --from=build_tracers /scamper /scamper
60+ RUN cp -R /scamper/* /usr/local/.
61+ RUN rm -Rf /scamper
62+
63+ COPY --from=build_tracers /paris-traceroute /paris-traceroute
64+ RUN cp -R /paris-traceroute/* /usr/local/.
65+ RUN rm -Rf /paris-traceroute
66+
67+ # They are dynamically-linked, so make sure to run ldconfig to locate all new
68+ # libraries.
3869RUN ldconfig
3970
40- COPY --from=build /go/bin/traceroute-caller /
71+ # Verify that all the binaries we depend on are actually available
72+ RUN which paris-traceroute
73+ RUN which scamper
74+ RUN which sc_attach
75+ RUN which sc_warts2json
76+ RUN which ss
4177
4278WORKDIR /
43-
4479ENTRYPOINT ["/traceroute-caller" ]
0 commit comments