Skip to content

Commit 430f129

Browse files
authored
Add comments and a check or two to the dockerfile. (#56)
* Add comments and a check or two to the dockerfile. * Don't distribute dev tools
1 parent 21c571c commit 430f129

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

Dockerfile

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
FROM golang:1.13 as build
1+
# Build the traceroute-caller binary
2+
FROM golang:1.13 as build_caller
23
ADD . /go/src/github.com/m-lab/traceroute-caller
4+
RUN rm /go/src/github.com/m-lab/traceroute-caller/Dockerfile
35
ENV GOARCH amd64
46
ENV CGO_ENABLED 0
57
ENV GOOS linux
@@ -10,35 +12,68 @@ RUN go get -v \
1012
RUN 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.
1520
RUN 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
2026
RUN ls -l
2127
RUN mkdir /scamper-src
2228
ADD ./vendor/scamper/ /scamper-src
2329
RUN chmod +x /scamper-src/scamper-cvs-20190916/configure
2430
WORKDIR /scamper-src/scamper-cvs-20190916/
25-
RUN ./configure
31+
RUN ./configure --prefix=/scamper
2632
RUN make -j 8
2733
RUN make install
28-
RUN ldconfig
2934

35+
# Build and install paris-traceroute
3036
RUN mkdir /pt-src
3137
ADD ./vendor/libparistraceroute/ /pt-src
3238
WORKDIR /pt-src
33-
RUN mkdir m4
39+
RUN mkdir -p m4
3440
RUN ./autogen.sh
35-
RUN ./configure
41+
RUN ./configure --prefix=/paris-traceroute
3642
RUN make -j 8
3743
RUN 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.
3869
RUN 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

4278
WORKDIR /
43-
4479
ENTRYPOINT ["/traceroute-caller"]

0 commit comments

Comments
 (0)