Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 33 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ on:
# a branch named ubuntu-<RELEASE> (RELEASE per the Dockerfile): ubuntu-<RELEASE>* only, so the image for an
# Ubuntu release other than main's can be built and tested without touching canary
# any other branch named ubuntu-*: the build fails fast, since it would otherwise publish nothing
# any other branch: canary*
# any other branch: canary*; <branch>* (with / replaced by -), so a dependent can pin to one branch's
# image, e.g. cs50/cli:python-3.15, without canary moving under it
# where * means the -amd64 and -arm64 tags plus a multi-arch manifest.

jobs:
Expand All @@ -28,7 +29,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: "3.14"
python-version: "3.15"

- name: Build for linux/amd64
uses: docker/build-push-action@v7
Expand Down Expand Up @@ -70,6 +71,15 @@ jobs:
run: |
docker push cs50/cli:canary-amd64

- name: Push linux/amd64 build to Docker Hub (${{ github.ref_name }})
if: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/heads/ubuntu-') }}
env:
BRANCH: ${{ github.ref_name }}
run: |
tag="${BRANCH//\//-}"
docker tag cs50/cli:canary-amd64 cs50/cli:"$tag"-amd64
docker push cs50/cli:"$tag"-amd64

- name: Push linux/amd64 build to Docker Hub (ubuntu-${{ steps.release.outputs.release }})
if: ${{ github.ref == 'refs/heads/main' || github.ref == format('refs/heads/ubuntu-{0}', steps.release.outputs.release) }}
env:
Expand All @@ -93,7 +103,7 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: "3.14"
python-version: "3.15"

- name: Build for linux/arm64
uses: docker/build-push-action@v7
Expand Down Expand Up @@ -135,6 +145,15 @@ jobs:
run: |
docker push cs50/cli:canary-arm64

- name: Push linux/arm64 build to Docker Hub (${{ github.ref_name }})
if: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/heads/ubuntu-') }}
env:
BRANCH: ${{ github.ref_name }}
run: |
tag="${BRANCH//\//-}"
docker tag cs50/cli:canary-arm64 cs50/cli:"$tag"-arm64
docker push cs50/cli:"$tag"-arm64

- name: Push linux/arm64 build to Docker Hub (ubuntu-${{ steps.release.outputs.release }})
if: ${{ github.ref == 'refs/heads/main' || github.ref == format('refs/heads/ubuntu-{0}', steps.release.outputs.release) }}
env:
Expand Down Expand Up @@ -171,6 +190,17 @@ jobs:
--amend cs50/cli:canary-arm64
docker manifest push cs50/cli:canary

- name: Create multi-arch manifest and push to Docker Hub (${{ github.ref_name }})
if: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/heads/ubuntu-') }}
env:
BRANCH: ${{ github.ref_name }}
run: |
tag="${BRANCH//\//-}"
docker manifest create cs50/cli:"$tag" \
--amend cs50/cli:"$tag"-amd64 \
--amend cs50/cli:"$tag"-arm64
docker manifest push cs50/cli:"$tag"

- name: Create multi-arch manifest and push to Docker Hub (ubuntu-${{ env.RELEASE }})
if: ${{ github.ref == 'refs/heads/main' || github.ref == format('refs/heads/ubuntu-{0}', needs.build-amd64.outputs.release) }}
run: |
Expand Down
24 changes: 16 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,28 @@ RUN apt update && \
build-essential ca-certificates curl git \
libssl-dev libbz2-dev libreadline-dev libsqlite3-dev \
llvm libncursesw5-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
libmpdec-dev `# For _decimal; 3.15 no longer falls back to the bundled copy` \
make tk-dev unzip wget xz-utils zlib1g-dev


# Install Python 3.14.x
# Install Python 3.15.x
# https://www.python.org/downloads/
# A single ./configure: a second bare one used to regenerate the Makefile with default
# flags, silently dropping --enable-optimizations, --enable-shared, and --with-lto.
# --disable-test-modules is the real flag for leaving out Lib/test and the _test*
# extension modules; --without-tests and --disable-static were never CPython options
# (configure warned "unrecognized options" and shipped the 176 MB test suite).
RUN cd /tmp && \
curl --remote-name https://www.python.org/ftp/python/3.14.10/Python-3.14.10.tgz && \
tar xzf Python-3.14.10.tgz && \
rm --force Python-3.14.10.tgz && \
cd Python-3.14.10 && \
CFLAGS="-Os" ./configure --disable-static --enable-optimizations --enable-shared --with-lto --without-tests && \
./configure && \
curl --remote-name https://www.python.org/ftp/python/3.15.2/Python-3.15.2.tgz && \
tar xzf Python-3.15.2.tgz && \
rm --force Python-3.15.2.tgz && \
cd Python-3.15.2 && \
CFLAGS="-Os" ./configure --disable-test-modules --enable-optimizations --enable-shared --with-lto && \
make && \
make install && \
ldconfig `# libpython is now a shared library in /usr/local/lib` && \
cd .. && \
rm --force --recursive Python-3.14.10 && \
rm --force --recursive Python-3.15.2 && \
ln --relative --symbolic /usr/local/bin/pip3 /usr/local/bin/pip && \
ln --relative --symbolic /usr/local/bin/python3 /usr/local/bin/python && \
pip3 install --no-cache-dir --upgrade "pip>=26.2.2" `# GHSA-6q48-6c7w-9gw2`
Expand Down Expand Up @@ -154,6 +160,7 @@ RUN userdel --force --remove ubuntu && \
# Copy files from builder
COPY --from=builder /opt /opt
COPY --from=builder /usr/local /usr/local
RUN ldconfig `# For libpython3.x.so in /usr/local/lib`


# Avoid "delaying package configuration, since apt-utils is not installed"
Expand Down Expand Up @@ -212,6 +219,7 @@ RUN apt update && \
libclang-rt-21-dev `# For clang` \
liblapack3 `# For R` \
libmagic-dev `# For style50` \
libmpdec4 `# Runtime package for Python's _decimal` \
libncurses-dev \
libpango-1.0-0 libharfbuzz0b libpangoft2-1.0-0 `# For render50` \
libpangocairo-1.0-0 `# For R` \
Expand Down
18 changes: 15 additions & 3 deletions tests/smoke.sh
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,31 @@ run "$IMAGE" bash --login -c '
help50 is-enabled > /dev/null && test "$(help50 status)" = started || exit 1
'

echo "- Python is 3.14 and the CS50 Python tools run"
echo "- Python is 3.15, built with the configure flags the Dockerfile asks for, and the CS50 Python tools run"
run "$IMAGE" bash --login -c '
python --version | grep -q "^Python 3\.14\." || { echo "unexpected $(python --version)" >&2; exit 1; }
python --version | grep -q "^Python 3\.15\." || { echo "unexpected $(python --version)" >&2; exit 1; }
test "$(type -P python)" = /usr/local/bin/python || exit 1

# The optimization flags survived configure (a second bare ./configure used to discard them, leaving
# a default static build), and the shared libpython the final stage copies in is what python links to
python -c "import sysconfig, sys; a = sysconfig.get_config_var(\"CONFIG_ARGS\"); missing = [f for f in (\"--enable-optimizations\", \"--enable-shared\", \"--with-lto\") if f not in a]; sys.exit(f\"CONFIG_ARGS lacks {missing}: {a}\" if missing else 0)" || exit 1
python -c "import sysconfig, sys; sys.exit(0 if sysconfig.get_config_var(\"Py_ENABLE_SHARED\") == 1 else \"Py_ENABLE_SHARED is not 1\")" || exit 1
ldd /usr/local/bin/python3 | grep -q "libpython3.15.so.1.0 => /usr/local/lib/" || { echo "python3 does not resolve libpython from /usr/local/lib:"; ldd /usr/local/bin/python3; exit 1; } >&2

# --disable-test-modules took effect (the old --without-tests was not a CPython option and shipped 176 MB of tests)
test ! -d /usr/local/lib/python3.15/test || { echo "Lib/test is installed; --disable-test-modules did not take effect" >&2; exit 1; }
python -c "import _testcapi" 2> /dev/null && { echo "_testcapi is installed; --disable-test-modules did not take effect" >&2; exit 1; }

# Every entry point imports and parses its arguments; print its output on failure
for c in check50 submit50 compare50 style50 cli50 render50 flask autopep8 pytest; do
out=$("$c" --help 2>&1) || { printf "%s --help failed:\n%s\n" "$c" "$out" >&2; exit 1; }
done

# Extension modules CPython was built against in the builder stage resolve in the final stage
# (decimal: 3.15 builds _decimal only against a system libmpdec, which the builder installs)
python -c "import cs50, flask, flask_session, cachelib, numpy" || exit 1
python -c "import bz2, ctypes, curses, lzma, readline, sqlite3, ssl, zlib" || exit 1
python -c "import bz2, ctypes, curses, decimal, lzma, readline, sqlite3, ssl, zlib" || exit 1
python -c "import decimal, sys; sys.exit(0 if decimal.__name__ and \"_decimal\" in sys.modules else \"decimal is the pure-Python fallback, _decimal did not build\")" || exit 1

# Security floors pinned in the Dockerfile are what the image carries
pip install --quiet --no-index --dry-run "pip>=26.2.2" "certifi>=2026.10.19" || { echo "pip/certifi below pinned floor" >&2; exit 1; }
Expand Down