From d538fb055b1ba63181c779c189a5f17e796a8b4b Mon Sep 17 00:00:00 2001 From: dvn Date: Wed, 1 Aug 2018 17:24:40 +0200 Subject: docker: Add a docker quick-start directory --- docker/Dockerfile | 102 ++++++++++++++++++++++++++++++++++ docker/README.md | 130 ++++++++++++++++++++++++++++++++++++++++++++ docker/docker-entrypoint.sh | 15 +++++ docker/gnunet.conf | 21 +++++++ 4 files changed, 268 insertions(+) create mode 100644 docker/Dockerfile create mode 100644 docker/README.md create mode 100644 docker/docker-entrypoint.sh create mode 100644 docker/gnunet.conf diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 000000000..c91ce4210 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,102 @@ +FROM ubuntu:18.04 + +ENV DEBIAN_FRONTEND noninteractive + +# Install tools and dependencies +RUN apt-get update && \ + apt-get -y install --no-install-recommends \ + ca-certificates \ + libsasl2-modules \ + git \ + automake \ + autopoint \ + autoconf \ + texinfo \ + libtool \ + libltdl-dev \ + libgpg-error-dev \ + libidn11-dev \ + libunistring-dev \ + libglpk-dev \ + libbluetooth-dev \ + libextractor-dev \ + libmicrohttpd-dev \ + libgnutls28-dev \ + libgcrypt20-dev \ + libpq-dev \ + libsqlite3-dev && \ + apt-get clean all && \ + apt-get -y autoremove && \ + rm -rf \ + /var/lib/apt/lists/* \ + /tmp/* + +# Install GNUrl +ENV GNURL_GIT_URL https://git.taler.net/gnurl.git +ENV GNURL_GIT_BRANCH gnurl-7.57.0 + +RUN git clone $GNURL_GIT_URL \ + --branch $GNURL_GIT_BRANCH \ + --depth=1 \ + --quiet && \ + cd /gnurl && \ + autoreconf -i && \ + ./configure \ + --enable-ipv6 \ + --with-gnutls \ + --without-libssh2 \ + --without-libmetalink \ + --without-winidn \ + --without-librtmp \ + --without-nghttp2 \ + --without-nss \ + --without-cyassl \ + --without-polarssl \ + --without-ssl \ + --without-winssl \ + --without-darwinssl \ + --disable-sspi \ + --disable-ntlm-wb \ + --disable-ldap \ + --disable-rtsp \ + --disable-dict \ + --disable-telnet \ + --disable-tftp \ + --disable-pop3 \ + --disable-imap \ + --disable-smtp \ + --disable-gopher \ + --disable-file \ + --disable-ftp \ + --disable-smb && \ + make install && \ + cd - && \ + rm -fr /gnurl + +# Install GNUnet +ENV GNUNET_PREFIX /usr/local/gnunet +ENV CFLAGS '-g -Wall -O0' + +COPY ../ /gnunet + +RUN cd /gnunet && \ + ./bootstrap && \ + ./configure \ + --with-nssdir=/lib \ + --prefix="$GNUNET_PREFIX" \ + --enable-logging=verbose && \ + make -j3 && \ + make install && \ + ldconfig && \ + cd - && \ + rm -fr /gnunet + +# Configure GNUnet +COPY gnunet.conf /etc/gnunet.conf +COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint +RUN chmod 755 /usr/local/bin/docker-entrypoint + +ENV LOCAL_PORT_RANGE='40001 40200' +ENV PATH "$GNUNET_PREFIX/bin:/usr/local/bin:$PATH" + +ENTRYPOINT ["docker-entrypoint"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 000000000..4e0e6b951 --- /dev/null +++ b/docker/README.md @@ -0,0 +1,130 @@ +# gnunet-docker +A Dockerfile (and maybe later docker-compose.yml) for getting a running GNUnet docker container. + +> This README and parts of the Dockerfile were adapted from https://github.com/compiaffe/gnunet-docker + + +## Build it +This will take quite a while and will consume a bit of data. + +```bash +docker build -t gnunet . +``` + +## Start it from the newly created gnunet image +Start a container from `gnunet` image, which can access /dev/net/tun, has access to the host network. We are going to name it `gnunet1`. + +Note the `--rm` that will delete the container as soon as you stop it and `-ti` gives you an interactive terminal. + +#### Linux Users +```bash +docker run \ + --rm \ + -ti \ + --privileged \ + --name gnunet1 \ + --net=host \ + -v /dev/net/tun:/dev/net/tun \ + gnunet +``` + +#### Mac Users +```bash +docker run \ + --rm \ + -it \ + --privileged \ + --name gnunet1 \ + -e LOCAL_PORT_RANGE='40001 40200' \ + -e GNUNET_PORT=2086 \ + -p 2086:2086 \ + -p 2086:2086/udp \ + -p40001-40200:40001-40200 \ + -p40001-40200:40001-40200/udp \ + gnunet +``` + +This terminal will keep on printing to screen at the moment. So go on in a new terminal please. + +Don't worry about warnings too much... + +## Check if you are connected +Open a new terminal and connect to the container we just started: + +```bash +docker exec -it gnunet1 gnunet-peerinfo -i +``` + +If you get a list of peers, all is good. + +## Multiple containers on the same host +### Running +#### Run Container 1 +```bash +export GPORT=2086 LPORT='40001-40200' GNAME=gnunet1 +docker run \ + --rm \ + -it \ + --privileged \ + -e GNUNET_PORT=$GPORT \ + -e LOCAL_PORT_RANGE="${LPORT/-/ }" \ + -p $GPORT:$GPORT \ + -p $GPORT:$GPORT/udp \ + -p$LPORT:$LPORT \ + -p$LPORT:$LPORT/udp \ + --name $GNAME \ + gnunet +``` + +#### Run Container 2 +```bash +export GPORT=2087 LPORT='40201-40400' GNAME=gnunet2 +docker run \ + --rm \ + -it \ + --privileged \ + -e GNUNET_PORT=$GPORT \ + -e LOCAL_PORT_RANGE="${LPORT/-/ }" \ + -p $GPORT:$GPORT \ + -p $GPORT:$GPORT/udp \ + -p$LPORT:$LPORT \ + -p$LPORT:$LPORT/udp \ + --name $GNAME \ + gnunet +``` + +### Testing cadet example +#### Container 1 +```bash +$ docker exec -it gnunet1 bash +$ gnunet-peerinfo -s +I am peer `VWPN1NZA6YMM866EJ5J2NY47XG692MQ6H6WASVECF0M18A9SCMZ0'. +$ gnunet-cadet -o asdasd +``` + +#### Container 2 +```bash +$ docker exec -it gnunet2 bash +$ gnunet-cadet VWPN1NZA6YMM866EJ5J2NY47XG692MQ6H6WASVECF0M18A9SCMZ0 asdasd +``` + +### Testing file sharing example +#### Container 1 +```bash +$ docker exec -it gnunet1 bash +$ echo 'test' > test.txt +$ gnunet-publish test.txt +Publishing `/test.txt' done. +URI is `gnunet://fs/chk/1RZ7A8TAQHMF8DWAGTSZ9CSA365T60C4BC6DDS810VM78D2Q0366CRX8DGFA29EWBT9BW5Y9HYD0Z1EAKNFNJQDJ04QQSGTQ352W28R.7MYB03GYXT17Z93ZRZRVV64AH9KPWFSVDEZGVE84YHD63XZFJ36B86M48KHTZVF87SZ05HBVB44PCXE8CVWAH72VN1SKYPRK1QN2C98.5'. +``` + +#### Container 2 +```bash +$ docker exec -it gnunet2 bash +$ gnunet-download -o out.file "gnunet://fs/chk/1RZ7A8TAQHMF8DWAGTSZ9CSA365T60C4BC6DDS810VM78D2Q0366CRX8DGFA29EWBT9BW5Y9HYD0Z1EAKNFNJQDJ04QQSGTQ352W28R.7MYB03GYXT17Z93ZRZRVV64AH9KPWFSVDEZGVE84YHD63XZFJ36B86M48KHTZVF87SZ05HBVB44PCXE8CVWAH72VN1SKYPRK1QN2C98.5" +100% [============================================================] +Downloading `out.file' done (0 b/s). +$ cat out.file +test +``` + diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh new file mode 100644 index 000000000..7f98ef68b --- /dev/null +++ b/docker/docker-entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash -e + +echo "${LOCAL_PORT_RANGE:-49152 65535}" > /proc/sys/net/ipv4/ip_local_port_range +sed -i 's/$GNUNET_PORT/'${GNUNET_PORT:-2086}'/g' /etc/gnunet.conf + +if [[ $# -eq 0 ]]; then + exec gnunet-arm \ + --config=/etc/gnunet.conf \ + --start \ + --monitor +elif [[ -z $1 ]] || [[ ${1:0:1} == '-' ]]; then + exec gnunet-arm "$@" +else + exec "$@" +fi diff --git a/docker/gnunet.conf b/docker/gnunet.conf new file mode 100644 index 000000000..c8299ef46 --- /dev/null +++ b/docker/gnunet.conf @@ -0,0 +1,21 @@ +[arm] +SYSTEM_ONLY = NO +USER_ONLY = NO + +[fs] +FORCESTART = NO + +[nat] +ENABLE_UPNP = NO +BEHIND_NAT = YES + +[transport-tcp] +PORT = $GNUNET_PORT +ADVERTISED_PORT = $GNUNET_PORT + +[transport-udp] +PORT = $GNUNET_PORT +BROADCAST = YES + +[cadet] +TESTING_IGNORE_KEYS = ACCEPT_FROM; -- cgit v1.2.3