diff options
Diffstat (limited to 'other/bootstrap_daemon/docker/Dockerfile')
-rw-r--r-- | other/bootstrap_daemon/docker/Dockerfile | 127 |
1 files changed, 72 insertions, 55 deletions
diff --git a/other/bootstrap_daemon/docker/Dockerfile b/other/bootstrap_daemon/docker/Dockerfile index 5ef359cf..25a48b85 100644 --- a/other/bootstrap_daemon/docker/Dockerfile +++ b/other/bootstrap_daemon/docker/Dockerfile | |||
@@ -1,64 +1,81 @@ | |||
1 | FROM debian:buster-slim | 1 | ########################################################### |
2 | # Builder image: we compile the code here (static build) | ||
3 | FROM alpine:3.11.5 AS build | ||
4 | |||
5 | RUN ["apk", "--no-cache", "add",\ | ||
6 | "build-base",\ | ||
7 | "cmake",\ | ||
8 | "linux-headers",\ | ||
9 | "libconfig-dev",\ | ||
10 | "libconfig-static",\ | ||
11 | "libsodium-dev",\ | ||
12 | "libsodium-static",\ | ||
13 | "ninja",\ | ||
14 | "python3"\ | ||
15 | ] | ||
16 | |||
17 | WORKDIR /src/c-toxcore | ||
18 | |||
19 | # Very selectively add files to the image, because we may have random stuff | ||
20 | # lying around. In particular, we don't need to rebuild the docker image when | ||
21 | # toxav changes or the Dockerfile changes down from the build. | ||
22 | COPY cmake cmake | ||
23 | COPY other/bootstrap_daemon/src other/bootstrap_daemon/src | ||
24 | COPY other/bootstrap_node_packets.[ch] other/ | ||
25 | COPY other/DHT_bootstrap.c other/ | ||
26 | COPY other/pkgconfig other/pkgconfig | ||
27 | COPY other/rpm other/rpm | ||
28 | COPY testing/misc_tools.[ch] testing/ | ||
29 | COPY toxcore toxcore | ||
30 | COPY toxencryptsave toxencryptsave | ||
31 | COPY CMakeLists.txt so.version ./ | ||
32 | |||
33 | RUN ["cmake", "-B_build", "-H.",\ | ||
34 | "-GNinja",\ | ||
35 | "-DCMAKE_BUILD_TYPE=Release",\ | ||
36 | "-DFULLY_STATIC=ON",\ | ||
37 | "-DBUILD_TOXAV=OFF",\ | ||
38 | "-DBOOTSTRAP_DAEMON=ON"\ | ||
39 | ] | ||
40 | RUN ["cmake", "--build", "_build", "--target", "install"] | ||
2 | 41 | ||
3 | WORKDIR /tmp/tox | 42 | # Verify checksum from dev-built binary, so we can be sure Docker Hub doesn't |
43 | # mess with your binaries. | ||
44 | COPY other/bootstrap_daemon/docker/tox-bootstrapd.sha256 other/bootstrap_daemon/docker/ | ||
45 | RUN ["sha256sum", "/usr/local/bin/tox-bootstrapd"] | ||
46 | RUN ["sha256sum", "-c", "other/bootstrap_daemon/docker/tox-bootstrapd.sha256"] | ||
47 | |||
48 | # Remove all the example bootstrap nodes from the config file. | ||
49 | COPY other/bootstrap_daemon/tox-bootstrapd.conf other/bootstrap_daemon/ | ||
50 | # hadolint ignore=SC2086,SC2154 | ||
51 | RUN ["sed", "-i", "/^bootstrap_nodes = /,$d", "other/bootstrap_daemon/tox-bootstrapd.conf"] | ||
52 | |||
53 | # Add bootstrap nodes from https://nodes.tox.chat/. | ||
54 | COPY other/bootstrap_daemon/docker/get-nodes.py other/bootstrap_daemon/docker/ | ||
55 | RUN ["other/bootstrap_daemon/docker/get-nodes.py", "other/bootstrap_daemon/tox-bootstrapd.conf"] | ||
56 | |||
57 | ########################################################### | ||
58 | # Final image build: this is what runs the bootstrap node | ||
59 | FROM debian:buster-slim | ||
4 | 60 | ||
5 | RUN export BUILD_PACKAGES="\ | 61 | COPY --from=build /usr/local/bin/tox-bootstrapd /usr/local/bin/ |
6 | build-essential \ | 62 | COPY --from=build /src/c-toxcore/other/bootstrap_daemon/tox-bootstrapd.conf /etc/tox-bootstrapd.conf |
7 | cmake \ | 63 | RUN ["useradd", "--home-dir", "/var/lib/tox-bootstrapd", "--create-home",\ |
8 | git \ | 64 | "--system", "--shell", "/sbin/nologin",\ |
9 | libconfig-dev \ | 65 | "--comment", "Account to run the Tox DHT bootstrap daemon",\ |
10 | libsodium-dev \ | 66 | "--user-group", "tox-bootstrapd"\ |
11 | python3" && \ | 67 | ] |
12 | export RUNTIME_PACKAGES="\ | 68 | RUN ["chmod", "644", "/etc/tox-bootstrapd.conf"] |
13 | libconfig9 \ | 69 | RUN ["chmod", "700", "/var/lib/tox-bootstrapd"] |
14 | libsodium23" && \ | ||
15 | # get all deps | ||
16 | apt-get update && apt-get install -y $BUILD_PACKAGES $RUNTIME_PACKAGES && \ | ||
17 | # install toxcore and daemon | ||
18 | git clone https://github.com/TokTok/c-toxcore && \ | ||
19 | cd c-toxcore && \ | ||
20 | # checkout latest release version | ||
21 | git checkout $(git tag --list | grep -P '^v(\d+).(\d+).(\d+)$' | \ | ||
22 | sed "s/v/v /g" | sed "s/\./ /g" | \ | ||
23 | sort -snk4,4 | sort -snk3,3 | sort -snk2,2 | tail -n 1 | \ | ||
24 | sed 's/v /v/g' | sed 's/ /\./g') && \ | ||
25 | mkdir _build && \ | ||
26 | cd _build && \ | ||
27 | cmake .. \ | ||
28 | -DCMAKE_BUILD_TYPE=Release \ | ||
29 | -DENABLE_SHARED=ON \ | ||
30 | -DENABLE_STATIC=OFF \ | ||
31 | -DBUILD_TOXAV=OFF \ | ||
32 | -DBOOTSTRAP_DAEMON=ON && \ | ||
33 | make -j`nproc` && \ | ||
34 | make install -j`nproc` && \ | ||
35 | cd .. && \ | ||
36 | # add new user | ||
37 | useradd --home-dir /var/lib/tox-bootstrapd --create-home \ | ||
38 | --system --shell /sbin/nologin \ | ||
39 | --comment "Account to run Tox's DHT bootstrap daemon" \ | ||
40 | --user-group tox-bootstrapd && \ | ||
41 | chmod 700 /var/lib/tox-bootstrapd && \ | ||
42 | cp other/bootstrap_daemon/tox-bootstrapd.conf /etc/tox-bootstrapd.conf && \ | ||
43 | # remove all the example bootstrap nodes from the config file | ||
44 | sed -i '/^bootstrap_nodes = /,$d' /etc/tox-bootstrapd.conf && \ | ||
45 | # add bootstrap nodes from https://nodes.tox.chat/ | ||
46 | python3 other/bootstrap_daemon/docker/get-nodes.py >> /etc/tox-bootstrapd.conf && \ | ||
47 | # perform cleanup | ||
48 | apt-get remove --purge -y $BUILD_PACKAGES && \ | ||
49 | apt-get clean && \ | ||
50 | apt-get autoremove -y && \ | ||
51 | rm -rf /var/lib/apt/lists/* && \ | ||
52 | cd / && \ | ||
53 | rm -rf /tmp/* | ||
54 | 70 | ||
55 | WORKDIR /var/lib/tox-bootstrapd | 71 | WORKDIR /var/lib/tox-bootstrapd |
56 | 72 | ||
57 | USER tox-bootstrapd | 73 | USER tox-bootstrapd |
58 | 74 | ||
59 | ENTRYPOINT /usr/local/bin/tox-bootstrapd \ | 75 | ENTRYPOINT ["/usr/local/bin/tox-bootstrapd",\ |
60 | --config /etc/tox-bootstrapd.conf \ | 76 | "--config", "/etc/tox-bootstrapd.conf",\ |
61 | --log-backend stdout \ | 77 | "--log-backend", "stdout",\ |
62 | --foreground | 78 | "--foreground"\ |
79 | ] | ||
63 | 80 | ||
64 | EXPOSE 443/tcp 3389/tcp 33445/tcp 33445/udp | 81 | EXPOSE 443/tcp 3389/tcp 33445/tcp 33445/udp |