diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3cf7794..78d3ce3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,8 +8,31 @@ on: branches: [main] jobs: - build_devcontainer: - name: Build and test (Devcontainer) + build_build_container: + name: Build and test (build container) + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, ubuntu-24.04-arm] + runs-on: ${{ matrix.os }} + env: + TAG: cpython-buildcontainer:1.0.0-${{ github.run_id }} + steps: + - name: Checkout Push to Registry action + uses: actions/checkout@v5 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build Dockerfile + uses: docker/build-push-action@v6 + with: + context: ./devcontainer + load: true + tags: ${{ env.TAG }} + - name: Test Clang version + run: docker run --rm ${{ env.TAG }} clang --version + + build_dev_container: + name: Build and test (Dev container) strategy: fail-fast: false matrix: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c84146f..37b3dc2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,7 @@ on: type: choice options: - autoconf + - buildcontainer - devcontainer run-name: "Release: ${{ inputs.package }}" diff --git a/buildcontainer/Dockerfile b/buildcontainer/Dockerfile new file mode 100644 index 0000000..847f78e --- /dev/null +++ b/buildcontainer/Dockerfile @@ -0,0 +1,17 @@ +FROM docker.io/library/fedora:41 + +LABEL org.opencontainers.image.base.name="docker.io/library/fedora:41" +LABEL org.opencontainers.image.source="https://github.com/python/cpython-devcontainers" +LABEL org.opencontainers.image.title="CPython build container" +LABEL org.opencontainers.image.description="CPython build container for Linux." +LABEL org.opencontainers.image.authors="Brett Cannon" + +ENV CC=clang + +# Remove a video codec repository to speed up installs. +RUN dnf config-manager setopt fedora-cisco-openh264.enabled=False + +RUN mkdir -p /opt/cpython-devcontainer/bin +COPY --chmod=755 install-builddeps.sh /opt/cpython-devcontainer/bin/ + +RUN /opt/cpython-devcontainer/bin/install-builddeps.sh diff --git a/buildcontainer/README.md b/buildcontainer/README.md new file mode 100644 index 0000000..189c6d6 --- /dev/null +++ b/buildcontainer/README.md @@ -0,0 +1,5 @@ +This container image contains everything necessary to build CPython on Linux. + +It is **not** meant for general development unless you are space-constrained. +For development you should use the +[dev container image](https://github.com/python/cpython-devcontainers/tree/main/devcontainer). diff --git a/buildcontainer/install-builddeps.sh b/buildcontainer/install-builddeps.sh new file mode 100644 index 0000000..2a26fee --- /dev/null +++ b/buildcontainer/install-builddeps.sh @@ -0,0 +1,25 @@ +#! /bin/bash -ex + +# Install build tools and CPython dependencies on Fedora. + + +# Define dependencies as an array, for easier formatting & comments. +# see: https://www.gnu.org/software/bash/manual/html_node/Arrays.html +# Contents inspired by experience and +# https://github.com/devcontainers/features/tree/main/src/common-utils . +DEPS=( + # Bare minimum + /usr/bin/{blurb,clang,git} + + # Necessary for getting Python build dependencies + 'dnf5-command(builddep)' + + # TODO: remove when Fedora version includes Python 3.14 + libzstd-devel +) + +dnf -y --nodocs --setopt=install_weak_deps=False install ${DEPS[@]} +dnf -y --nodocs --setopt=install_weak_deps=False builddep python3 + +# Don't leave caches in the container +dnf -y clean all diff --git a/devcontainer/README.md b/devcontainer/README.md new file mode 100644 index 0000000..1d5d500 --- /dev/null +++ b/devcontainer/README.md @@ -0,0 +1,8 @@ +A general dev container for developing CPython for Linux and WASI. + +See the +[devguide's container docs](https://devguide.python.org/getting-started/setup-building/#using-a-container) +on how to use this container image for development. + +If you need a smaller/minimal container image, see the +[build container](https://github.com/python/cpython-devcontainers/tree/main/buildcontainer).