Skip to content

Commit 4a85c8c

Browse files
committed
build: multi-stage builds and service configuration
- Updated `Dockerfile` to support multi-stage builds - Introduced a new `compose.yml` file for service definition - Updated documentation build: consistently use editable install build: extend base service feat: obwatcher config from environment variable revert: obwatcher
1 parent 21cbc31 commit 4a85c8c

File tree

7 files changed

+110
-18
lines changed

7 files changed

+110
-18
lines changed

.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
.git
22
*.egg-info
33
deps
4-
jmvenv
4+
jmvenv
5+
compose.yml
6+
Dockerfile

Dockerfile

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,34 @@
1-
FROM debian:bookworm-slim
2-
3-
RUN mkdir -p /jm/clientserver
1+
ARG BITCOIN_VERSION=29.2
2+
ARG PYTHON_IMAGE_TAG=3.13-slim-trixie
3+
FROM bitcoin/bitcoin:${BITCOIN_VERSION} AS bitcoin
4+
FROM python:${PYTHON_IMAGE_TAG} AS python
45
WORKDIR /jm/clientserver
56

6-
COPY . .
7-
8-
RUN apt-get update && apt-get install -y --no-install-recommends gnupg ca-certificates=* curl=* \
9-
python3-pip=* python3=* \
10-
&& pip3 config set global.break-system-packages true \
11-
&& pip3 install 'wheel>=0.35.1' \
12-
&& ./install.sh --docker-install \
13-
&& apt-get purge -y --autoremove python3-pip \
7+
FROM python AS base-deps
8+
RUN DEBIAN_FRONTEND=noninteractive \
9+
apt-get update \
10+
&& apt-get install -y --no-install-recommends \
11+
libsecp256k1-2 \
12+
libsodium23 \
13+
openssl \
14+
tor \
1415
&& apt-get clean \
1516
&& rm -rf /var/lib/apt/lists/*
1617

18+
FROM base-deps AS builder
19+
COPY . .
20+
RUN python -m venv jmvenv \
21+
&& . ./jmvenv/bin/activate \
22+
&& pip install -e .[services]
23+
24+
FROM base-deps AS base
25+
COPY --from=builder /jm/clientserver /jm/clientserver
26+
ENTRYPOINT ["./scripts/docker-entrypoint.sh"]
27+
28+
FROM base AS test
29+
ARG BITCOIN_VERSION
30+
COPY --from=bitcoin /opt/bitcoin-${BITCOIN_VERSION}/bin /usr/local/bin/
31+
RUN . ./jmvenv/bin/activate \
32+
&& pip install -e .[test]
33+
34+
FROM base AS joinmarket

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ Alternative to this "quickstart": follow the [install guide](docs/INSTALL.md).
6262
* [Installation guide for Qubes+Whonix](https://github.com/qubenix/qubes-whonix-bitcoin/blob/master/1_joinmarket.md).
6363
* [Youtube video installation tutorial for Ubuntu](https://www.youtube.com/watch?v=zTCC86IUzWo).
6464

65+
### Docker
66+
67+
JoinMarket can be built and run using Docker. To build the Docker image:
68+
69+
docker build -t joinmarket .
70+
71+
To run tests using Docker Compose:
72+
73+
docker compose up test
74+
75+
This will run the full test suite in an isolated environment with all necessary dependencies including Bitcoin Core.
76+
6577
### Usage
6678

6779
If you are new, follow and read the links in the [usage guide](docs/USAGE.md).

compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
services:
2+
x-jmbase:
3+
build:
4+
context: .
5+
args:
6+
BITCOIN_VERSION: 29.2
7+
PYTHON_IMAGE_TAG: 3.13-slim-trixie
8+
volumes:
9+
- ./src:/jm/clientserver/src
10+
- ./test:/jm/clientserver/test
11+
- ./scripts:/jm/clientserver/scripts
12+
test:
13+
extends: x-jmbase
14+
image: joinmarket:test
15+
build:
16+
target: test
17+
shm_size: '2gb'
18+
command: ["./test/run_tests.sh", "-v"]

docs/INSTALL.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,34 @@ There, you need to install the client code (without Joinmarket's bitcoin):
265265
266266
#### Docker Installation
267267
268-
The [Dockerfile](../Dockerfile) provided builds a minimal Docker image which can help in getting started with a custom Docker setup. An example of building and running the [wallet-tool.py](../scripts/wallet-tool.py) script:
268+
The [Dockerfile](../Dockerfile) provided builds an optimized multi-stage Docker image for JoinMarket. The build process is optimized for layer caching and includes all necessary dependencies.
269269
270-
```
271-
docker build -t joinmarket-test ./
272-
docker run --rm -it joinmarket-test bash -c "cd scripts && python3 wallet-tool.py --help"
273-
```
270+
##### Building the Docker image
271+
272+
To build the production image:
273+
274+
docker build -t joinmarket .
275+
276+
This creates a minimal production image with JoinMarket installed.
277+
278+
##### Running JoinMarket scripts in Docker
279+
280+
Example of running the [wallet-tool.py](../scripts/wallet-tool.py) script:
281+
282+
docker run --rm -it joinmarket python ./scripts/wallet-tool.py --help"
283+
284+
##### Building custom images
285+
286+
The Dockerfile uses multi-stage builds with the following targets:
287+
288+
* `joinmarket` (default) - Production image with JoinMarket installed
289+
* `test` - Testing image that includes Bitcoin Core binaries
290+
291+
You can build a specific target:
292+
293+
docker build --target test -t joinmarket:test .
274294
275-
A new Docker image can be built using `joinmarket-test` as a base using `FROM joinmarket-test`. See [Docker documentation](https://docs.docker.com/engine/reference/builder/) for more details.
295+
See [Docker documentation](https://docs.docker.com/engine/reference/builder/) for more details on multi-stage builds.
276296
277297
#### Development (or making other changes to the code)
278298

docs/TESTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
### Test instructions (for developers):
22

3+
#### Quick start: Running tests with Docker
4+
5+
The easiest way to run the full test suite is using Docker Compose, which handles all dependencies automatically:
6+
7+
docker compose run --rm test
8+
9+
This will:
10+
11+
* Build a Docker image with all dependencies (Python, Bitcoin Core 29.2, miniircd)
12+
* Run the complete test suite in an isolated environment
13+
* Automatically download and set up miniircd
14+
* No need to install bitcoind or other dependencies on your host machine
15+
16+
For development, the Docker setup mounts the `src`, `scripts`, and `test` directories, so you can make changes locally and re-run tests without rebuilding the image.
17+
18+
#### Manual setup
19+
320
Work in your `jmvenv` virtual environment as for all Joinmarket work. Make sure to have [bitcoind](https://bitcoin.org/en/full-node) 28.1 or newer installed. Also need miniircd installed to the root (i.e. in your `joinmarket-clientserver` directory):
421

522
(jmvenv)$ cd /path/to/joinmarket-clientserver

scripts/docker-entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
# shellcheck disable=SC1091
4+
source jmvenv/bin/activate
5+
exec "$@"

0 commit comments

Comments
 (0)