Skip to content

Commit 8ea05d8

Browse files
committed
build: add development flow
1 parent 9b7b0a9 commit 8ea05d8

File tree

1 file changed

+202
-0
lines changed

1 file changed

+202
-0
lines changed

.github/workflows/development.yml

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
name: development
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- '*' # matches every branch that doesn't contain a '/'
8+
- '*/*' # matches every branch containing a single '/'
9+
- '*/*/*' # matches every branch contains two /
10+
- '**' # matches every branch
11+
- '!main' # excludes main
12+
- '!master' # excludes master
13+
paths:
14+
- ".github/workflows/development.yaml"
15+
16+
17+
env:
18+
TARGET_PLATFORMS: linux/amd64,linux/arm64/v8
19+
20+
jobs:
21+
docker:
22+
strategy:
23+
fail-fast: true
24+
matrix:
25+
repository:
26+
- 'localhost:5000'
27+
python:
28+
- '3.14'
29+
- '3.13'
30+
- '3.12'
31+
- '3.11'
32+
- '3.10'
33+
- '3.9'
34+
- '3.8'
35+
alpine:
36+
- '3.20'
37+
- '3.21'
38+
- '3.22'
39+
os:
40+
- 'ubuntu-latest'
41+
exclude:
42+
# No tag
43+
- python: '3.8'
44+
alpine: '3.21'
45+
- python: '3.8'
46+
alpine: '3.22'
47+
- python: '3.14'
48+
alpine: '3.20'
49+
50+
runs-on: ${{ matrix.os }}
51+
services:
52+
registry:
53+
image: registry:3
54+
ports:
55+
- 5000:5000
56+
57+
permissions:
58+
packages: write
59+
60+
steps:
61+
-
62+
name: Checkout
63+
uses: actions/checkout@v4
64+
65+
-
66+
name: Set up QEMU
67+
uses: docker/setup-qemu-action@v3
68+
-
69+
name: Set up Docker Buildx
70+
uses: docker/setup-buildx-action@v3
71+
72+
-
73+
id: image_env
74+
run: |
75+
. ./env.sh \
76+
'${{ matrix.alpine }}' \
77+
'${{ matrix.python }}' \
78+
'${{ github.repository_owner }}' \
79+
'${{ matrix.repository }}'
80+
81+
docker pull "${SOURCE_IMAGE}" || true
82+
echo "IMAGE_HOME=$(mktemp -d)" >> "$GITHUB_OUTPUT"
83+
84+
echo ALPINE_VERSION="${ALPINE_VERSION}" >> "$GITHUB_OUTPUT"
85+
echo PYTHON_VERSION="${PYTHON_VERSION}" >> "$GITHUB_OUTPUT"
86+
echo SOURCE_IMAGE="${SOURCE_IMAGE}" >> "$GITHUB_OUTPUT"
87+
echo IMAGE_TAG="${IMAGE_TAG}" >> "$GITHUB_OUTPUT"
88+
echo REPOSITORY="${REPOSITORY}" >> "$GITHUB_OUTPUT"
89+
echo BASE_IMAGE_DIGEST="$(digest_of "$SOURCE_IMAGE")" >> "$GITHUB_OUTPUT"
90+
echo 'IMAGE_DESCRIPTION=${{ github.event.repository.description }}. See ${{ github.server_url }}/${{ github.repository }} for more info.' >> "$GITHUB_OUTPUT"
91+
92+
exit 1
93+
94+
-
95+
name: Login to GitHub Container Registry
96+
if: ${{ matrix.repository == 'ghcr.io' }}
97+
uses: docker/login-action@v3
98+
with:
99+
registry: 'ghcr.io'
100+
username: ${{ github.repository_owner }}
101+
password: ${{ secrets.GITHUB_TOKEN }}
102+
-
103+
name: Login to DockerHub
104+
if: ${{ matrix.repository == 'docker.io' }}
105+
uses: docker/login-action@v3
106+
with:
107+
registry: 'docker.io'
108+
username: ${{ github.repository_owner }}
109+
password: ${{ secrets.DOCKERHUB_TOKEN }}
110+
-
111+
name: Create Buildroot
112+
uses: docker/build-push-action@v6
113+
with:
114+
push: true
115+
platforms: ${{ env.TARGET_PLATFORMS }}
116+
context: "."
117+
file: Dockerfile.alpine
118+
target: buildroot
119+
cache-to: |
120+
type=gha,mode=max
121+
cache-from: |
122+
type=gha
123+
type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot
124+
type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }}
125+
build-args: |
126+
ALPINE_VERSION=${{ steps.image_env.outputs.ALPINE_VERSION }}
127+
BASE_IMAGE_DIGEST=${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }}
128+
PYTHON_VERSION=${{ steps.image_env.outputs.PYTHON_VERSION }}
129+
SOURCE_IMAGE=${{ steps.image_env.outputs.SOURCE_IMAGE }}
130+
BUILD_ROOT=/d
131+
tags: "${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot"
132+
-
133+
name: Upload
134+
uses: docker/build-push-action@v6
135+
env:
136+
SOURCE_DATE_EPOCH: 0
137+
with:
138+
push: true
139+
context: "."
140+
platforms: ${{ env.TARGET_PLATFORMS }}
141+
file: Dockerfile.alpine
142+
cache-to: |
143+
type=gha,mode=max
144+
cache-from: |
145+
type=gha
146+
type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}
147+
type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot
148+
type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }}
149+
build-args: |
150+
ALPINE_VERSION=${{ steps.image_env.outputs.ALPINE_VERSION }}
151+
BASE_IMAGE_DIGEST=${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }}
152+
PYTHON_VERSION=${{ steps.image_env.outputs.PYTHON_VERSION }}
153+
SOURCE_IMAGE=${{ steps.image_env.outputs.SOURCE_IMAGE }}
154+
BUILD_ROOT=/d
155+
tags: "${{ steps.image_env.outputs.IMAGE_TAG }}"
156+
labels: ${{steps.image_env.outputs.IMAGE_LABELS}}
157+
sbom: true
158+
annotations: |
159+
index,manifest:org.opencontainers.image.authors=distroless-python image developers <autumn.jolitz+distroless-python@gmail.com>
160+
index,manifest:org.opencontainers.image.source=https://github.com/autumnjolitz/distroless-python
161+
index,manifest:org.opencontainers.image.title=distroless-python${{ steps.image_env.outputs.PYTHON_VERSION }}-alpine${{ steps.image_env.outputs.ALPINE_VERSION }}
162+
index,manifest:org.opencontainers.image.description=${{ steps.image_env.outputs.IMAGE_DESCRIPTION }}
163+
index,manifest:org.opencontainers.image.base.digest=${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }}
164+
index,manifest:org.opencontainers.image.base.name=${{ steps.image_env.outputs.SOURCE_IMAGE }}
165+
index,manifest:distroless.python-version=${{ steps.image_env.outputs.PYTHON_VERSION }}
166+
index,manifest:distroless.alpine-version=${{ steps.image_env.outputs.ALPINE_VERSION }}
167+
index,manifest:distroless.base-image=alpine${{ steps.image_env.outputs.ALPINE_VERSION }}
168+
169+
-
170+
name: examples/simple-flask
171+
uses: docker/build-push-action@v6
172+
with:
173+
context: "examples/simple-flask"
174+
platforms: ${{ env.TARGET_PLATFORMS }}
175+
cache-from: |
176+
type=gha
177+
type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}
178+
type=registry,ref=${{ steps.image_env.outputs.IMAGE_TAG }}-buildroot
179+
type=registry,ref=${{ steps.image_env.outputs.SOURCE_IMAGE }}@${{ steps.image_env.outputs.BASE_IMAGE_DIGEST }}
180+
build-args: |
181+
SOURCE_IMAGE=${{ steps.image_env.outputs.IMAGE_TAG }}
182+
tags: "${{ steps.image_env.outputs.IMAGE_TAG }}-example1-amd64"
183+
outputs: type=oci,dest=${{ steps.image_env.outputs.IMAGE_HOME }}/example1.tar
184+
185+
186+
render-dockerhub-desc:
187+
needs: [docker]
188+
runs-on: "ubuntu-latest"
189+
steps:
190+
-
191+
name: Checkout
192+
uses: actions/checkout@v4
193+
-
194+
name: Convert README.rst to markdown
195+
uses: docker://pandoc/core:2.9
196+
with:
197+
args: >-
198+
-s
199+
--wrap=none
200+
-t gfm
201+
-o README.md
202+
README.rst

0 commit comments

Comments
 (0)