Skip to content
Closed
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
152 changes: 152 additions & 0 deletions .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
---
name: Publish Docker images

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

on:
push:
tags:
- 'v*'

env:
DH_REPO: ${{ github.repository }}
GHCR_REPO: ghcr.io/${{ github.repository }}

jobs:
build:
strategy:
fail-fast: true
matrix:
platform:
- linux/amd64
- linux/arm64/v8
os:
- ubuntu-latest
- ubuntu-24.04-arm
exclude:
- os: ubuntu-latest
platform: linux/arm64/v8
- os: ubuntu-24.04-arm
platform: linux/amd64
runs-on: ${{ matrix.os }}
steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout source
uses: actions/checkout@v4

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DH_REPO }}
${{ env.GHCR_REPO }}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,manifest-descriptor # Important for manifest annotation (used by Github packages)

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

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

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

- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: |
type=image,"name=${{ env.DH_REPO }},${{ env.GHCR_REPO }}",push-by-digest=true,name-canonical=true,push=true
attests: |
type=sbom
type=provenance,mode=max
build-args: |
TARGET_PLATFORM=${{ matrix.platform }}
- name: Export digest
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${{ steps.build.outputs.digest }}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

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

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

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.DH_REPO }}
${{ env.GHCR_REPO }}
tags: |
type=ref,event=tag
type=semver,pattern={{raw}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }}
env:
DOCKER_METADATA_ANNOTATIONS_LEVELS: index # Important for manifest annotation (used by Github packages)

- name: Create manifest list and push
working-directory: ${{ runner.temp }}/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DH_REPO }}@sha256:%s ' *)
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.GHCR_REPO }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.DH_REPO }}:${{ steps.meta.outputs.version }}
docker buildx imagetools inspect ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}
...
35 changes: 35 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# syntax=docker/dockerfile:latest
ARG TARGET_PLATFORM=linux/amd64
FROM --platform=$TARGET_PLATFORM cgr.dev/chainguard/wolfi-base:latest AS build
RUN \
apk add \
build-base \
clang \
cmake \
libuv-dev \
llvm \
llvm-lld \
openssl-dev \
samurai
RUN \
--mount=type=bind,readwrite,source=/,target=/src \
<<EOF
cmake \
-S /src \
-B /src/build \
-G Ninja \
-D BUILD_STATIC=ON \
-D CMAKE_BUILD_TYPE=Release \
-D CMAKE_C_COMPILER=clang \
-D CMAKE_CXX_COMPILER=clang++ \
-D CMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld -static -static-libgcc -static-libstdc++" \
-D OPENSSL_USE_STATIC_LIBS=ON \
-D WITH_HTTP=ON \
-D WITH_TLS=ON
cmake --build /src/build
mv /src/build/xmrig-proxy /xmrig-proxy
EOF

FROM --platform=$TARGET_PLATFORM cgr.dev/chainguard/static:latest AS runtime
COPY --from=build /xmrig-proxy /xmrig-proxy
ENTRYPOINT [ "/xmrig-proxy" ]
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
services:
xmrig-proxy:
image: xmrig/xmrig-proxy:latest
ports:
- 3333:3333
volumes:
- ./xmrig-proxy.json:/.xmrig-proxy.json
...