Skip to content

Commit 7e85775

Browse files
committed
Add a build container
Once this lands and is published, the dev container will be updated to be based on this image.
1 parent 2c28764 commit 7e85775

File tree

6 files changed

+81
-2
lines changed

6 files changed

+81
-2
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,31 @@ on:
88
branches: [main]
99

1010
jobs:
11-
build_devcontainer:
12-
name: Build and test (Devcontainer)
11+
build_build_container:
12+
name: Build and test (build container)
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
os: [ubuntu-latest, ubuntu-24.04-arm]
17+
runs-on: ${{ matrix.os }}
18+
env:
19+
TAG: cpython-buildcontainer:1.0.0-${{ github.run_id }}
20+
steps:
21+
- name: Checkout Push to Registry action
22+
uses: actions/checkout@v5
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
- name: Build Dockerfile
26+
uses: docker/build-push-action@v6
27+
with:
28+
context: ./devcontainer
29+
load: true
30+
tags: ${{ env.TAG }}
31+
- name: Test Clang version
32+
run: docker run --rm ${{ env.TAG }} clang --version
33+
34+
build_dev_container:
35+
name: Build and test (Dev container)
1336
strategy:
1437
fail-fast: false
1538
matrix:

.github/workflows/release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
type: choice
1111
options:
1212
- autoconf
13+
- buildcontainer
1314
- devcontainer
1415

1516
run-name: "Release: ${{ inputs.package }}"

buildcontainer/Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM docker.io/library/fedora:41
2+
3+
LABEL org.opencontainers.image.base.name="docker.io/library/fedora:41"
4+
LABEL org.opencontainers.image.source="https://github.com/python/cpython-devcontainers"
5+
LABEL org.opencontainers.image.title="CPython build container"
6+
LABEL org.opencontainers.image.description="CPython build container for Linux."
7+
LABEL org.opencontainers.image.authors="Brett Cannon"
8+
9+
ENV CC=clang
10+
11+
# Remove a video codec repository to speed up installs.
12+
RUN dnf config-manager setopt fedora-cisco-openh264.enabled=False
13+
14+
RUN mkdir -p /opt/cpython-devcontainer/bin
15+
COPY --chmod=755 install-builddeps.sh /opt/cpython-devcontainer/bin/
16+
17+
RUN /opt/cpython-devcontainer/bin/install-builddeps.sh

buildcontainer/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This container image contains everything necessary to build CPython on Linux.
2+
3+
It is **not** meant for general development unless you are space-constrained.
4+
For development you should use the
5+
[dev container image](https://github.com/python/cpython-devcontainers/tree/main/devcontainer).
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#! /bin/bash -ex
2+
3+
# Install build tools and CPython dependencies on Fedora.
4+
5+
6+
# Define dependencies as an array, for easier formatting & comments.
7+
# see: https://www.gnu.org/software/bash/manual/html_node/Arrays.html
8+
# Contents inspired by experience and
9+
# https://github.com/devcontainers/features/tree/main/src/common-utils .
10+
DEPS=(
11+
# Bare minimum
12+
/usr/bin/{blurb,clang,git}
13+
14+
# Necessary for getting Python build dependencies
15+
'dnf5-command(builddep)'
16+
17+
# TODO: remove when Fedora version includes Python 3.14
18+
libzstd-devel
19+
)
20+
21+
dnf -y --nodocs --setopt=install_weak_deps=False install ${DEPS[@]}
22+
dnf -y --nodocs --setopt=install_weak_deps=False builddep python3
23+
24+
# Don't leave caches in the container
25+
dnf -y clean all

devcontainer/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
A general dev container for developing CPython for Linux and WASI.
2+
3+
See the
4+
[devguide's container docs](https://devguide.python.org/getting-started/setup-building/#using-a-container)
5+
on how to use this container image for development.
6+
7+
If you need a smaller/minimal container image, see the
8+
[build container](https://github.com/python/cpython-devcontainers/tree/main/buildcontainer).

0 commit comments

Comments
 (0)