-
Notifications
You must be signed in to change notification settings - Fork 231
110 lines (100 loc) · 3.73 KB
/
docker-image.yml
File metadata and controls
110 lines (100 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Build and Push Docker Images
on:
push:
branches: [main, master]
paths:
- '.ci/Dockerfile'
- '.ci/*.patch'
- '.github/workflows/docker-image.yml'
workflow_dispatch:
inputs:
force_rebuild:
description: 'Force rebuild all images'
required: false
default: 'false'
type: boolean
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/pylibfranka-build
jobs:
build-and-push:
name: Build ${{ matrix.name }} image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
# Python wheel build images
- python-version: '3.9'
ubuntu-version: '20.04' # Ubuntu 20.04 for glibc 2.31 compatibility
name: 'Python 3.9'
tag-prefix: 'py'
- python-version: '3.10'
ubuntu-version: '22.04'
name: 'Python 3.10'
tag-prefix: 'py'
- python-version: '3.11'
ubuntu-version: '22.04'
name: 'Python 3.11'
tag-prefix: 'py'
- python-version: '3.12'
ubuntu-version: '22.04'
name: 'Python 3.12'
tag-prefix: 'py'
# Debian package build images (Ubuntu version specific)
- python-version: '3.8'
ubuntu-version: '20.04'
name: 'Ubuntu 20.04'
tag-prefix: 'ubuntu'
- python-version: '3.10'
ubuntu-version: '22.04'
name: 'Ubuntu 22.04'
tag-prefix: 'ubuntu'
- python-version: '3.12'
ubuntu-version: '24.04'
name: 'Ubuntu 24.04'
tag-prefix: 'ubuntu'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ matrix.tag-prefix }}${{ matrix.tag-prefix == 'py' && matrix.python-version || matrix.ubuntu-version }}
type=sha,prefix=${{ matrix.tag-prefix }}${{ matrix.tag-prefix == 'py' && matrix.python-version || matrix.ubuntu-version }}-
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .ci/
file: .ci/Dockerfile
build-args: |
UBUNTU_VERSION=${{ matrix.ubuntu-version }}
PYTHON_VERSION=${{ matrix.python-version }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=docker-${{ matrix.tag-prefix }}${{ matrix.tag-prefix == 'py' && matrix.python-version || matrix.ubuntu-version }}
cache-to: type=gha,mode=max,scope=docker-${{ matrix.tag-prefix }}${{ matrix.tag-prefix == 'py' && matrix.python-version || matrix.ubuntu-version }}
- name: Verify pushed image
env:
IMAGE_TAG: ${{ matrix.tag-prefix }}${{ matrix.tag-prefix == 'py' && matrix.python-version || matrix.ubuntu-version }}
run: |
echo "Verifying image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG}"
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG}
docker run --rm ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${IMAGE_TAG} python3 --version