Skip to content

Commit 776bce6

Browse files
committed
implemented python-only target
1 parent 750572e commit 776bce6

2 files changed

Lines changed: 140 additions & 8 deletions

File tree

.github/workflows/python-314t-rust.yml

Lines changed: 122 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,125 @@ env:
1818

1919
jobs:
2020

21+
# Build job for py314t image (base Python image)
22+
build-py314t:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
packages: write
27+
id-token: write
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
platform:
32+
- linux/amd64
33+
- linux/arm64
34+
steps:
35+
- name: Checkout repository
36+
uses: actions/checkout@v4
37+
38+
- name: Inject slug/short variables
39+
uses: rlespinasse/github-slug-action@v4.4.1
40+
41+
- name: Prepare
42+
run: |
43+
platform=${{ matrix.platform }}
44+
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
45+
46+
# Install the cosign tool except on PR
47+
- name: Install cosign
48+
if: github.event_name != 'pull_request'
49+
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
50+
with:
51+
cosign-release: 'v2.1.1'
52+
53+
# Set up QEMU for cross-platform builds
54+
- name: Set up QEMU
55+
uses: docker/setup-qemu-action@v3
56+
57+
# Set up BuildKit Docker container builder
58+
- name: Set up Docker Buildx
59+
uses: docker/setup-buildx-action@v3
60+
61+
# Login against a Docker registry except on PR
62+
- name: Log into registry ${{ env.REGISTRY }}
63+
if: github.event_name != 'pull_request'
64+
uses: docker/login-action@v3
65+
with:
66+
registry: ${{ env.REGISTRY }}
67+
username: ${{ github.actor }}
68+
password: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Build and push by digest
71+
id: build-py314t
72+
uses: docker/build-push-action@v6
73+
with:
74+
provenance: false
75+
sbom: false
76+
file: docker/Dockerfile.py314t_rust
77+
target: py314t
78+
platforms: ${{ matrix.platform }}
79+
tags: ghcr.io/insight-platform/py314t
80+
outputs: type=image,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
81+
context: .
82+
cache-from: type=gha
83+
cache-to: type=gha,mode=max
84+
85+
- name: Export digest
86+
run: |
87+
mkdir -p ${{ runner.temp }}/digests-py314t
88+
digest="${{ steps.build-py314t.outputs.digest }}"
89+
touch "${{ runner.temp }}/digests-py314t/${digest#sha256:}"
90+
91+
- name: Upload digest
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: digests-py314t-${{ env.PLATFORM_PAIR }}
95+
path: ${{ runner.temp }}/digests-py314t/*
96+
if-no-files-found: error
97+
retention-days: 1
98+
99+
# Merge job for py314t image
100+
merge-py314t:
101+
runs-on: ubuntu-latest
102+
needs:
103+
- build-py314t
104+
if: github.event_name != 'pull_request'
105+
permissions:
106+
contents: read
107+
packages: write
108+
steps:
109+
- name: Inject slug/short variables
110+
uses: rlespinasse/github-slug-action@v4.4.1
111+
112+
- name: Download digests
113+
uses: actions/download-artifact@v4
114+
with:
115+
path: ${{ runner.temp }}/digests-py314t
116+
pattern: digests-py314t-*
117+
merge-multiple: true
118+
119+
- name: Set up Docker Buildx
120+
uses: docker/setup-buildx-action@v3
121+
122+
- name: Log into registry ${{ env.REGISTRY }}
123+
uses: docker/login-action@v3
124+
with:
125+
registry: ${{ env.REGISTRY }}
126+
username: ${{ github.actor }}
127+
password: ${{ secrets.GITHUB_TOKEN }}
128+
129+
- name: Create manifest list and push
130+
working-directory: ${{ runner.temp }}/digests-py314t
131+
run: |
132+
docker buildx imagetools create \
133+
-t ghcr.io/insight-platform/py314t:${{ env.GITHUB_REF_SLUG }} \
134+
$(printf 'ghcr.io/insight-platform/py314t@sha256:%s ' *)
135+
136+
- name: Inspect image
137+
run: |
138+
docker buildx imagetools inspect ghcr.io/insight-platform/py314t:${{ env.GITHUB_REF_SLUG }}
139+
21140
# Build job for py314t_rust image
22141
build-py314t-rust:
23142
runs-on: ubuntu-latest
@@ -68,12 +187,13 @@ jobs:
68187
password: ${{ secrets.GITHUB_TOKEN }}
69188

70189
- name: Build and push by digest
71-
id: build
190+
id: build-py314t-rust
72191
uses: docker/build-push-action@v6
73192
with:
74193
provenance: false
75194
sbom: false
76195
file: docker/Dockerfile.py314t_rust
196+
target: py314t_rust
77197
platforms: ${{ matrix.platform }}
78198
tags: ghcr.io/insight-platform/py314t_rust
79199
outputs: type=image,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
@@ -84,7 +204,7 @@ jobs:
84204
- name: Export digest
85205
run: |
86206
mkdir -p ${{ runner.temp }}/digests-py314trust
87-
digest="${{ steps.build.outputs.digest }}"
207+
digest="${{ steps.build-py314t-rust.outputs.digest }}"
88208
touch "${{ runner.temp }}/digests-py314trust/${digest#sha256:}"
89209
90210
- name: Upload digest
@@ -95,7 +215,6 @@ jobs:
95215
if-no-files-found: error
96216
retention-days: 1
97217

98-
99218
# Merge job for py314t_rust image
100219
merge-py314t-rust:
101220
runs-on: ubuntu-latest

docker/Dockerfile.py314t_rust

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
FROM debian:bookworm-slim
1+
# Stage 1: Build Python 3.14t
2+
FROM debian:bookworm-slim AS python-base
23

34
ENV DEBIAN_FRONTEND=noninteractive
45

5-
# Install dependencies needed for building Python and Rust
6+
# Install dependencies needed for building Python
67
RUN --mount=type=cache,target=/var/lib/apt/lists \
78
apt-get update && apt-get install -y --no-install-recommends \
89
build-essential \
910
pkg-config \
1011
curl \
11-
git \
1212
wget \
1313
ca-certificates \
1414
gcc \
@@ -27,12 +27,10 @@ RUN --mount=type=cache,target=/var/lib/apt/lists \
2727
make \
2828
tk-dev \
2929
uuid-dev \
30-
unzip \
3130
xz-utils \
3231
zlib1g-dev
3332

3433
# Build Python 3.14 with free-threading (--disable-gil)
35-
# Note: Using latest available version - adjust PYTHON_VERSION as needed
3634
ENV PYTHON_VERSION=3.14.0
3735
WORKDIR /tmp
3836
RUN wget -q https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tar.xz && \
@@ -59,6 +57,21 @@ RUN python3.14t --version && \
5957
ls -la /usr/local/lib/libpython3.14t* && \
6058
python3.14t -c "import sysconfig; print('Lib dir:', sysconfig.get_config_var('LIBDIR'))"
6159

60+
WORKDIR /opt
61+
62+
# Stage 2: py314t - Python-only image
63+
FROM python-base AS py314t
64+
# This stage is just the Python base, no additional changes needed
65+
66+
# Stage 3: py314t_rust - Python + Rust image
67+
FROM python-base AS py314t_rust
68+
69+
# Install additional dependencies needed for Rust
70+
RUN --mount=type=cache,target=/var/lib/apt/lists \
71+
apt-get update && apt-get install -y --no-install-recommends \
72+
git \
73+
unzip
74+
6275
RUN --mount=type=bind,source=.,target=/opt/scripts bash /opt/scripts/docker/install-basic-deps.sh
6376

6477
WORKDIR /opt

0 commit comments

Comments
 (0)