Skip to content

Commit ef3b23c

Browse files
committed
chore: initial commit
0 parents  commit ef3b23c

16 files changed

+599
-0
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
labels: ["dependencies"]
9+
commit-message:
10+
prefix: "ci"
11+
include: "scope"

.github/workflows/autoupdate.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: autoupdate
2+
3+
on:
4+
schedule:
5+
- cron: '0 18 1,16 * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
autoupdate:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repo
13+
uses: actions/checkout@v4
14+
with:
15+
token: ${{ secrets.COATL_BOT_GH_TOKEN }}
16+
17+
- name: Upgrade build/2.7/requirements.txt
18+
uses: coatl-dev/actions/pip-compile-upgrade@v4
19+
with:
20+
path: requirements.txt
21+
python-version: '2.7'
22+
working-directory: build/2.7
23+
24+
- name: Upgrade build/3.12/requirements.txt
25+
uses: coatl-dev/actions/uv-pip-compile-upgrade@v4
26+
with:
27+
path: requirements.txt
28+
python-version: '3.12'
29+
working-directory: build/3.12
30+
31+
- name: Upgrade pip-tools/2.7/requirements.txt
32+
uses: coatl-dev/actions/pip-compile-upgrade@v4
33+
with:
34+
path: requirements/tools.txt
35+
python-version: '2.7'
36+
working-directory: build/2.7
37+
38+
- name: Detect changes
39+
id: git-diff
40+
uses: coatl-dev/actions/simple-git-diff@v4
41+
42+
- name: Import GPG key
43+
if: ${{ steps.git-diff.outputs.diff == 'true' }}
44+
id: gpg-import
45+
uses: coatl-dev/actions/gpg-import@v4
46+
with:
47+
passphrase: ${{ secrets.COATL_BOT_GPG_PASSPHRASE }}
48+
private-key: ${{ secrets.COATL_BOT_GPG_PRIVATE_KEY }}
49+
50+
- name: Commit and push changes
51+
if: ${{ steps.git-diff.outputs.diff == 'true' }}
52+
run: |
53+
git checkout -B autoupdate
54+
git add -u
55+
git commit -m "build(deps): update build dependencies"
56+
git push --force --set-upstream origin autoupdate
57+
58+
- name: Create pull request
59+
if: ${{ steps.git-diff.outputs.diff == 'true' }}
60+
uses: coatl-dev/actions/pr-create@v4
61+
with:
62+
gh-token: ${{ secrets.COATL_BOT_GH_TOKEN }}
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
on:
2+
workflow_call:
3+
inputs:
4+
dockerhub-repo:
5+
description: >-
6+
Docker Hub repository to push the image to.
7+
required: true
8+
type: string
9+
dockerhub-username:
10+
description: >-
11+
Username for authenticating to Docker Hub.
12+
required: true
13+
type: string
14+
ghcr-repo:
15+
description: >-
16+
GitHub Container Registry repository to push the image to.
17+
required: true
18+
type: string
19+
ghcr-username:
20+
description: >-
21+
Username for authenticating to GitHub Container Registry.
22+
required: true
23+
type: string
24+
quay-repo:
25+
description: >-
26+
Quay repository to push the image to.
27+
required: true
28+
type: string
29+
quay-username:
30+
description: >-
31+
Username for authenticating to Quay.
32+
required: true
33+
type: string
34+
build-context:
35+
description: >-
36+
Build's context is the set of files located in the specified PATH or URL.
37+
type: string
38+
required: false
39+
build-file:
40+
description: >-
41+
Path to the Dockerfile.
42+
type: string
43+
required: false
44+
build-digest-key:
45+
description: >-
46+
Name of the build digest.
47+
required: false
48+
type: string
49+
default: coatl
50+
metadata-tags:
51+
description: >-
52+
List of tags as key-value pair attributes.
53+
required: false
54+
type: string
55+
latest-tag-flavor:
56+
description: >-
57+
Set the latest tag flavor.
58+
required: false
59+
type: string
60+
default: auto
61+
secrets:
62+
dockerhub-password:
63+
description: >-
64+
Password or personal access token for authenticating against Docker Hub.
65+
required: true
66+
ghcr-password:
67+
description: >-
68+
Password or personal access token for authenticating against GitHub Container Registry.
69+
quay-password:
70+
description: >-
71+
Password or personal access token for authenticating against Quay.
72+
required: true
73+
74+
jobs:
75+
build:
76+
runs-on: ${{ matrix.builder.runner-image }}
77+
strategy:
78+
fail-fast: false
79+
matrix:
80+
builder:
81+
- runner-image: blacksmith-4vcpu-ubuntu-2404
82+
platform: linux/amd64
83+
- runner-image: blacksmith-4vcpu-ubuntu-2404-arm
84+
platform: linux/arm64
85+
steps:
86+
- name: Checkout repository
87+
uses: actions/checkout@v4
88+
89+
- name: Prepare
90+
id: prepare
91+
run: |
92+
platform=${{ matrix.builder.platform }}
93+
echo "platform-pair=${platform//\//-}" >> $GITHUB_OUTPUT
94+
95+
- name: Docker meta
96+
id: meta
97+
uses: docker/metadata-action@v5
98+
with:
99+
images: |
100+
${{ inputs.dockerhub-repo }}
101+
${{ inputs.ghcr-repo }}
102+
${{ inputs.quay-repo }}
103+
104+
- name: Login to Docker Hub
105+
uses: docker/login-action@v3
106+
with:
107+
username: ${{ inputs.dockerhub-username }}
108+
password: ${{ secrets.dockerhub-password }}
109+
110+
- name: Login to GitHub Container Registry
111+
uses: docker/login-action@v3
112+
with:
113+
registry: ghcr.io
114+
username: ${{ inputs.ghcr-username }}
115+
password: ${{ secrets.ghcr-password }}
116+
117+
- name: Login to Quay
118+
uses: docker/login-action@v3
119+
with:
120+
registry: quay.io
121+
username: ${{ inputs.quay-username }}
122+
password: ${{ secrets.quay-password }}
123+
124+
- name: Set up Docker Buildx
125+
uses: docker/setup-buildx-action@v3
126+
with:
127+
version: latest
128+
129+
- name: Build and push by digest
130+
id: build
131+
uses: useblacksmith/build-push-action@v1
132+
with:
133+
context: ${{ inputs.build-context }}
134+
file: ${{ inputs.build-file }}
135+
labels: ${{ steps.meta.outputs.labels }}
136+
outputs: type=image,"name=${{ inputs.dockerhub-repo }},${{ inputs.ghcr-repo }},${{ inputs.quay-repo }}",push-by-digest=true,name-canonical=true,push=true
137+
platforms: ${{ matrix.builder.platform }}
138+
provenance: false
139+
140+
- name: Export digest
141+
run: |
142+
mkdir -p ${{ runner.temp }}/digests
143+
digest="${{ steps.build.outputs.digest }}"
144+
touch "${{ runner.temp }}/digests/${digest#sha256:}"
145+
146+
- name: Upload digest
147+
uses: actions/upload-artifact@v4
148+
with:
149+
name: digests-${{ inputs.build-digest-key }}-${{ steps.prepare.outputs.platform-pair }}
150+
path: ${{ runner.temp }}/digests/*
151+
if-no-files-found: error
152+
retention-days: 1
153+
154+
merge:
155+
runs-on: blacksmith-2vcpu-ubuntu-2404
156+
needs:
157+
- build
158+
steps:
159+
- name: Download digests
160+
uses: actions/download-artifact@v4
161+
with:
162+
path: ${{ runner.temp }}/digests
163+
pattern: digests-${{ inputs.build-digest-key }}-*
164+
merge-multiple: true
165+
166+
- name: Login to Docker Hub
167+
uses: docker/login-action@v3
168+
with:
169+
username: ${{ inputs.dockerhub-username }}
170+
password: ${{ secrets.dockerhub-password }}
171+
172+
- name: Login to GitHub Container Registry
173+
uses: docker/login-action@v3
174+
with:
175+
registry: ghcr.io
176+
username: ${{ inputs.ghcr-username }}
177+
password: ${{ secrets.ghcr-password }}
178+
179+
- name: Login to Quay
180+
uses: docker/login-action@v3
181+
with:
182+
registry: quay.io
183+
username: ${{ inputs.quay-username }}
184+
password: ${{ secrets.quay-password }}
185+
186+
- name: Set up Docker Buildx
187+
uses: docker/setup-buildx-action@v3
188+
189+
- name: Docker meta
190+
id: meta
191+
uses: docker/metadata-action@v5
192+
with:
193+
images: |
194+
${{ inputs.dockerhub-repo }}
195+
${{ inputs.ghcr-repo }}
196+
${{ inputs.quay-repo }}
197+
tags: |
198+
${{ inputs.metadata-tags }}
199+
flavor: |
200+
latest=${{ inputs.latest-tag-flavor }}
201+
202+
- name: Create manifest list and push
203+
working-directory: ${{ runner.temp }}/digests
204+
run: |
205+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
206+
$(printf '${{ inputs.dockerhub-repo }}@sha256:%s ' *)
207+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
208+
$(printf '${{ inputs.ghcr-repo }}@sha256:%s ' *)
209+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
210+
$(printf '${{ inputs.quay-repo }}@sha256:%s ' *)
211+
212+
- name: Inspect image
213+
run: |
214+
docker buildx imagetools inspect ${{ inputs.dockerhub-repo }}:${{ steps.meta.outputs.version }}
215+
docker buildx imagetools inspect ${{ inputs.ghcr-repo }}:${{ steps.meta.outputs.version }}
216+
docker buildx imagetools inspect ${{ inputs.quay-repo }}:${{ steps.meta.outputs.version }}

.github/workflows/publish.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
branches:
6+
- coatl
7+
paths:
8+
- .github/workflows/docker-build-push-multi-registry.yml
9+
- .github/workflows/publish.yml
10+
- build/**
11+
- pip-tools/**
12+
workflow_dispatch:
13+
14+
env:
15+
IMAGE_NAME: 'python-tools'
16+
17+
jobs:
18+
publish:
19+
uses: ./.github/workflows/docker-build-push-multi-registry.yml
20+
strategy:
21+
matrix:
22+
include:
23+
- context: build/2.7
24+
file: build/2.7/Dockerfile
25+
tag: python-tools:2.7-build
26+
digest-key: python-tools-2.7-build
27+
- context: build/3.12
28+
file: build/3.12/Dockerfile
29+
tag: python-tools:3.12-build
30+
digest-key: python-tools-3.12-build
31+
- context: pip-tools/2.7
32+
file: pip-tools/2.7/Dockerfile
33+
tag: python-tools:2.7-pip-tools
34+
digest-key: python-tools-2.7-pip-tools
35+
with:
36+
dockerhub-repo: coatldev/python-tools
37+
dockerhub-username: ${{ vars.DOCKERHUB_USERNAME }}
38+
ghcr-repo: ghcr.io/coatl-dev/python-tools
39+
ghcr-username: ${{ github.repository_owner }}
40+
quay-repo: quay.io/coatldev/python-tools
41+
quay-username: ${{ vars.QUAY_USERNAME }}
42+
build-context: ${{ matrix.context }}
43+
build-file: ${{ matrix.file }}
44+
build-digest-key: ${{ matrix.digest-key }}
45+
metadata-tags: |
46+
type=raw,value=${{ matrix.tag }}
47+
secrets:
48+
dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}
49+
ghcr-password: ${{ secrets.GHCR_TOKEN }}
50+
quay-password: ${{ secrets.QUAY_ROBOT_TOKEN }}

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
ci:
2+
autoupdate_commit_msg: 'build(deps): pre-commit autoupdate'
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v5.0.0
7+
hooks:
8+
- id: check-yaml
9+
- id: trailing-whitespace
10+
- repo: https://github.com/python-jsonschema/check-jsonschema
11+
rev: 0.33.1
12+
hooks:
13+
- id: check-github-workflows
14+
- repo: https://github.com/coatl-dev/hadolint-coatl
15+
rev: 2.12.1b0
16+
hooks:
17+
- id: hadolint

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# docker-python-tools
2+
3+
This repository is a collection of Docker images containing tools Python 2.7 and 3.12.

build/2.7/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM coatldev/python:2.7.18-slim
2+
3+
COPY requirements.txt /tmp/requirements.txt
4+
5+
RUN set -eux; \
6+
\
7+
python -m pip install \
8+
--no-cache-dir \
9+
--requirement \
10+
/tmp/requirements.txt; \
11+
\
12+
rm -rf /tmp/*
13+
14+
CMD [ "/bin/bash" ]

build/2.7/requirements.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
twine

0 commit comments

Comments
 (0)