Skip to content

Commit 3bd72a2

Browse files
committed
GitHub Action for DockerHub build and publish dipdup-io#19
1 parent 9fbaadb commit 3bd72a2

File tree

3 files changed

+116
-0
lines changed

3 files changed

+116
-0
lines changed

.github/workflows/docker-publish.yml

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and Publish image to Docker Hub
2+
on:
3+
repository_dispatch:
4+
types: [prover-update]
5+
push:
6+
tags:
7+
- 'v*.*.*'
8+
9+
jobs:
10+
build_and_push:
11+
env:
12+
DOCKER_HUB: ${{ secrets.DOCKER_LOGIN }}
13+
DOCKER_TAGS: latest
14+
runs-on: ubuntu-22.04
15+
permissions:
16+
id-token: write
17+
attestations: write
18+
contents: read
19+
packages: write
20+
21+
strategy:
22+
matrix:
23+
target:
24+
- name: stone-prover
25+
dockerfile: Dockerfile
26+
- name: cpu_air_prover
27+
dockerfile: air_prover/Dockerfile
28+
- name: cpu_air_verifier
29+
dockerfile: air_verifier/Dockerfile
30+
continue-on-error: true
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Set up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Log in to Docker Hub
40+
uses: docker/login-action@v3
41+
with:
42+
username: ${{ secrets.DOCKER_LOGIN }}
43+
password: ${{ secrets.DOCKERHUB_TOKEN }}
44+
45+
- name: Determine Docker Tags
46+
id: set-tag
47+
run: |
48+
if [[ "${GITHUB_EVENT_NAME}" == "repository_dispatch" ]]; then
49+
echo "Latest version tags..."
50+
elif [[ "${GITHUB_REF}" == refs/tags/* ]]; then
51+
TAG_NAME=$(echo ${GITHUB_REF} | sed 's/refs\/tags\///')
52+
echo "DOCKER_TAGS=${TAG_NAME}" >> $GITHUB_ENV
53+
else
54+
echo "No valid ref for tagging. Exiting..."
55+
exit 1
56+
fi
57+
shell: bash
58+
59+
- name: Set image tags & labels
60+
id: meta
61+
uses: docker/metadata-action@v5
62+
with:
63+
images: ${{ env.DOCKER_HUB }}/${{ matrix.target.name }}
64+
tags: ${{ env.DOCKER_TAGS }}
65+
66+
- name: Build And Push Image
67+
id: push
68+
uses: docker/build-push-action@v6
69+
with:
70+
context: .
71+
file: ${{ matrix.target.dockerfile }}
72+
push: true
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}
75+
76+
- name: Generate artifact attestation
77+
if: github.event.repository.fork == false
78+
uses: actions/attest-build-provenance@v1
79+
with:
80+
subject-name: ${{ secrets.DOCKER_LOGIN }}/${{ matrix.target.name }}
81+
subject-digest: ${{ steps.push.outputs.digest }}
82+
push-to-registry: true
83+

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,39 @@ Run the verifier to confirm the proof:
149149
cpu_air_verifier --in_file=fibonacci_proof.json && echo "Successfully verified example proof."
150150
```
151151

152+
## Docker Image Publishing
153+
154+
This repository contains a GitHub Actions workflow that automatically builds and publishes Docker images to Docker Hub.
155+
156+
- **Workflow file:** `.github/workflows/docker-publish.yml`
157+
158+
### Usage
159+
160+
1. Set up the following GitHub repository secrets under **Settings** > **Secrets and variables** > **Actions**:
161+
- `DOCKER_LOGIN`: Your Docker Hub username.
162+
- `DOCKERHUB_TOKEN`: Your Docker Hub access token.
163+
2. The workflow is triggered by any push or pull request to the `master` branch. It builds the Docker image and publishes it to Docker Hub.
164+
165+
### Workflow Overview
166+
167+
The workflow performs the following actions:
168+
- Checks out the repository code.
169+
- Sets up Docker Buildx for cross-platform builds.
170+
- Logs in to Docker Hub using the credentials stored in GitHub Secrets.
171+
- Builds the Docker image based on the repository content.
172+
- Pushes the image to Docker Hub with the specified tag.
173+
- Generates an attestation for the image artifact (not applicable to forked repositories).
174+
- Logs out of Docker Hub after the process is complete.
175+
176+
### Tests
177+
178+
1. Forked the original repository.
179+
2. To use the local Docker Hub, update the workflow file by setting `env.DOCKER_HUB` to `127.0.0.1:5000`.
180+
3. Temporarily updated the workflow trigger branch for testing purposes.
181+
4. Pushed a small change to trigger the workflow.
182+
5. Monitored the workflow in the **Actions** tab.
183+
6. Verified the Docker image was pushed to local Docker Hub.
184+
152185
This project is supported by Nethermind and Starknet Foundation via [OnlyDust platform](https://app.onlydust.com/p/stone-packaging-)
153186

154187

build.sh

100644100755
File mode changed.

0 commit comments

Comments
 (0)