Skip to content

Commit 8c13c6f

Browse files
committed
feat: Add Dockerfile
1 parent 1892691 commit 8c13c6f

2 files changed

Lines changed: 108 additions & 0 deletions

File tree

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: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,41 @@ Ensure you have "killall" installed on your system (*psmisc* package on Debian-l
106106

107107
If the node and Gateway are on different systems, you may need to utilize the "NOTIFY" endpoint on the Gateway's dashboard/API instead.
108108

109+
## Docker
110+
111+
The DATUM Gateway is also available as a Docker image.
112+
113+
114+
### Building the Docker Image
115+
116+
To build the DATUM Gateway Docker image:
117+
118+
```bash
119+
# From the root of the repository
120+
docker build -t datum_gateway .
121+
```
122+
123+
### Running the Container
124+
125+
To run the DATUM Gateway container:
126+
127+
```bash
128+
# Run with default configuration
129+
docker run -p 23334:23334 -p 7152:7152 --name datum-gateway datum_gateway
130+
```
131+
132+
The container expects a configuration file at `/app/config/config.json`. Mount a volume to this path to use your own configuration:
133+
134+
```bash
135+
docker run -v /path/to/your/config/directory:/app/config datum_gateway
136+
```
137+
138+
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:
139+
140+
```bash
141+
blocknotify=wget -q -O /dev/null http://datum-gateway:7152/NOTIFY
142+
```
143+
109144
## Template/Share Requirements for Pooled Mining
110145

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

0 commit comments

Comments
 (0)