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
80 changes: 80 additions & 0 deletions .github/workflows/build-debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build Debian Package

on:
workflow_run:
workflows: ["Release"]
types: [completed]
push:
branches:
- debian-package

jobs:
build-debian:
name: Build Debian Package
runs-on: ubuntu-22.04
# Only run if Release succeeded (when triggered by workflow_run) or on manual triggers
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
dpkg-dev

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.88.0

- name: Install cargo-deb
run: |
if ! command -v cargo-deb &> /dev/null; then
cargo install cargo-deb
fi

- name: Build release binaries
run: cargo build --release

- name: Build Debian package
run: cargo deb

- name: Get package version
id: version
run: |
VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "deb_file=hydrapool_${VERSION}_amd64.deb" >> $GITHUB_OUTPUT

- name: List generated files
run: |
ls -lh target/debian/

- name: Upload Debian package as artifact
uses: actions/upload-artifact@v4
with:
name: debian-package
path: target/debian/*.deb
if-no-files-found: error

- name: Attach to GitHub Release
if: github.event_name == 'workflow_run'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Get the tag from the workflow run that triggered this
TAG_NAME=$(git describe --tags --exact-match ${{ github.event.workflow_run.head_sha }} 2>/dev/null || echo "")

if [ -z "$TAG_NAME" ]; then
echo "No tag found for this release, skipping upload"
exit 0
fi

echo "Attaching Debian package to release: $TAG_NAME"
gh release upload "$TAG_NAME" target/debian/*.deb --clobber
echo "Debian package uploaded successfully to release $TAG_NAME"
23 changes: 23 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,26 @@ bench = false
name = "hydrapool_cli"
test = false
bench = false

[package.metadata.deb]
maintainer = "Kulpreet Singh <kp@opdup.com>"
copyright = "2024, Kulpreet Singh <kp@opdup.com>"
license-file = ["LICENSE", "4"]
extended-description = """\
Hydrapool is an open source Bitcoin mining pool with support for solo mining \
and PPLNS (Pay Per Last N Shares) accounting. Features include:\n\
- Run a private solo pool or PPLNS pool\n\
- Payouts made directly from coinbase (no custody)\n\
- API for downloading and validating share accounting\n\
- Compatible with any bitcoin RPC node"""
depends = "$auto, systemd"
section = "net"
priority = "optional"
assets = [
["target/release/hydrapool", "usr/bin/", "755"],
["target/release/hydrapool_cli", "usr/bin/", "755"],
["config.toml", "etc/hydrapool/config.toml", "644"],
]
conf-files = ["/etc/hydrapool/config.toml"]
maintainer-scripts = "packages/debian/"
systemd-units = { enable = false }
8 changes: 3 additions & 5 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ hostname = "0.0.0.0"
port = 3333
start_difficulty = 1
minimum_difficulty = 1
# The bitcoin address to use for first jobs when there are no shares
bootstrap_address = "<your bootstrap address here>"
# The bitcoin address to use for first jobs when there are no
# shares. The default provided is the 256 Foundation address.
bootstrap_address = "bc1qypskemx80lznv4tjpnmpw9c5pgpy32fpkk3sw2"
# Any donation amount for developers to be sent to donation address. Default no donation.
# donation_address = "<your donation address here>"
# In basis points, 1% = 100 basis points. Default 0
Expand All @@ -31,9 +32,6 @@ difficulty_multiplier = 1.0
# to add a pool signature. Maximum length 16 bytes.
pool_signature = "hydrapool"

[miner]
pubkey = "020202020202020202020202020202020202020202020202020202020202020202"

[bitcoinrpc]
# RPC credentials are loaded from env vars
url = "http://127.0.0.1:38332"
Expand Down
16 changes: 0 additions & 16 deletions hydrapool.service

This file was deleted.

39 changes: 39 additions & 0 deletions packages/Dockerfile.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
FROM ubuntu:jammy

# Install required build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
clang \
pkg-config \
libzmq3-dev \
git \
cmake \
libzstd-dev \
libsnappy-dev \
libbz2-dev \
liblz4-dev \
zlib1g-dev \
libssl-dev \
curl \
dpkg-dev \
&& rm -rf /var/lib/apt/lists/*

RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN cargo install cargo-deb

RUN mkdir -p /hydrapool
COPY ../LICENSE /hydrapool
COPY ../Cargo.toml /hydrapool
COPY ../Cargo.lock /hydrapool
COPY ../config.toml /hydrapool
COPY ../src /hydrapool/src/
COPY ../packages/ /hydrapool/packages/

WORKDIR /hydrapool
RUN cargo build --release

WORKDIR /hydrapool/packages

ENTRYPOINT [ ]
CMD ["/hydrapool/packages/build-deb.sh"]
18 changes: 18 additions & 0 deletions packages/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
= Packaging for Hydrapool

== Supported packages:

. Debian

= Debian Build Locally Using Docker

== Build docker image

This image runs cargo build --release so that later we use the image
only to build the package.

`docker build -f packages/Dockerfile.debian -t debian-build-hydrapool-package .`

== Build package

`docker run --volume ./:/hydrapool/target debian-build-hydrapool-package`
33 changes: 33 additions & 0 deletions packages/build-deb.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash
set -e

echo "Building Hydrapool Debian package..."
echo

# Check if cargo-deb is installed
if ! command -v cargo-deb &> /dev/null; then
echo "cargo-deb not found. Installing..."
cargo install cargo-deb
fi

# Build the release binaries first
echo "Building release binaries..."
cargo build --release

# Build the Debian package
echo "Creating Debian package..."
cargo deb

echo
echo "Build complete!"
echo "Package location: target/debian/"
ls -lh ../target/debian/*.deb
echo
echo "To install the package:"
echo " sudo dpkg -i target/debian/hydrapool_*.deb"
echo
echo "After installation:"
echo " 1. Edit /etc/hydrapool/config.toml with your settings"
echo " 2. Start the service: sudo systemctl start hydrapool"
echo " 3. Enable at boot: sudo systemctl enable hydrapool"
echo " 4. Check status: sudo systemctl status hydrapool"
25 changes: 25 additions & 0 deletions packages/debian/service
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[Unit]
Description=Hydrapool Bitcoin Mining Pool
After=network.target

[Service]
Type=simple
User=hydrapool
Group=hydrapool
WorkingDirectory=/var/lib/hydrapool
ExecStart=/usr/bin/hydrapool --config /etc/hydrapool/config.toml
Restart=always
RestartSec=30
StandardOutput=journal
StandardError=journal
SyslogIdentifier=hydrapool

# Security hardening
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/hydrapool /var/log/hydrapool

[Install]
WantedBy=multi-user.target