Skip to content

Commit f1680b4

Browse files
feat: add Docker image build/push to the release workflow
Adds a Dockerfile and .dockerignore, and extends the tag-triggered release workflow with a job that builds and pushes the image to GitHub Container Registry (ghcr.io) alongside the existing wheel/sdist GitHub release. Tags the image with the release version and, for non-prerelease tags, also tags it "latest".
1 parent 0f2329e commit f1680b4

3 files changed

Lines changed: 65 additions & 0 deletions

File tree

.dockerignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.git
2+
.github
3+
.pytest_cache
4+
__pycache__
5+
*.pyc
6+
.minichain
7+
tests/
8+
examples/
9+
public/
10+
bore.zip
11+
bore_bin/
12+
dist/
13+
build/
14+
*.egg-info/
15+
README.md
16+
Contributors.md
17+
DCO.md

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77

88
permissions:
99
contents: write
10+
packages: write
1011

1112
jobs:
1213
build-and-release:
@@ -40,3 +41,36 @@ jobs:
4041
files: dist/*
4142
generate_release_notes: true
4243
prerelease: ${{ steps.prerelease.outputs.is_prerelease }}
44+
45+
docker:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
50+
- name: Log in to GitHub Container Registry
51+
uses: docker/login-action@v3
52+
with:
53+
registry: ghcr.io
54+
username: ${{ github.actor }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Compute image tags
58+
id: image
59+
run: |
60+
IMAGE="ghcr.io/$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')"
61+
TAGS="${IMAGE}:${GITHUB_REF_NAME}"
62+
if [[ ! "${GITHUB_REF_NAME}" =~ (a|b|rc)[0-9]+$ ]]; then
63+
TAGS="${TAGS}"$'\n'"${IMAGE}:latest"
64+
fi
65+
{
66+
echo "tags<<EOF"
67+
echo "$TAGS"
68+
echo "EOF"
69+
} >> "$GITHUB_OUTPUT"
70+
71+
- name: Build and push image
72+
uses: docker/build-push-action@v6
73+
with:
74+
context: .
75+
push: true
76+
tags: ${{ steps.image.outputs.tags }}

Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:3.11-slim
2+
3+
WORKDIR /app
4+
5+
COPY requirements.txt .
6+
RUN pip install --no-cache-dir -r requirements.txt
7+
8+
COPY main.py genesis.json ./
9+
COPY minichain/ ./minichain/
10+
11+
EXPOSE 9000 8545
12+
13+
ENTRYPOINT ["python", "main.py"]
14+
CMD ["--host", "0.0.0.0", "--port", "9000"]

0 commit comments

Comments
 (0)