-
Notifications
You must be signed in to change notification settings - Fork 77
Description
I am trying (actually managed, but I will get there) to run Joinmarket and Jam separately under a Docker Compose setup.
It seems the instructions for connecting to a local joinmarket instance are outdated, I think none of the env vars mentioned in the final docker run ...
command for running Jam are actually used in code, at least I couldn't find them in the repo:
docker run --rm -it \
--add-host=host.docker.internal:host-gateway \
--env JAM_JMWALLETD_HOST="host.docker.internal" \
--env JAM_JMWALLETD_API_PORT="28183" \
--env JAM_JMWALLETD_WEBSOCKET_PORT="28283" \
--env JAM_JMOBWATCH_PORT="62601" \
--publish "3000:80" \
ghcr.io/joinmarket-webui/jam-ui-only:${jam_version}
I found this setupProxy.js file which should setup the proxy calls to the Joinmarket services, but I think it is problematic because 1) it assumes the services are running on localhost
, so I have to expose them on the host machine even if all the services are running under Docker and 2) I believe it only works on dev mode (running with npm run dev
).
I think theoretically I should be able to make it work by treating Docker as a remote machine and setting up the SSH tunnel as mentioned in here, but I only thought about this after getting a working setup using nginx, and it also seems to not be needed when running under Docker.
The way I managed to get it to work was by:
1. Build Jam with a Dockerfile and run it with nginx
Dockerfile:
FROM node:20-alpine AS builder
WORKDIR /app
COPY ./jam .
RUN npm install && npm run build
FROM nginx:alpine
RUN rm -rf /usr/share/nginx/html/*
COPY --from=builder /app/build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]
nginx.conf:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
# Serve static frontend
root /usr/share/nginx/html;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}
# Proxy API calls to jmwalletd
location /api/ {
proxy_pass https://jmwalletd:28183/api/;
proxy_set_header Authorization $http_x_jm_authorization;
}
# Proxy WebSocket connections to jmwalletd
location /jmws {
proxy_pass https://jmwalletd:28283;
proxy_http_version 1.1;
proxy_set_header Authorization $http_x_jm_authorization;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_ssl_verify off;
}
# Proxy Orderbook calls to obwatch
location /obwatch/ {
proxy_pass http://obwatch:62601/;
proxy_set_header Authorization $http_x_jm_authorization;
}
}
}
2. Build Joinmarket using its own Dockerfile and run jmwalletd
and obwatch
under Docker Compose
jmwalletd:
image: joinmarket
container_name: jmwalletd
command: >
bash -c "python3 scripts/jmwalletd.py"
volumes:
- /Some_Place_On_Host:/root/.joinmarket
expose:
- "28183"
- "28283"
networks:
- jam_net
obwatch:
image: joinmarket
container_name: obwatch
command: >
bash -c "python3 scripts/obwatch/ob-watcher.py --host=0.0.0.0"
volumes:
- /Some_Place_On_Host:/root/.joinmarket
expose:
- "62601"
networks:
- jam_net
jam:
image: jam
container_name: jam
restart: always
ports:
- "31313:80"
volumes:
- jam_data:/jam
networks:
- jam_net
This way I managed to get it working running everything under Docker exposing only Jam to the host machine, but I am wondering if there was an easier way to get this working. If not, I believe it would be a good idea to have this example on the docs for the people who want to build both Joinmarket and Jam from source and run them under Docker.