From 7e0bfe14790a8545bbdb14236cb57189ece9448c Mon Sep 17 00:00:00 2001 From: pool2win <78231905+pool2win@users.noreply.github.com> Date: Thu, 30 Oct 2025 11:49:03 +0100 Subject: [PATCH 1/9] Optimise Dockerfile; tighten docker-compose --- .dockerignore | 1 + docker/Dockerfile.hydrapool | 79 ++++++++++++------ docker/README.md | 157 ++++++++++++++++++++++++++++++++++++ docker/cli.sh | 10 +++ docker/config-example.toml | 76 +++++++++++++++++ docker/docker-compose.yml | 53 +++++++++--- 6 files changed, 341 insertions(+), 35 deletions(-) create mode 100644 docker/README.md create mode 100755 docker/cli.sh create mode 100644 docker/config-example.toml diff --git a/.dockerignore b/.dockerignore index 819f96d..7c3c9ee 100644 --- a/.dockerignore +++ b/.dockerignore @@ -8,3 +8,4 @@ **/.env* **/*.md ansible +docker/config.toml \ No newline at end of file diff --git a/docker/Dockerfile.hydrapool b/docker/Dockerfile.hydrapool index 1600bec..4fc3f6a 100644 --- a/docker/Dockerfile.hydrapool +++ b/docker/Dockerfile.hydrapool @@ -1,5 +1,5 @@ -# Build stage -FROM rust:1.88-slim-bullseye +# Stage 1: Builder +FROM rust:1.88-slim-bullseye AS builder # Install required build dependencies RUN apt-get update && apt-get install -y \ @@ -17,30 +17,63 @@ RUN apt-get update && apt-get install -y \ libssl-dev \ && rm -rf /var/lib/apt/lists/* -# Build and install RocksDB -RUN git clone --depth 1 --branch v7.10.2 https://github.com/facebook/rocksdb.git && \ - cd rocksdb && \ - PORTABLE=1 make -j$(nproc) shared_lib && \ - cp librocksdb.so* /usr/lib/ && \ - cp -r include/rocksdb /usr/include/ && \ - cd .. && \ - rm -rf rocksdb - # Create and set working directory -RUN mkdir -p /hydrapool -COPY src/ /hydrapool/src -COPY Cargo.lock /hydrapool/Cargo.lock -COPY Cargo.toml /hydrapool/Cargo.toml - -ENV RUST_LOG=info - WORKDIR /hydrapool -# Build hydrapool and hydrapool_cli +# Copy source files +COPY src/ ./src/ +COPY Cargo.lock Cargo.toml ./ + +# Build hydrapool and hydrapool_cli in release mode RUN cargo build --release -# Copy config after building - for quick config changes -COPY config.toml /hydrapool/config.toml +# Stage 2: Runtime +FROM debian:bullseye-slim + +# Install only runtime dependencies +RUN apt-get update && apt-get install -y \ + libzmq5 \ + libssl1.1 \ + libzstd1 \ + libsnappy1v5 \ + libbz2-1.0 \ + liblz4-1 \ + ca-certificates \ + curl \ + && rm -rf /var/lib/apt/lists/* + +# Create hydrapool user and group +RUN groupadd --system hydrapool && \ + useradd --system --gid hydrapool --home-dir /var/lib/hydrapool \ + --no-create-home --shell /usr/sbin/nologin hydrapool + +# Create necessary directories +RUN mkdir -p /var/lib/hydrapool /var/log/hydrapool /etc/hydrapool && \ + chown -R hydrapool:hydrapool /var/lib/hydrapool /var/log/hydrapool + +# Copy binaries from builder stage +COPY --from=builder /hydrapool/target/release/hydrapool /usr/local/bin/ +COPY --from=builder /hydrapool/target/release/hydrapool_cli /usr/local/bin/ + +# Copy default config +COPY config.toml /etc/hydrapool/config.toml + +# Set permissions +RUN chmod +x /usr/local/bin/hydrapool /usr/local/bin/hydrapool_cli && \ + chown hydrapool:hydrapool /etc/hydrapool/config.toml + +# Switch to non-root user +USER hydrapool + +# Set working directory +WORKDIR /var/lib/hydrapool + +# Expose API port (adjust based on your config) +EXPOSE 46884 + +# Set environment +ENV RUST_LOG=info -ENTRYPOINT [ ] -CMD [] +# Run hydrapool +ENTRYPOINT ["/usr/local/bin/hydrapool"] +CMD ["--config", "/etc/hydrapool/config.toml"] diff --git a/docker/README.md b/docker/README.md new file mode 100644 index 0000000..79a2baf --- /dev/null +++ b/docker/README.md @@ -0,0 +1,157 @@ +# Running Hydrapool with Docker + +This guide shows how to run Hydrapool using Docker and Docker Compose. + +## Quick Start + +### 1. Copy and edit the configuration file + +```bash +cd docker +cp config-example.toml config.toml +``` + +Edit `config.toml` and configure: +- **`bootstrap_address`** - Your Bitcoin address for bootstrap mining. Default to 256 Foundation's donation address. +- **`zmqpubhashblock`** - Your Bitcoin node's ZMQ endpoint (e.g., `tcp://host.docker.internal:28334`) +- **`bitcoinrpc.url`** - Your Bitcoin RPC URL (e.g., `http://host.docker.internal:38332`) +- **`bitcoinrpc.username`** and **`bitcoinrpc.password`** - Your Bitcoin RPC credentials +- **`network`** - Set to `main`, `testnet4`, or `signet` + +### 2. Start Hydrapool + +Run Hydrapool only: +```bash +docker compose up -d hydrapool +``` + +Or run with monitoring dashboards (Prometheus + Grafana): +```bash +docker compose up -d +``` + +### 3. Check status + +```bash +docker compose logs -f hydrapool +docker compose ps +``` + +### 4. Access services + +- **Stratum mining:** `stratum+tcp://localhost:3333` +- **API server:** `http://localhost:46884` +- **Grafana dashboard:** `http://localhost:3000` (if running with dashboards) +- **Prometheus:** `http://localhost:9090` (if running with dashboards) + +## Updating Configuration + +After editing `config.toml`, restart Hydrapool: + +```bash +docker compose restart hydrapool +``` + +## Stopping Hydrapool + +```bash +# Stop all services +docker compose down + +# Stop and remove volumes (WARNING: deletes all data) +docker compose down -v +``` + +## Using CLI Tools + +Easy to run shell script from the docker directory, i.e. this directory + +```bash +./cli.sh --help +``` + +Or, if you want to directly run using docker compose: + +```bash +docker compose run --rm hydrapool-cli --help +docker compose run --rm hydrapool-cli gen-auth myuser mypassword +``` + +## Data Persistence + +Data is stored in Docker volumes: +- **hydrapool_data:** Database and stats +- **hydrapool_logs:** Log files +- **prometheus_data:** Prometheus metrics +- **grafana_data:** Grafana dashboards + +To backup data: +```bash +docker run --rm -v hydrapool_data:/data -v $(pwd):/backup alpine tar czf /backup/hydrapool-backup.tar.gz /data +``` + +## Building from Source + +To rebuild the Docker image after code changes: + +```bash +docker compose build hydrapool +docker compose up -d hydrapool +``` + +## Troubleshooting + +### Cannot connect to Bitcoin node + +If Hydrapool can't connect to your Bitcoin node running on the host: + +1. Make sure your Bitcoin node is configured to accept RPC connections +2. Use `host.docker.internal` in URLs instead of `localhost` or `127.0.0.1` +3. Check that ZMQ is enabled in your `bitcoin.conf`: + ``` + zmqpubhashblock=tcp://0.0.0.0:28334 + ``` + +### View logs + +```bash +# Follow logs +docker compose logs -f hydrapool + +# Last 100 lines +docker compose logs --tail=100 hydrapool +``` + +### Container won't start + +Check the configuration file is valid: +```bash +docker compose config +``` + +## Advanced Usage + +### Using Pre-built Images + +Instead of building locally, use pre-built images from Docker Hub (when available): + +```yaml +services: + hydrapool: + image: hydrapool/hydrapool:latest + # ... rest of config +``` + +### Custom Network + +To use a custom Docker network: + +```bash +docker network create my-network +``` + +Then update `docker-compose.yml` to use the external network. + +## Support + +For more information, see the main [Hydrapool README](../README.md) or visit [hydrapool.org](https://hydrapool.org). diff --git a/docker/cli.sh b/docker/cli.sh new file mode 100755 index 0000000..ac795e1 --- /dev/null +++ b/docker/cli.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# Wrapper script to run hydrapool_cli commands +# Usage: ./cli.sh [args...] +# Examples: +# ./cli.sh info +# ./cli.sh gen-auth myuser mypassword +# ./cli.sh --help + +cd "$(dirname "$0")" +docker compose run --rm hydrapool-cli "$@" diff --git a/docker/config-example.toml b/docker/config-example.toml new file mode 100644 index 0000000..2953f75 --- /dev/null +++ b/docker/config-example.toml @@ -0,0 +1,76 @@ +# Hydrapool Docker Configuration Example +# Copy this file to config.toml and edit for your setup: +# cp config-example.toml config.toml + +[store] +# Database path - leave as-is for Docker +path = "/var/lib/hydrapool/store.db" +background_task_frequency_hours = 24 +pplns_ttl_days = 7 + +[stratum] +hostname = "0.0.0.0" +port = 3333 +start_difficulty = 1 +minimum_difficulty = 1 + +# REQUIRED: Change this to YOUR Bitcoin address. Default is 256 +# Foundation donation address. +# +# This address receives payouts if a block is found in the first 10 +# seconds +bootstrap_address = "bc1qypskemx80lznv4tjpnmpw9c5pgpy32fpkk3sw2" + +# Optional: Donation to developers (in basis points, 100 = 1%) +# donation_address = "" +# donation = 50 + +# Optional: Pool operator fee (in basis points, 100 = 1%) +# fee_address = "" +# fee = 200 + +# REQUIRED: Change to match your Bitcoin node's ZMQ endpoint +# For Docker: use "tcp://host.docker.internal:28334" to connect to host +# For local Bitcoin node running on host machine +zmqpubhashblock = "tcp://host.docker.internal:28334" + +# REQUIRED: Set your network ("main", "testnet4", or "signet") +network = "signet" + +version_mask = "1fffe000" + +# Difficulty multiplier for PPLNS window calculation +# See: https://github.com/p2poolv2/p2poolv2/wiki/Difficult-Multiplier +difficulty_multiplier = 1.0 + +# Optional: Pool signature (max 16 bytes) +# Comment out for anonymous mining or replace/append your identifier. +pool_signature = "hydrapool" + +[bitcoinrpc] +# REQUIRED: Bitcoin RPC connection +# For Docker: use "http://host.docker.internal:38332" to connect to host +url = "http://host.docker.internal:38332" +username = "hydrapool" +password = "hydrapool" + +[logging] +# Log file path - leave as-is for Docker +# file = "/var/log/hydrapool/hydrapool.log" +level = "info" +# Stats backup directory - leave as-is for Docker +stats_dir = "/var/lib/hydrapool/stats" + +[api] +hostname = "0.0.0.0" +port = 46884 + +# API authentication - CHANGE THIS! +# Generate new credentials with: hydrapool_cli gen-auth +# With docker - `cd docker; ./cli.sh gen-auth ` +# When you change this change the following: +# 1. docker-compose.yml to update the username/password for hydrapool healthcheck +# 2. prometheus.yml to update auth +auth_user = "hydrapool" +auth_token = "28a556ceb0b24c9b664d1e35a81239ed$5c9fb3271b22be05eb87272ce11c3cad55242d045eb379873ce0dc821586204a" + diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5355834..530ec16 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,21 +1,27 @@ services: hydrapool: - profiles: [hydrapool] build: context: .. dockerfile: docker/Dockerfile.hydrapool environment: - - HYDRAPOOL_BITCOIN_NETWORK=${NETWORK:-signet} - - HYDRAPOOL_BITCOIN_URL=bitcoind:${BTC_RPC_PORT:-38332} - - HYDRAPOOL_STORE_PATH=/data/${NETWORK:-signet} - RUST_LOG=info - command: /hydrapool/target/release/hydrapool --config=/hydrapool/config.toml + # Config is mounted from local file - edit docker/config.toml to customize volumes: - - hydrapool_data:/data + - ./config.toml:/etc/hydrapool/config.toml:ro + - hydrapool_data:/var/lib/hydrapool + - hydrapool_logs:/var/log/hydrapool restart: unless-stopped ports: - - "3333:3333" - - "46884:46884" # API server port + - "3333:3333" # Stratum mining port + - "46884:46884" # API server port + extra_hosts: + - "host.docker.internal:host-gateway" + healthcheck: + test: ["CMD", "curl", "-f", "--user", "hydrapool:hydrapool", "http://localhost:46884/health"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s networks: - hydrapool_network logging: @@ -23,9 +29,24 @@ services: options: max-size: "100m" max-file: "3" - + + hydrapool-cli: + build: + context: .. + dockerfile: docker/Dockerfile.hydrapool + profiles: [cli] # Prevents auto-start with docker compose up + entrypoint: ["/usr/local/bin/hydrapool_cli", "--config", "/etc/hydrapool/config.toml"] + volumes: + - ./config.toml:/etc/hydrapool/config.toml:ro + - hydrapool_data:/var/lib/hydrapool + networks: + - hydrapool_network + prometheus: - image: prom/prometheus:latest + image: prom/prometheus:v3.6.0 + depends_on: + hydrapool: + condition: service_healthy volumes: - ../prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus_data:/prometheus @@ -38,6 +59,12 @@ services: - '--web.console.templates=/usr/share/prometheus/consoles' extra_hosts: - "host.docker.internal:host-gateway" + healthcheck: + test: ["CMD", "curl", "-f", "http://localhost:9090/-/healthy"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 10s restart: unless-stopped logging: driver: "json-file" @@ -46,9 +73,10 @@ services: max-file: "3" grafana: - image: grafana/grafana:latest + image: grafana/grafana:12.2.0 depends_on: - - prometheus + prometheus: + condition: service_healthy volumes: - grafana_data:/var/lib/grafana - ../prometheus/grafana/provisioning:/etc/grafana/provisioning:ro @@ -73,6 +101,7 @@ volumes: prometheus_data: grafana_data: hydrapool_data: + hydrapool_logs: networks: hydrapool_network: From d62d229787c063667928778e2f7ae7176a377e22 Mon Sep 17 00:00:00 2001 From: pool2win <78231905+pool2win@users.noreply.github.com> Date: Thu, 30 Oct 2025 15:12:29 +0100 Subject: [PATCH 2/9] Add custom docker images for prom and grafana Use healthchecks and depdencies Use env file for grafana admin user config --- .gitignore | 1 + docker/.env.example | 11 +++++++++ docker/Dockerfile.grafana | 11 +++++++++ docker/Dockerfile.hydrapool | 2 +- docker/Dockerfile.prometheus | 6 +++++ docker/README.md | 24 +++++++++++++++---- docker/docker-compose.yml | 21 ++++++++-------- .../provisioning/dashboards/dashboards.yml | 2 +- 8 files changed, 62 insertions(+), 16 deletions(-) create mode 100644 docker/.env.example create mode 100644 docker/Dockerfile.grafana create mode 100644 docker/Dockerfile.prometheus diff --git a/.gitignore b/.gitignore index 9d17c6a..7c1cdb8 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ store*.db p2pool.log .env +docker/.env logs/* \ No newline at end of file diff --git a/docker/.env.example b/docker/.env.example new file mode 100644 index 0000000..e3aa624 --- /dev/null +++ b/docker/.env.example @@ -0,0 +1,11 @@ +# Hydrapool Docker Environment Configuration +# Copy this file to .env and customize as needed: +# cp .env.example .env + +# Grafana Admin Credentials +# IMPORTANT: Change these for production deployments! +GRAFANA_ADMIN_USER=admin +GRAFANA_ADMIN_PASSWORD=admin + +# To change any other configs, copy config-example.toml to config.toml +# and provide options there. \ No newline at end of file diff --git a/docker/Dockerfile.grafana b/docker/Dockerfile.grafana new file mode 100644 index 0000000..8ccc46c --- /dev/null +++ b/docker/Dockerfile.grafana @@ -0,0 +1,11 @@ +FROM grafana/grafana:12.2.0 + +# Copy provisioning configurations +COPY ./prometheus/grafana/provisioning/datasources/prometheus.yml /etc/grafana/provisioning/datasources/prometheus.yml +COPY ./prometheus/grafana/provisioning/dashboards/dashboards.yml /etc/grafana/provisioning/dashboards/dashboards.yml + +# Copy dashboard JSON files +COPY ./prometheus/grafana/dashboards/ /etc/grafana/dashboards/ + + +# The base image already sets the correct user, entrypoint and command diff --git a/docker/Dockerfile.hydrapool b/docker/Dockerfile.hydrapool index 4fc3f6a..5a31ff3 100644 --- a/docker/Dockerfile.hydrapool +++ b/docker/Dockerfile.hydrapool @@ -39,7 +39,7 @@ RUN apt-get update && apt-get install -y \ libbz2-1.0 \ liblz4-1 \ ca-certificates \ - curl \ + wget \ && rm -rf /var/lib/apt/lists/* # Create hydrapool user and group diff --git a/docker/Dockerfile.prometheus b/docker/Dockerfile.prometheus new file mode 100644 index 0000000..fa5d55b --- /dev/null +++ b/docker/Dockerfile.prometheus @@ -0,0 +1,6 @@ +FROM prom/prometheus:v3.6.0 + +# Copy custom prometheus configuration +COPY ./prometheus/prometheus.yml /etc/prometheus/prometheus.yml + +# The base image already sets the correct entrypoint and command diff --git a/docker/README.md b/docker/README.md index 79a2baf..dc4e599 100644 --- a/docker/README.md +++ b/docker/README.md @@ -18,7 +18,23 @@ Edit `config.toml` and configure: - **`bitcoinrpc.username`** and **`bitcoinrpc.password`** - Your Bitcoin RPC credentials - **`network`** - Set to `main`, `testnet4`, or `signet` -### 2. Start Hydrapool +### 2. (Optional) Customize Grafana credentials + +By default, Grafana uses `admin/admin` for username and password. To change: + +```bash +cp .env.example .env +``` + +Edit `.env` and set your desired credentials: +```bash +GRAFANA_ADMIN_USER=yourusername +GRAFANA_ADMIN_PASSWORD=yourpassword +``` + +**Note:** The `.env` file is git-ignored to prevent accidentally committing credentials. + +### 3. Start Hydrapool Run Hydrapool only: ```bash @@ -30,18 +46,18 @@ Or run with monitoring dashboards (Prometheus + Grafana): docker compose up -d ``` -### 3. Check status +### 4. Check status ```bash docker compose logs -f hydrapool docker compose ps ``` -### 4. Access services +### 5. Access services - **Stratum mining:** `stratum+tcp://localhost:3333` - **API server:** `http://localhost:46884` -- **Grafana dashboard:** `http://localhost:3000` (if running with dashboards) +- **Grafana dashboard:** `http://localhost:3000` (if running with dashboards, login with credentials from step 2) - **Prometheus:** `http://localhost:9090` (if running with dashboards) ## Updating Configuration diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 530ec16..5a8aafa 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -17,7 +17,7 @@ services: extra_hosts: - "host.docker.internal:host-gateway" healthcheck: - test: ["CMD", "curl", "-f", "--user", "hydrapool:hydrapool", "http://localhost:46884/health"] + test: ["CMD", "wget", "--spider", "-q", "--http-user=hydrapool", "--http-password=hydrapool", "--auth-no-challenge", "http://localhost:46884/health"] interval: 30s timeout: 10s retries: 3 @@ -43,12 +43,13 @@ services: - hydrapool_network prometheus: - image: prom/prometheus:v3.6.0 + build: + context: .. + dockerfile: docker/Dockerfile.prometheus depends_on: hydrapool: condition: service_healthy volumes: - - ../prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro - prometheus_data:/prometheus ports: - "9090:9090" @@ -60,7 +61,7 @@ services: extra_hosts: - "host.docker.internal:host-gateway" healthcheck: - test: ["CMD", "curl", "-f", "http://localhost:9090/-/healthy"] + test: ["CMD", "wget", "--spider", "-q", "http://localhost:9090/-/healthy"] interval: 30s timeout: 10s retries: 3 @@ -73,23 +74,23 @@ services: max-file: "3" grafana: - image: grafana/grafana:12.2.0 + build: + context: .. + dockerfile: docker/Dockerfile.grafana depends_on: prometheus: condition: service_healthy volumes: - grafana_data:/var/lib/grafana - - ../prometheus/grafana/provisioning:/etc/grafana/provisioning:ro - - ../prometheus/grafana/dashboards:/var/lib/grafana/dashboards:ro ports: - "3000:3000" environment: - - GF_SECURITY_ADMIN_PASSWORD=admin - - GF_SECURITY_ADMIN_USER=admin + - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin} + - GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin} - GF_USERS_ALLOW_SIGN_UP=false - GF_AUTH_ANONYMOUS_ENABLED=true - GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer - - GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/var/lib/grafana/dashboards/pool.json + - GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/dashboards/pool.json restart: unless-stopped logging: driver: "json-file" diff --git a/prometheus/grafana/provisioning/dashboards/dashboards.yml b/prometheus/grafana/provisioning/dashboards/dashboards.yml index 5abe28b..71b3455 100644 --- a/prometheus/grafana/provisioning/dashboards/dashboards.yml +++ b/prometheus/grafana/provisioning/dashboards/dashboards.yml @@ -9,4 +9,4 @@ providers: updateIntervalSeconds: 10 allowUiUpdates: false options: - path: /var/lib/grafana/dashboards + path: /etc/grafana/dashboards From 7475d3c32bdaee93a7e44f80dfa74c9b35906016 Mon Sep 17 00:00:00 2001 From: pool2win <78231905+pool2win@users.noreply.github.com> Date: Thu, 30 Oct 2025 19:10:22 +0100 Subject: [PATCH 3/9] Revert "Remove docker builds" This reverts commit 94fe11bcf7b426f89015693acb85a4c4b4a7891c. --- .github/workflows/docker-build.yml | 76 ++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 0000000..daea42e --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,76 @@ +name: Build and Push Docker Images + +on: + pull_request: + push: + tags: + - '**[0-9]+.[0-9]+.[0-9]+*' + +env: + REGISTRY: ghcr.io + ORGANIZATION: 256-foundation + +jobs: + build: + name: Build Docker Images + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + strategy: + matrix: + component: [hydrapool, grafana, prometheus] + include: + - component: hydrapool + dockerfile: docker/Dockerfile.hydrapool + context: docker/ + - component: grafana + dockerfile: docker/Dockerfile.grafana + context: docker/ + - component: prometheus + dockerfile: docker/Dockerfile.prometheus + context: docker/ + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to GitHub Container Registry + if: github.event_name != 'pull_request' + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/hydrapool-${{ matrix.component }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha + labels: | + org.opencontainers.image.description=Hydrapool ${{ matrix.component }} image + org.opencontainers.image.vendor=${{ env.ORGANIZATION }} + org.opencontainers.image.licenses=AGPL-3.0 + org.opencontainers.image.visibility=public + + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: ${{ matrix.context }} + file: ${{ matrix.dockerfile }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max From 19ef77c554be68828a0469241c640287eb599204 Mon Sep 17 00:00:00 2001 From: pool2win <78231905+pool2win@users.noreply.github.com> Date: Thu, 30 Oct 2025 19:10:33 +0100 Subject: [PATCH 4/9] Add changelog --- CHANGELOG.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..fa068b7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,58 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- Add docker files for hydrapool, grafana and prometheus +- Add a docker compose file for easy use for end users +- + +### Changed + +- Use frontmatter title & description in each language version template +- Replace broken OpenGraph image with an appropriately-sized Keep a Changelog + image that will render properly (although in English for all languages) +- Fix OpenGraph title & description for all languages so the title and +description when links are shared are language-appropriate + +### Removed + +- Trademark sign previously shown after the project description in version +0.3.0 + +## [1.1.12] - 2025-10-29 + +### Fixed + +- Fix write permission for writing debian package from workflow + +## [1.1.11] - 2025-10-29 + +### Fixed + +- Book keeping fix for tag + +## [1.1.10] - 2025-10-29 + +### Fixed + +- Fix debian package failure to get release tag + +## [1.1.9] - 2025-10-29 + +### Added + +- Add debian package workflow using cargo-deb + +[unreleased]: https://github.com/256-foundation/Hydra-Pool/compare/v1.1.12...HEAD +[1.1.12]: https://github.com/256-foundation/Hydra-Pool/compare/v1.1.11...v1.1.12 +[1.1.11]: https://github.com/256-foundation/Hydra-Pool/compare/v1.1.10...v1.1.11 +[1.1.10]: https://github.com/256-foundation/Hydra-Pool/compare/v1.1.9...v1.1.10 +[1.1.9]: https://github.com/256-foundation/Hydra-Pool/compare/v1.1.8...v1.1.9 + From dc7f8d31538a64e2c3fc837d65eaf68548674660 Mon Sep 17 00:00:00 2001 From: pool2win <78231905+pool2win@users.noreply.github.com> Date: Thu, 30 Oct 2025 19:11:51 +0100 Subject: [PATCH 5/9] Add changelog message for docker build --- CHANGELOG.md | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa068b7..1713766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,20 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add docker files for hydrapool, grafana and prometheus - Add a docker compose file for easy use for end users -- - -### Changed - -- Use frontmatter title & description in each language version template -- Replace broken OpenGraph image with an appropriately-sized Keep a Changelog - image that will render properly (although in English for all languages) -- Fix OpenGraph title & description for all languages so the title and -description when links are shared are language-appropriate - -### Removed - -- Trademark sign previously shown after the project description in version -0.3.0 +- Add docker build work flow to build docker images on github actions ## [1.1.12] - 2025-10-29 From a2b64080677025c092acff71c74960482405da7c Mon Sep 17 00:00:00 2001 From: pool2win <78231905+pool2win@users.noreply.github.com> Date: Thu, 30 Oct 2025 21:53:57 +0100 Subject: [PATCH 6/9] Bring back publishing docker images --- .github/workflows/build-debian.yml | 3 --- .github/workflows/docker-build.yml | 17 +++++++++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-debian.yml b/.github/workflows/build-debian.yml index 3451f8e..c7a8468 100644 --- a/.github/workflows/build-debian.yml +++ b/.github/workflows/build-debian.yml @@ -6,9 +6,6 @@ on: workflow_run: workflows: ["Release"] types: [completed] - push: - branches: - - debian-package jobs: build-debian: diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index daea42e..fee7c50 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -1,10 +1,13 @@ name: Build and Push Docker Images +permissions: + "contents": "write" on: - pull_request: + release: + types: [published] push: - tags: - - '**[0-9]+.[0-9]+.[0-9]+*' + branches: + - docker-one-click env: REGISTRY: ghcr.io @@ -25,16 +28,22 @@ jobs: - component: hydrapool dockerfile: docker/Dockerfile.hydrapool context: docker/ + image_name: hydrapool - component: grafana dockerfile: docker/Dockerfile.grafana context: docker/ + image_name: hydrapool-grafana - component: prometheus dockerfile: docker/Dockerfile.prometheus context: docker/ + image_name: hydrapool-prometheus steps: - name: Checkout code uses: actions/checkout@v3 + with: + ref: ${{ github.event.release.tag_name || github.ref }} + fetch-depth: 0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -51,7 +60,7 @@ jobs: id: meta uses: docker/metadata-action@v4 with: - images: ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/hydrapool-${{ matrix.component }} + images: ${{ env.REGISTRY }}/${{ env.ORGANIZATION }}/${{ matrix.image_name }} tags: | type=ref,event=branch type=ref,event=pr From e2879ebdfee4b8f8ad6146b74d3a33dbcbd2f2b3 Mon Sep 17 00:00:00 2001 From: pool2win <78231905+pool2win@users.noreply.github.com> Date: Thu, 30 Oct 2025 21:55:01 +0100 Subject: [PATCH 7/9] Rename docker workflow --- .github/workflows/{docker-build.yml => build-docker.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{docker-build.yml => build-docker.yml} (100%) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/build-docker.yml similarity index 100% rename from .github/workflows/docker-build.yml rename to .github/workflows/build-docker.yml From 25a42fcc9d7a8c2d4086707b42b595b12979c6e2 Mon Sep 17 00:00:00 2001 From: pool2win <78231905+pool2win@users.noreply.github.com> Date: Thu, 30 Oct 2025 22:16:21 +0100 Subject: [PATCH 8/9] Remove grafana env depedency We now only need to edit config --- docker/.env.example | 11 ----------- docker/README.md | 17 ++++------------- docker/docker-compose.yml | 4 ++-- 3 files changed, 6 insertions(+), 26 deletions(-) delete mode 100644 docker/.env.example diff --git a/docker/.env.example b/docker/.env.example deleted file mode 100644 index e3aa624..0000000 --- a/docker/.env.example +++ /dev/null @@ -1,11 +0,0 @@ -# Hydrapool Docker Environment Configuration -# Copy this file to .env and customize as needed: -# cp .env.example .env - -# Grafana Admin Credentials -# IMPORTANT: Change these for production deployments! -GRAFANA_ADMIN_USER=admin -GRAFANA_ADMIN_PASSWORD=admin - -# To change any other configs, copy config-example.toml to config.toml -# and provide options there. \ No newline at end of file diff --git a/docker/README.md b/docker/README.md index dc4e599..e83d73d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -18,21 +18,12 @@ Edit `config.toml` and configure: - **`bitcoinrpc.username`** and **`bitcoinrpc.password`** - Your Bitcoin RPC credentials - **`network`** - Set to `main`, `testnet4`, or `signet` -### 2. (Optional) Customize Grafana credentials +### 2. Grafana credentials -By default, Grafana uses `admin/admin` for username and password. To change: +By default, Grafana uses `admin/admin` for username and password. -```bash -cp .env.example .env -``` - -Edit `.env` and set your desired credentials: -```bash -GRAFANA_ADMIN_USER=yourusername -GRAFANA_ADMIN_PASSWORD=yourpassword -``` - -**Note:** The `.env` file is git-ignored to prevent accidentally committing credentials. +You can and should login and change this password before exposing your +grafana instance to the public. ### 3. Start Hydrapool diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 5a8aafa..014367b 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -85,8 +85,8 @@ services: ports: - "3000:3000" environment: - - GF_SECURITY_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD:-admin} - - GF_SECURITY_ADMIN_USER=${GRAFANA_ADMIN_USER:-admin} + - GF_SECURITY_ADMIN_PASSWORD=admin + - GF_SECURITY_ADMIN_USER=admin - GF_USERS_ALLOW_SIGN_UP=false - GF_AUTH_ANONYMOUS_ENABLED=true - GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer From 0cc2582d02dc6f543442d000ef18758242543d31 Mon Sep 17 00:00:00 2001 From: pool2win <78231905+pool2win@users.noreply.github.com> Date: Thu, 30 Oct 2025 22:25:13 +0100 Subject: [PATCH 9/9] Fix context in workflow --- .github/workflows/build-docker.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index fee7c50..8d579ff 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -27,15 +27,15 @@ jobs: include: - component: hydrapool dockerfile: docker/Dockerfile.hydrapool - context: docker/ + context: . image_name: hydrapool - component: grafana dockerfile: docker/Dockerfile.grafana - context: docker/ + context: . image_name: hydrapool-grafana - component: prometheus dockerfile: docker/Dockerfile.prometheus - context: docker/ + context: . image_name: hydrapool-prometheus steps: