Skip to content

Commit b23e091

Browse files
committed
Merge remote-tracking branch 'github-pull/115/head' (feat: Add Dockerfile)
2 parents e34bd2a + 4f476dc commit b23e091

File tree

2 files changed

+191
-0
lines changed

2 files changed

+191
-0
lines changed

Dockerfile

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
FROM debian:bookworm-slim AS builder
2+
3+
# Install dependencies for building
4+
RUN apt-get update && apt-get install -y \
5+
build-essential \
6+
cmake \
7+
gcc \
8+
pkg-config \
9+
libjansson-dev \
10+
libmicrohttpd-dev \
11+
libsodium-dev \
12+
libcurl4-openssl-dev \
13+
git \
14+
--no-install-recommends \
15+
&& apt-get clean \
16+
&& rm -rf /var/lib/apt/lists/*
17+
18+
WORKDIR /build
19+
20+
# Copy entire repository for git information
21+
COPY . .
22+
23+
# Build the application with optimization flags
24+
RUN cmake -DCMAKE_BUILD_TYPE=Release . && make -j$(nproc)
25+
26+
# Use the same Debian version for runtime to ensure library compatibility
27+
FROM debian:bookworm-slim AS runtime
28+
29+
# Install only runtime dependencies
30+
RUN apt-get update && apt-get install -y \
31+
libjansson4 \
32+
libmicrohttpd12 \
33+
libsodium23 \
34+
libcurl4 \
35+
netcat-traditional \
36+
--no-install-recommends \
37+
&& apt-get clean \
38+
&& rm -rf /var/lib/apt/lists/* \
39+
&& rm -rf /usr/share/doc /usr/share/man \
40+
&& find /var/cache -type f -delete
41+
42+
WORKDIR /app
43+
44+
# Copy only the built binary and necessary files from builder
45+
COPY --from=builder /build/datum_gateway /app/
46+
COPY --from=builder /build/www/ /app/www/
47+
COPY --from=builder /build/doc/example_datum_gateway_config.json /app/config/config.json
48+
49+
# Create a configuration directory if it doesn't exist
50+
RUN mkdir -p /app/config
51+
52+
# Verify shared library dependencies
53+
RUN ldd /app/datum_gateway
54+
55+
# Create a non-root user
56+
RUN useradd -r -s /bin/false datumuser && \
57+
chown -R datumuser:datumuser /app
58+
59+
# Change to non-root user
60+
USER datumuser
61+
62+
# Set up healthcheck
63+
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
64+
CMD nc -zv localhost 23334 || exit 1
65+
66+
# Expose ports
67+
EXPOSE 23334/tcp 7152/tcp
68+
69+
# Create a volume for configuration and data
70+
VOLUME ["/app/config"]
71+
72+
# Set the entrypoint
73+
ENTRYPOINT ["/app/datum_gateway", "--config", "/app/config/config.json"]

README.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,124 @@ Note that the API/web admin password is also used for preventing CSRF attacks, s
140140
You should review the [documentation on usernames](doc/usernames.md) next.
141141
Once you have everything running, you can point miners at the Gateway.
142142

143+
## Docker
144+
145+
The DATUM Gateway is also available as a Docker image.
146+
147+
148+
### Building the Docker Image
149+
150+
To build the DATUM Gateway Docker image:
151+
152+
```bash
153+
# From the root of the repository
154+
docker build -t datum_gateway .
155+
```
156+
157+
### Running the Container
158+
159+
To run the DATUM Gateway container:
160+
161+
```bash
162+
# Run with default configuration
163+
docker run -p 23334:23334 -p 7152:7152 --name datum-gateway datum_gateway
164+
```
165+
166+
The container expects a configuration file at `/app/config/config.json`. Mount a volume to this path to use your own configuration:
167+
168+
```bash
169+
docker run -v /path/to/your/config/directory:/app/config -p 23334:23334 -p 7152:7152 datum_gateway
170+
```
171+
172+
You will need to disable the notify fallback in your configuration file if you are using Docker. And in bitcoin.conf, you will need to set the following:
173+
174+
```bash
175+
blocknotify=wget -q -O /dev/null http://datum-gateway:7152/NOTIFY
176+
```
177+
178+
### Connecting to a Bitcoin Node
179+
180+
When running the DATUM Gateway in Docker, you need to configure it to connect to your Bitcoin node. The connection method depends on where your Bitcoin node is running:
181+
182+
#### 1. Bitcoin Node Running in Docker (Same Network)
183+
184+
If your Bitcoin node is also running in a Docker container on the same network, use the container name as the hostname:
185+
186+
```json
187+
{
188+
"rpc_host": "bitcoin-node",
189+
"rpc_port": 8332,
190+
"rpc_user": "your_rpc_user",
191+
"rpc_pass": "your_rpc_password"
192+
}
193+
```
194+
195+
In your `bitcoin.conf`, set the blocknotify to use the DATUM Gateway container name:
196+
197+
```
198+
blocknotify=wget -q -O /dev/null http://datum-gateway:7152/NOTIFY
199+
```
200+
201+
#### 2. Bitcoin Node Running on Host System
202+
203+
If your Bitcoin node is running directly on the host system or in a container that binds to host ports, you have two options:
204+
205+
**Option A: Using host.docker.internal (recommended)**
206+
```json
207+
{
208+
"rpc_host": "host.docker.internal",
209+
"rpc_port": 8332,
210+
"rpc_user": "your_rpc_user",
211+
"rpc_pass": "your_rpc_password"
212+
}
213+
```
214+
215+
**Option B: Using host networking mode**
216+
Run the DATUM Gateway container with `--network host`:
217+
218+
```bash
219+
docker run --network host -v /path/to/config:/app/config datum_gateway
220+
```
221+
222+
Then configure using localhost:
223+
```json
224+
{
225+
"rpc_host": "localhost",
226+
"rpc_port": 8332,
227+
"rpc_user": "your_rpc_user",
228+
"rpc_pass": "your_rpc_password"
229+
}
230+
```
231+
232+
For blocknotify in `bitcoin.conf` when using host networking:
233+
```
234+
blocknotify=wget -q -O /dev/null http://localhost:7152/NOTIFY
235+
```
236+
237+
#### 3. Bitcoin Node on Remote System
238+
239+
If your Bitcoin node is running on a different machine, use the hostname or IP address:
240+
241+
```json
242+
{
243+
"rpc_host": "192.168.1.100",
244+
"rpc_port": 8332,
245+
"rpc_user": "your_rpc_user",
246+
"rpc_pass": "your_rpc_password"
247+
}
248+
```
249+
250+
In your remote Bitcoin node's `bitcoin.conf`:
251+
```
252+
blocknotify=wget -q -O /dev/null http://datum-gateway-host-ip:7152/NOTIFY
253+
```
254+
255+
**Important Notes:**
256+
- Ensure your Bitcoin node's RPC is configured to accept connections from the DATUM Gateway
257+
- For remote connections, you may need to configure `rpcbind` and `rpcallowip` in your `bitcoin.conf`
258+
- Always use strong RPC credentials and consider network security when exposing RPC endpoints
259+
- Remember to disable the notify fallback in your DATUM Gateway configuration when using Docker
260+
143261
## Template/Share Requirements for Pooled Mining
144262

145263
- Must be a valid block and conform to current Bitcoin consensus rules

0 commit comments

Comments
 (0)