Build docker image and push to registry.bitdeals.org / main-build-job (push) Successful in 3m0s
The sed pass that configures the daemon punished anyone setting a strong
password: '&' in a replacement means the whole match, so a password
containing one was silently rewritten into something else, and the '|'
delimiter made sed exit with 'unknown option to s'. Every setting rode in
one invocation and the script had no set -e, so that failure applied none
of them -- not apipassword, not apienabled, not apiinterface -- and the
daemon came up on whatever it had before without saying so.
esc() now escapes backslash, '&' and the delimiter via printf. The
expressions are anchored to the start of the line and name their key in the
replacement instead of using \1, so no backreference is involved and
nothing in another section can match. keys.dat also holds privsigningkey
and privencryptionkey for this node's Bitmessage identities; editing in
place leaves every byte outside [bitmessagesettings] untouched, which is
why this stays a line edit rather than a parse-and-rewrite.
The clients needed the other half of this: credentials go into an XML-RPC
URL, where '@' splits the userinfo and '#' truncates the rest, so a strong
password wrote correctly and still failed to connect. Both now
percent-encode. A '%' in the password remains unusable -- it breaks
PyBitmessage's own config reader and every API call returns 500.
Also here, all found while making the above safe:
- set -eu, with the keys.dat chown guarded. A misconfiguration now stops
the container instead of passing unnoticed.
- The seed-address retry loop used bash brace expansion under CMD ["sh"],
where /bin/sh is dash and {1..4} is a literal, so it ran once, not four
times.
- apt-get update shared a layer with nothing, letting a cached update feed
install months-stale package lists.
- HEALTHCHECK gained a start period; the startup VACUUM takes tens of
seconds on a large messages.dat and the container reported unhealthy for
all of it.
- Removed the AppImage systemd unit, AppArmor profile and updater script.
Nothing referenced them -- not the image, the deployment or the ansible
roles -- and the updater fetched a binary with no signature or checksum
check.
69 lines
2.4 KiB
Markdown
69 lines
2.4 KiB
Markdown
# 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.
|
|
|
|
This repository covers the docker deployment only. It used to also carry an
|
|
AppImage systemd unit, an AppArmor profile and an updater script; none of them
|
|
were referenced by the image, the deployment or the ansible roles, and the
|
|
updater fetched a binary with no signature or checksum check, so they were
|
|
removed rather than left looking usable.
|
|
|
|
# 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:
|
|
build:
|
|
context: https://git.bitdeals.org/private/bitmessage.git
|
|
dockerfile: ./docker/Dockerfile
|
|
image: registry.bitdeals.org/bitmessage
|
|
environment:
|
|
- BITMESSAGE_API_USER=bitmessage_api_user
|
|
- BITMESSAGE_API_PASSWORD=bitmessage_api_password
|
|
- BITMESSAGE_SEED_PHRASE=bitmessage_seed_phrase
|
|
- BITMESSAGE_SEED_ADDRESSES=1
|
|
- BITMESSAGE_TTL=172800
|
|
- BITMESSAGE_STOPRESENDINGAFTERXDAYS=60
|
|
ports:
|
|
- 8442:8442
|
|
```
|
|
|
|
## docker cli
|
|
|
|
```sh
|
|
docker run -d \
|
|
-e BITMESSAGE_API_USER=bitmessage_api_user \
|
|
-e BITMESSAGE_API_PASSWORD=bitmessage_api_password \
|
|
-e BITMESSAGE_SEED_PHRASE=bitmessage_seed_phrase \
|
|
-e BITMESSAGE_SEED_ADDRESSES=1 \
|
|
-e BITMESSAGE_TTL=172800 \
|
|
-e BITMESSAGE_STOPRESENDINGAFTERXDAYS=60
|
|
-p 8442:8442 \
|
|
registry.bitdeals.org/bitmessage
|
|
```
|
|
|
|
# Parameters
|
|
|
|
Container images are configured using parameters passed at runtime.
|
|
|
|
|Parameter|Function|
|
|
|:--------|:-------|
|
|
|-p 8442|API port|
|
|
|-e BITMESSAGE_API_USER|XML-RPC API user. Default: `bitmessage_api_user`|
|
|
|-e BITMESSAGE_API_PASSWORD|XML-RPC API password. Default: `bitmessage_api_password`|
|
|
|-e BITMESSAGE_SEED_PHRASE|Create Deterministic Addresses password. Default: created randomly. |
|
|
|-e BITMESSAGE_SEED_ADDRESSES|Number of Deterministic Addresses to generate. Default: `0`|
|
|
|-e BITMESSAGE_TTL|The expiration of newly send messages, in seconds. Default: `172800`|
|
|
|-e BITMESSAGE_STOPRESENDINGAFTERXDAYS|Stop resending unreceived message after X days. Default: `60`|
|
|
|-e BITMESSAGE_APIVARIANT|provides xml or json-RPC API. Default: `legacy`|
|
|
|