This docker build file is created in order to build i2pd and include the i2pd-tools as well. The reason for doing this is that most involved i2p operations require the tools but they are not included inside the official i2pd Docker container such that compiling them outside of a container seems like overkill when they could just be bundled together.
Check out the bundle with Subversion to an empty directory:
svn export --force https://svn.grimore.org/docker/build/i2pd/
change to that directory and issue:
docker build -t TAG .
where:
TAG
represents a tag to set on the built image (ie: i2pd:latest
)
After i2pd is built, a container can be created and ran either via docker run
or deployed within the swarm with docker stack deploy
.
Note that if the image is to be deployed to a swarm, then more than likely the image should be committed to a local registry serving the local docker swarm.
# # Copyright (c) 2017-2022, The PurpleI2P Project # # This file is part of Purple i2pd project and licensed under BSD3 # # See full license text in LICENSE file at top of project tree # FROM alpine:latest LABEL authors="Mikal Villa <mikal@sigterm.no>, Darknet Villain <supervillain@riseup.net>" LABEL maintainer="Wizardry and Steamworks <wizardry.steamworks@outlook.com>" LABEL org.opencontainers.image.source=https://github.com/PurpleI2P/i2pd LABEL org.opencontainers.image.documentation=https://i2pd.readthedocs.io/en/latest/ LABEL org.opencontainers.image.licenses=BSD3 # Build arguments #ARG DISTCC_HOSTS="docker.internal:35001 docker.internal:35002 docker.internal:35003 docker.internal:35004" #ARG CC="distcc" #ARG CXX="distcc g++" ARG COMPILE_JOBS=2 # Expose git branch, tag and URL variables as arguments ARG GIT_BRANCH="openssl" ENV GIT_BRANCH=${GIT_BRANCH} ARG GIT_TAG="" ENV GIT_TAG=${GIT_TAG} ARG REPO_URL="https://github.com/PurpleI2P/i2pd.git" ENV REPO_URL=${REPO_URL} ENV I2PD_HOME="/home/i2pd" ENV DATA_DIR="${I2PD_HOME}/data" ENV DEFAULT_ARGS=" --datadir=$DATA_DIR" RUN mkdir -p "$I2PD_HOME" "$DATA_DIR" \ && adduser -S -h "$I2PD_HOME" i2pd \ && chown -R i2pd:nobody "$I2PD_HOME" # 1. Building binary # Each RUN is a layer, adding the dependencies and building i2pd in one layer takes around 8-900Mb, so to keep the # image under 20mb we need to remove all the build dependencies in the same "RUN" / layer. # # 1. install deps, clone and build. # 2. strip binaries. # 3. Purge all dependencies and other unrelated packages, including build directory. RUN apk update \ && apk --no-cache --virtual build-dependendencies add make gcc g++ libtool zlib-dev boost-dev build-base openssl-dev openssl miniupnpc-dev git boost-date_time boost-filesystem boost-chrono boost-program_options distcc \ && mkdir -p /tmp/build \ && cd /tmp/build && git clone -b ${GIT_BRANCH} ${REPO_URL} \ && cd i2pd \ && if [ -n "${GIT_TAG}" ]; then git checkout tags/${GIT_TAG}; fi \ && make -j${COMPILE_JOBS} USE_UPNP=yes \ && cp -R contrib/certificates /i2pd_certificates \ && mkdir -p /usr/local/bin \ && mv i2pd /usr/local/bin \ && cd /usr/local/bin \ && strip i2pd \ && rm -fr /tmp/build \ && mkdir -p /tmp/build \ && cd /tmp/build && git clone --recursive https://github.com/PurpleI2P/i2pd-tools \ && cd i2pd-tools \ && git submodule init && git submodule update && git submodule update --init && git pull --recurse-submodules \ && make -j${COMPILE_JOBS} \ && cp b33address offlinekeys keyinfo regaddr vain x25519 regaddr_3ld famtool i2pbase64 regaddralias keygen verifyhost routerinfo /usr/local/bin \ && cd /usr/local/bin \ && strip b33address offlinekeys keyinfo regaddr vain x25519 regaddr_3ld famtool i2pbase64 regaddralias keygen verifyhost routerinfo \ && rm -fr /tmp/build \ && apk --no-cache --purge del build-dependendencies build-base fortify-headers boost-dev zlib-dev openssl-dev \ miniupnpc-dev boost-python3 python3 gdbm boost-unit_test_framework linux-headers boost-prg_exec_monitor \ boost-serialization boost-wave boost-wserialization boost-math boost-graph boost-regex git pcre2 \ libtool g++ gcc boost-date_time boost-filesystem boost-chrono boost-program_options # 2. Adding required libraries to run i2pd to ensure it will run. RUN apk --no-cache add boost-filesystem boost-system boost-program_options boost-date_time boost-thread boost-iostreams openssl miniupnpc musl-utils libstdc++ # 3. Copy preconfigured config file and entrypoint COPY i2pd-docker.conf "$DATA_DIR/i2pd.conf" RUN chown i2pd:nobody "$DATA_DIR/i2pd.conf" COPY entrypoint.sh /entrypoint.sh RUN chmod a+x /entrypoint.sh RUN echo "export DATA_DIR=${DATA_DIR}" >> /etc/profile VOLUME "$DATA_DIR" EXPOSE 7070 4444 4447 7656 2827 7654 7650 USER i2pd ENTRYPOINT [ "/entrypoint.sh" ]