10 Commits

Author SHA1 Message Date
Seth For Privacy
699b578ee7 Harden CI workflows: reliability tests, least-privilege, build cache
Reliability (catch a bad image revision before prod):
- Smoke-test the exact pushed digest in update-image-on-push.yml BEFORE the
  merge job tags it 'latest' (previously the prod artifact was never run).
- Assert the p2pool banner reports the pinned P2POOL_BRANCH tag, and verify
  the container starts and stays up, instead of just sleeping 30s.

Hardening:
- Least-privilege 'permissions:' blocks (default contents: read; packages:
  write only on push/merge jobs; repo default token is currently write-all).
- Concurrency groups (cancel superseded PR builds; serialize prod pushes).
- persist-credentials: false on checkout; timeout-minutes on jobs.

Build cache:
- cache-to registry buildcache (mode=max, per-arch); read buildcache + latest.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 09:16:30 -04:00
Seth For Privacy
46d68375cd Merge pull request #161 from sethforprivacy/fix-legacy-dockerfile-syntax
Fix legacy Dockerfile syntax flagged by BuildKit
2026-06-23 08:45:47 -04:00
Seth For Privacy
1bb3947f60 Fix legacy Dockerfile syntax flagged by BuildKit
- 'FROM ... as build' -> 'AS' (FromAsCasing)
- 'ENV key value' -> 'ENV key=value' for USE_SINGLE_BUILDDIR and
  BOOST_DEBUG (LegacyKeyValueFormat)

No functional change; 'docker build --check' now reports no warnings.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-23 08:20:40 -04:00
Seth For Privacy
df326bcf85 Merge pull request #160 from sethforprivacy/renovate/ubuntu-26.x
chore(deps): update ubuntu docker tag to v26
2026-06-23 07:36:59 -04:00
renovate[bot]
f0f9059dd6 chore(deps): update ubuntu docker tag to v26 2026-06-23 11:11:44 +00:00
Seth For Privacy
93b13c156d Merge pull request #157 from sethforprivacy/optimize-final-image
Optimize final image: runtime libs instead of -dev, pin base image
2026-06-23 07:11:01 -04:00
Seth For Privacy
5b7ab876bf Merge pull request #158 from sethforprivacy/add-renovate-config
Add Renovate config for automated p2pool version bumps
2026-06-23 07:10:21 -04:00
Seth For Privacy
c0187089f4 Optimize final image: runtime libs instead of -dev, pin base image
The final runtime stage installed full -dev packages (headers, static
archives, build-time deps) when only the runtime shared libraries are
needed. Replace them with the runtime-only equivalents, verified via
`ldd` on the built p2pool binary against the pinned base.

Changes:
- Final stage: install runtime libs instead of -dev packages
  (libuv1t64, libzmq5, libsodium23, libpgm-5.3-0t64, libnorm1t64,
  libgssapi-krb5-2, libcurl4t64, libidn2-0). Note the t64 names on
  Ubuntu 24.04 due to the 64-bit time_t transition.
- Pin both stages to ubuntu:24.04 (current LTS) instead of
  ubuntu:latest for reproducible builds. Renovate's docker manager
  keeps this current.
- Add --depth 1 --shallow-submodules to the git clone for faster,
  lighter source checkout.

Local verification (native arm64):
- Build succeeds (exit 0).
- `docker run --rm p2pool:test --help` prints "P2Pool v4.17" + usage.
- `ldd` on the binary in the final image: all libs resolve, none missing.
- Image size: 317MB -> 188MB (-129MB, -41%).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 20:57:26 -04:00
Seth For Privacy
6f18143ef1 Merge pull request #156 from sethforprivacy/purge-old-handle
chore: purge old sethsimmons handle/branding
2026-06-22 20:18:01 -04:00
Seth For Privacy
81b47a06b7 chore: replace old sethsimmons handle/branding
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-22 20:15:30 -04:00
4 changed files with 108 additions and 34 deletions

View File

@@ -11,12 +11,25 @@ on:
- 'Dockerfile' - 'Dockerfile'
workflow_dispatch: workflow_dispatch:
# Least-privilege default token (this workflow only reads the repo and pulls cache)
permissions:
contents: read
# Cancel superseded runs for the same ref to save CI minutes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env: env:
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/p2pool GHCR_REPO: ghcr.io/${{ github.repository_owner }}/p2pool
jobs: jobs:
rebuild-container: rebuild-container:
name: "Build image with cache" name: "Build image with cache"
timeout-minutes: 60
permissions:
contents: read
packages: read
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@@ -35,14 +48,13 @@ jobs:
run: | run: |
echo "PLATFORM=linux/amd64" >> $GITHUB_ENV echo "PLATFORM=linux/amd64" >> $GITHUB_ENV
echo "DIGEST_NAME=amd64" >> $GITHUB_ENV echo "DIGEST_NAME=amd64" >> $GITHUB_ENV
- - name: Set up Docker Buildx
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.1.0 uses: docker/setup-buildx-action@v4.1.0
- - name: Checkout repository
name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
- with:
name: Test build of image persist-credentials: false
- name: Test build of image
id: build id: build
uses: docker/build-push-action@v7.2.0 uses: docker/build-push-action@v7.2.0
with: with:
@@ -50,11 +62,25 @@ jobs:
load: true load: true
platforms: ${{ env.PLATFORM }} platforms: ${{ env.PLATFORM }}
tags: p2pool:testing tags: p2pool:testing
cache-from: type=registry,ref=${{ env.GHCR_REPO }}:latest cache-from: |
- type=registry,ref=${{ env.GHCR_REPO }}:buildcache-${{ env.DIGEST_NAME }}
name: Test-run image type=registry,ref=${{ env.GHCR_REPO }}:latest
- name: Verify reported version matches the pinned p2pool tag
run: | run: |
docker run --rm p2pool:testing --wallet 468ydghFfthE3UTc53eF5MP9UyrMcUiAHP5kizVYJsej5XGaXBoAAEzUHCcUF7t3E3RrYAX8Rs1ujhBdcvMpZSbH8qkb55R & set -euo pipefail
PID=$! EXPECTED="$(awk -F= '/^ARG P2POOL_BRANCH=/{print $2; exit}' Dockerfile)"
sleep 30 echo "Expecting p2pool to report: ${EXPECTED}"
kill -SIGINT $PID # this will return a non-zero exit code if the container dies early on OUT="$(docker run --rm p2pool:testing --help 2>&1 || true)"
echo "${OUT}" | head -1
echo "${OUT}" | grep -q "${EXPECTED}" \
|| { echo "::error::p2pool banner does not contain expected tag ${EXPECTED}"; exit 1; }
- name: Verify the container starts and stays up
run: |
set -uo pipefail
CID="$(docker run -d p2pool:testing --wallet 468ydghFfthE3UTc53eF5MP9UyrMcUiAHP5kizVYJsej5XGaXBoAAEzUHCcUF7t3E3RrYAX8Rs1ujhBdcvMpZSbH8qkb55R)"
sleep 20
if [ "$(docker inspect -f '{{.State.Running}}' "$CID" 2>/dev/null || echo false)" != "true" ]; then
echo "::error::container exited early"; docker logs "$CID" 2>&1 || true
docker rm -f "$CID" >/dev/null 2>&1 || true; exit 1
fi
docker rm -f "$CID" >/dev/null 2>&1 || true

View File

@@ -8,12 +8,26 @@ on:
- 'Dockerfile' - 'Dockerfile'
workflow_dispatch: workflow_dispatch:
# Least-privilege default; jobs that push opt into packages: write below
permissions:
contents: read
# Never run two prod pushes for the same ref concurrently (avoid racing the
# manifest/`latest` tag); do not cancel an in-flight push.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
env: env:
GHCR_REPO: ghcr.io/${{ github.repository_owner }}/p2pool GHCR_REPO: ghcr.io/${{ github.repository_owner }}/p2pool
jobs: jobs:
build: build:
name: "Build container for multiple architectures and push by digest" name: "Build container for multiple architectures and push by digest"
timeout-minutes: 60
permissions:
contents: read
packages: write
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@@ -38,28 +52,53 @@ jobs:
with: with:
images: | images: |
${{ env.GHCR_REPO }} ${{ env.GHCR_REPO }}
- - name: Set up Docker Buildx
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4.1.0 uses: docker/setup-buildx-action@v4.1.0
- - name: Login to GitHub Container Registry
name: Login to GitHub Container Registry
uses: docker/login-action@v4.2.0 uses: docker/login-action@v4.2.0
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- - name: Checkout repository
name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
- with:
name: Build and and push by digest persist-credentials: false
- name: Build and push by digest
uses: docker/build-push-action@v7.2.0 uses: docker/build-push-action@v7.2.0
id: build id: build
with: with:
outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true outputs: type=image,"name=${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
platforms: ${{ env.PLATFORM }} platforms: ${{ env.PLATFORM }}
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ env.GHCR_REPO }}:latest cache-from: |
type=registry,ref=${{ env.GHCR_REPO }}:buildcache-${{ env.DIGEST_NAME }}
type=registry,ref=${{ env.GHCR_REPO }}:latest
cache-to: type=registry,ref=${{ env.GHCR_REPO }}:buildcache-${{ env.DIGEST_NAME }},mode=max
# Smoke-test the exact artifact that was just pushed, BEFORE the merge job
# tags it `latest`. If this fails, the merge job (needs: build) never runs.
- name: Verify pushed image reports the pinned p2pool tag
run: |
set -euo pipefail
EXPECTED="$(awk -F= '/^ARG P2POOL_BRANCH=/{print $2; exit}' Dockerfile)"
REF="${GHCR_REPO}@${{ steps.build.outputs.digest }}"
echo "Expecting ${EXPECTED} from ${REF}"
OUT="$(docker run --rm "${REF}" --help 2>&1 || true)"
echo "${OUT}" | head -1
echo "${OUT}" | grep -q "${EXPECTED}" \
|| { echo "::error::pushed image banner does not contain expected tag ${EXPECTED}"; exit 1; }
- name: Verify pushed image starts and stays up
run: |
set -uo pipefail
REF="${GHCR_REPO}@${{ steps.build.outputs.digest }}"
CID="$(docker run -d "${REF}" --wallet 468ydghFfthE3UTc53eF5MP9UyrMcUiAHP5kizVYJsej5XGaXBoAAEzUHCcUF7t3E3RrYAX8Rs1ujhBdcvMpZSbH8qkb55R)"
sleep 20
if [ "$(docker inspect -f '{{.State.Running}}' "$CID" 2>/dev/null || echo false)" != "true" ]; then
echo "::error::pushed image exited early"; docker logs "$CID" 2>&1 || true
docker rm -f "$CID" >/dev/null 2>&1 || true; exit 1
fi
docker rm -f "$CID" >/dev/null 2>&1 || true
- name: Export digest - name: Export digest
run: | run: |
@@ -76,9 +115,14 @@ jobs:
retention-days: 1 retention-days: 1
merge: merge:
name: "Merge digests and push with proper tags"
timeout-minutes: 15
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: needs:
- build - build
permissions:
contents: read
packages: write
steps: steps:
- name: Download digests - name: Download digests
uses: actions/download-artifact@v8 uses: actions/download-artifact@v8
@@ -99,7 +143,9 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v7 uses: actions/checkout@v7
with:
persist-credentials: false
- name: Get p2pool release tag - name: Get p2pool release tag
run: echo P2POOL_TAG="$(awk -F '=' '/P2POOL_BRANCH=/ {print $2}' Dockerfile)" >> $GITHUB_ENV run: echo P2POOL_TAG="$(awk -F '=' '/P2POOL_BRANCH=/ {print $2}' Dockerfile)" >> $GITHUB_ENV

View File

@@ -1,8 +1,8 @@
# renovate: datasource=github-releases depName=SChernykh/p2pool # renovate: datasource=github-releases depName=SChernykh/p2pool
ARG P2POOL_BRANCH=v4.17 ARG P2POOL_BRANCH=v4.17
# Select latest Ubuntu LTS for the build image base # Pin to the latest Ubuntu LTS for the build image base (kept current by Renovate)
FROM ubuntu:latest as build FROM ubuntu:26.04 AS build
LABEL author="sethforprivacy@protonmail.com" \ LABEL author="sethforprivacy@protonmail.com" \
maintainer="sethforprivacy@protonmail.com" maintainer="sethforprivacy@protonmail.com"
@@ -17,28 +17,30 @@ RUN apt-get update \
ENV CFLAGS='-fPIC' ENV CFLAGS='-fPIC'
ENV CXXFLAGS='-fPIC' ENV CXXFLAGS='-fPIC'
ENV USE_SINGLE_BUILDDIR 1 ENV USE_SINGLE_BUILDDIR=1
ENV BOOST_DEBUG 1 ENV BOOST_DEBUG=1
# Switch to p2pool source directory # Switch to p2pool source directory
WORKDIR /p2pool WORKDIR /p2pool
# Git pull p2pool source at specified tag/branch # Git pull p2pool source at specified tag/branch
ARG P2POOL_BRANCH ARG P2POOL_BRANCH
RUN git clone --recursive --branch ${P2POOL_BRANCH} https://github.com/SChernykh/p2pool . RUN git clone --recursive --depth 1 --shallow-submodules --branch ${P2POOL_BRANCH} https://github.com/SChernykh/p2pool .
# Make static p2pool binary # Make static p2pool binary
ARG NPROC ARG NPROC
RUN test -z "$NPROC" && nproc > /nproc || echo -n "$NPROC" > /nproc && mkdir build && cd build && cmake .. && make -j"$(cat /nproc)" RUN test -z "$NPROC" && nproc > /nproc || echo -n "$NPROC" > /nproc && mkdir build && cd build && cmake .. && make -j"$(cat /nproc)"
# Select latest Ubuntu LTS for the image base # Pin to the latest Ubuntu LTS for the image base (kept current by Renovate)
FROM ubuntu:latest FROM ubuntu:26.04
# Install remaining dependencies # Install only the runtime shared libraries that the p2pool binary links against
# (runtime equivalents of the build-stage -dev packages, verified via ldd on the
# built binary against the pinned Ubuntu 24.04 base)
RUN apt-get update \ RUN apt-get update \
&& apt-get upgrade -y \ && apt-get upgrade -y \
&& apt-get install --no-install-recommends -y libuv1-dev libzmq3-dev libsodium-dev \ && apt-get install --no-install-recommends -y libuv1t64 libzmq5 libsodium23 \
libpgm-dev libnorm-dev libgss-dev libcurl4-openssl-dev libidn2-0-dev \ libpgm-5.3-0t64 libnorm1t64 libgssapi-krb5-2 libcurl4t64 libidn2-0 \
&& apt-get clean \ && apt-get clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*

View File

@@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) 2021 Seth Simmons (@sethsimmons) Copyright (c) 2021 Seth For Privacy (@sethforprivacy)
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal