Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,59 @@ jobs:
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-container:
name: Build and Push Container Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Determine version
id: version
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
else
echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
fi

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=raw,value=${{ steps.version.outputs.version }}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}

- name: Build and push image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_TIME=${{ github.event.head_commit.timestamp || github.event.repository.pushed_at || github.run_started_at }}
BUILD_VERSION=${{ steps.version.outputs.version }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ bitcoin-node/
documentation/reference-miners/
documentation/sv2-apps
documentation/sv2-spec
vendor/

41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# syntax=docker/dockerfile:1

FROM golang:1.26.1-bookworm AS builder

WORKDIR /src

# Install ZeroMQ build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
libzmq3-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

COPY go.mod go.sum ./
RUN go mod download

COPY . .

ARG BUILD_TIME=unknown
ARG BUILD_VERSION=v0.0.0-dev

RUN CGO_ENABLED=1 go build \
-trimpath \
-ldflags="-s -w -X main.buildTime=${BUILD_TIME} -X main.buildVersion=${BUILD_VERSION}" \
-o /out/goPool .

FROM debian:bookworm-slim

WORKDIR /app

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libzmq5 \
&& rm -rf /var/lib/apt/lists/*

COPY --from=builder /out/goPool /app/goPool
COPY data /app/data
COPY documentation /app/documentation

EXPOSE 3333 80 443

ENTRYPOINT ["/app/goPool"]
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ Stratum notes:
<img src="Screenshot_20260215_055225.png" alt="goPool status dashboard" width="720">
</p>


## Quick start

1. Install Go 1.26 or later and ZeroMQ (`libzmq3-dev` or equivalent depending on your platform).
2. Clone the repo and build the pool.
2. Clone the repo and build the pool:
```bash
git clone https://github.com/Distortions81/M45-Core-goPool.git
cd M45-Core-goPool
Expand All @@ -86,6 +87,38 @@ Stratum notes:
3. Run `./goPool` once to generate example config files under `data/config/examples/`, then copy the base example into `data/config/config.toml` and edit it.
4. Set the required `node.payout_address`, `node.rpc_url`, and ZMQ addresses (`node.zmq_hashblock_addr`/`node.zmq_rawblock_addr`; leave empty to run RPC/longpoll-only) before restarting the pool.

## Containerization (Docker/Compose)

You can run goPool using Docker or Docker Compose for easy deployment and reproducibility.

### Build and run with Docker

```bash
docker build -t gopool:local .
docker run --rm -it \
-e BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-e BUILD_VERSION="v0.0.0-dev" \
-p 3333:3333 -p 80:80 -p 443:443 \
-v "$PWD/data:/app/data" \
gopool:local -stdout
```

### Using Docker Compose

Edit `.env` or `env.example` to set environment variables as needed. Then:

```bash
# Build and start in background
make up

# View logs
make logs

# Stop and remove containers
make down
```


## Codebase size

- **Go source (excluding tests):** 35,438 lines across 147 non-test `.go` files.
Expand Down
27 changes: 27 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
version: "3.8"
services:
gopool:
build:
context: .
dockerfile: Dockerfile
args:
BUILD_TIME: "${BUILD_TIME}"
BUILD_VERSION: "${BUILD_VERSION}"
image: gopool:local
container_name: gopool
restart: unless-stopped
network_mode: "${NETWORK_MODE:-bridge}"
ports:
- "${PORT_STRATUM:-3333}:3333"
- "${PORT_STRATUM_SSL:-3334}:3334"
- "${PORT_HTTP:-80}:80"
- "${PORT_HTTPS:-443}:443"
volumes:
- ./data:/app/data
command: ["/app/goPool", "-stdout", "-pool-log=/dev/null"]
healthcheck:
test: ["CMD-SHELL", "timeout 3 bash -c '</dev/tcp/127.0.0.1/3333' || exit 1"]
interval: 30s
timeout: 5s
retries: 5
start_period: 20s
5 changes: 4 additions & 1 deletion documentation/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Documentation Index

Start with [README.md](../README.md) for quick setup and feature overview, then use these docs for deeper operations:

Start with [README.md](../README.md) for quick setup and feature overview, including Docker/Compose containerization instructions. See below for deeper operations:

- `operations.md` - Build/run procedures, config files, runtime flags, listeners/TLS, backups, signals, and operational guidance.
- `json-apis.md` - Public and authenticated `/api/*` endpoint reference (methods, response fields, auth expectations, caching headers).
- `stratum-v1.md` - Stratum v1 method compatibility and behavior notes (supported, compatibility-acknowledged, and not implemented).
- `version-bits.md` - `version_bits.toml` format, precedence, and known bit usage in goPool.
- `TESTING.md` - Unit/compat/fuzz/benchmark workflows, profiling commands, and coverage commands.
- `systemd.service` - Example service unit for long-running deployments.

- **Containerization**: See the [Containerization section in the main README](../README.md#containerization-dockercompose) for Docker and Compose usage, environment variables, and persistent data setup.
45 changes: 44 additions & 1 deletion documentation/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,50 @@ Operational Stratum notes:
- A background heartbeat (`stratumHeartbeatInterval`) performs periodic non-longpoll template refreshes so "quiet mempool / no template churn" does not look like a dead node.
- When updates are degraded but basic node RPC calls still work, the node-unavailable page will also show common sync/indexing indicators (IBD flag and blocks/headers) to help diagnose "node indexing" situations.

## Building

## Containerization (Docker/Compose)

goPool provides a Dockerfile and docker-compose.yml for containerized deployments. This is the recommended way to run in production or for easy local testing.

### Building and running with Docker

Build the image:

```bash
docker build -t gopool:local .
```

Run the container:

```bash
docker run --rm -it \
-e BUILD_TIME="$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-e BUILD_VERSION="v0.0.0-dev" \
-p 3333:3333 -p 80:80 -p 443:443 \
-v "$PWD/data:/app/data" \
gopool:local -stdout
```

### Using Docker Compose

+Edit `.env` or `env.example` to set environment variables (ports, build args, runtime flags). Then:

```bash
docker compose up -d --build
```

This will build and start the container, mapping ports and mounting `./data` for persistent config/state.

### Build arguments and environment variables

- `BUILD_TIME` and `BUILD_VERSION` are passed at build time (set automatically by the Makefile and CI).
- Runtime environment variables (see `env.example`) control ports, network mode, and extra flags.

### Persistent data

The `data` directory is mounted into the container at `/app/data` to persist configuration, logs, and state. Always back up this directory.

---

Requirements:
* **Go 1.26.0+** — install from https://go.dev/dl/ for matching ABI guarantees.
Expand Down
19 changes: 19 additions & 0 deletions env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Build metadata (set automatically by CI or manually)
BUILD_VERSION=v0.0.0-dev
BUILD_TIME=

# Ports (used for Docker/Compose port mapping)
PORT_STRATUM=3333
PORT_STRATUM_SSL=4333
PORT_HTTP=80
PORT_HTTPS=443

# Runtime flags (passed to goPool)
GOPOOL_ARGS=-stdout -pool-log=/dev/null

# Docker Compose network mode ("bridge" or "host")
NETWORK_MODE=bridge

# Example for additional environment variables:
# - Set these in your .env file or export before running Compose/Make
# - All variables are optional unless required by your config
Loading