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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
**/.env*
**/*.md
ansible
docker/config.toml
3 changes: 0 additions & 3 deletions .github/workflows/build-debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
workflow_run:
workflows: ["Release"]
types: [completed]
push:
branches:
- debian-package

jobs:
build-debian:
Expand Down
85 changes: 85 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Build and Push Docker Images
permissions:
"contents": "write"

on:
release:
types: [published]
push:
branches:
- docker-one-click

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: .
image_name: hydrapool
- component: grafana
dockerfile: docker/Dockerfile.grafana
context: .
image_name: hydrapool-grafana
- component: prometheus
dockerfile: docker/Dockerfile.prometheus
context: .
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

- 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 }}/${{ matrix.image_name }}
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
store*.db
p2pool.log
.env
docker/.env
logs/*
45 changes: 45 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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
- Add docker build work flow to build docker images on github actions

## [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

11 changes: 11 additions & 0 deletions docker/Dockerfile.grafana
Original file line number Diff line number Diff line change
@@ -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
79 changes: 56 additions & 23 deletions docker/Dockerfile.hydrapool
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -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 \
wget \
&& 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"]
6 changes: 6 additions & 0 deletions docker/Dockerfile.prometheus
Original file line number Diff line number Diff line change
@@ -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
Loading