From 304a530df28a38b11e493b3fce720c140bd61672 Mon Sep 17 00:00:00 2001 From: status404 Date: Wed, 19 Oct 2022 05:05:45 -0400 Subject: [PATCH] Dockerfile --- Docker/Dockerfile | 58 +++++++++++++++++++++++++++++++++++++ README.md | 52 +++++++++++++++++++++++++++++++++ bitmessage-appimage.service | 25 ++++++++++++++++ docker-compose.yml | 11 +++++++ 4 files changed, 146 insertions(+) create mode 100644 Docker/Dockerfile create mode 100644 README.md create mode 100644 bitmessage-appimage.service create mode 100644 docker-compose.yml diff --git a/Docker/Dockerfile b/Docker/Dockerfile new file mode 100644 index 0000000..8bd162a --- /dev/null +++ b/Docker/Dockerfile @@ -0,0 +1,58 @@ +# A container for PyBitmessage daemon +FROM ubuntu:bionic-20220401 + +RUN apt-get update + +# Install dependencies +RUN apt-get install -yq --no-install-suggests --no-install-recommends \ + build-essential libcap-dev libssl-dev \ + python-all-dev python-msgpack python-pip python-setuptools \ + git + +WORKDIR /root +RUN git clone https://github.com/Bitmessage/PyBitmessage + +WORKDIR /root/PyBitmessage + +# Install +RUN pip2 install jsonrpclib . + +FROM ubuntu:bionic-20220401 + +EXPOSE 8442 + +ENV BITMESSAGE_API_USER=api +ENV BITMESSAGE_API_PASSWORD=changeme +ENV BITMESSAGE_SEED_PHRASE=changeme +ENV BITMESSAGE_SEED_ADDRESSES=1 + +ENV HOME /home/bitmessage +ENV BITMESSAGE_HOME ${HOME} + +COPY --from=0 /usr/local/ /usr/local/ + +# Install dependencies +RUN apt-get update \ + && apt-get install -yq --no-install-suggests --no-install-recommends python-setuptools \ + && rm -rf /var/lib/apt/lists/* + +# Create a user +RUN useradd --create-home --home-dir $HOME bitmessage + +WORKDIR ${HOME} +USER bitmessage + +# Generate default config +RUN pybitmessage -t + +# Setup environment +ENTRYPOINT sed -ie "s|\(apiinterface = \).*|\10\.0\.0\.0|g" keys.dat \ + #&& sed -ie "s|\(apivariant = \).*|\1json|g" keys.dat \ + && sed -ie "s|\(apiusername = \).*|\1$BITMESSAGE_API_USER|g" keys.dat \ + && sed -ie "s|\(apipassword = \).*|\1$BITMESSAGE_API_PASSWORD|g" keys.dat \ + && exec pybitmessage -d + +# Generate Deterministic address +HEALTHCHECK --retries=3 --interval=15s \ + CMD python -c "import xmlrpclib; api_link='http://$BITMESSAGE_API_USER:$BITMESSAGE_API_PASSWORD@127.0.0.1:8442/'; api = xmlrpclib.ServerProxy(api_link); print api.createDeterministicAddresses('$BITMESSAGE_SEED_PHRASE'.encode('base64'),$BITMESSAGE_SEED_ADDRESSES)" || exit 1 + diff --git a/README.md b/README.md new file mode 100644 index 0000000..99b0450 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# Intro + +[PyBitmessage](https://bitmessage.org/) is a client of the Bitmessages P2P communication protocol used to send encrypted messages to another person or to many subscribers. + +PyBitmessage client running as a daemon in docker container with XML-RPC API enabled. + +# Usage + +The container generates a Bitmessage Deterministic Addresses based on a `BITMESSAGE_SEED_PHRASE` variable. + +Here are some example snippets to help you get started creating a container. + +## docker-compose + +```yaml +version: "3" +services: + pybitmessage: + image: bitdeals/pybitmessage + environment: + - BITMESSAGE_API_USER= + - BITMESSAGE_API_PASSWORD= + - BITMESSAGE_SEED_PHRASE= + - BITMESSAGE_SEED_ADDRESSES=<1> + ports: + - 8442:8442 +``` + +## docker cli + +```sh +docker run -d \ + -e BITMESSAGE_API_USER=api \ + -e BITMESSAGE_API_PASSWORD=changeme \ + -e BITMESSAGE_SEED_PHRASE=changeme \ + -e BITMESSAGE_SEED_ADDRESSES=1 \ + -p 8442:8442 \ + bitdeals/pybitmessage +``` + +# Parameters + +Container images are configured using parameters passed at runtime. + +|Parameter|Function| +|:--------|:-------| +|-p 8442|XML-RPC API port TCP| +|-e BITMESSAGE_API_USER=|XML-RPC API user. Default: `api`| +|-e BITMESSAGE_API_PASSWORD=|XML-RPC API password. Default: `changeme`| +|-e BITMESSAGE_SEED_PHRASE|Create Deterministic Addresses password. Default: `changeme`| +|-e BITMESSAGE_SEED_ADDRESSES|Number of Deterministic Addresses to generate. Default: `1`| + diff --git a/bitmessage-appimage.service b/bitmessage-appimage.service new file mode 100644 index 0000000..0d17392 --- /dev/null +++ b/bitmessage-appimage.service @@ -0,0 +1,25 @@ +[Unit] +Description=Bitmessage appimage service +Documentation=https://bitmessage.org/wiki/API_Reference +ConditionPathExists=/home/bitmessage/PyBitmessage.AppImage +After=network.target +Wants=network.target + +[Service] +Type=forking +ExecStart=/home/bitmessage/PyBitmessage.AppImage --daemon +WorkingDirectory=/home/bitmessage +PIDFile=/home/bitmessage/.config/PyBitmessage/singleton.lock +KillMode=process +Restart=always +RestartSec=10 +#Nice=10 + +SyslogIdentifier=bitmessage +User=bitmessage +Group=bitmessage +PrivateTmp=yes + +[Install] +WantedBy=multi-user.target + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..2b1d46e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,11 @@ +version: '3.9' +services: + bitmessage: + image: bitdeals/pybitmessage:0.6.3.2-ubuntu + environment: + - BITMESSAGE_API_USER=bitmessage_api_user + - BITMESSAGE_API_PASSWORD=bitmessage_api_password + - BITMESSAGE_SEED_PHRASE=bitmessage_seed_phrase + ports: + - 8442:8442 +