Skip to content

Update alpine base image #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
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
18 changes: 17 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ on:

jobs:
bake_pyenv:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
timeout-minutes: 20
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
Expand All @@ -22,33 +23,40 @@ jobs:
swap-storage: true
-
name: Checkout
timeout-minutes: 20
uses: actions/checkout@v4
-
name: Set up QEMU
timeout-minutes: 60
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
timeout-minutes: 20
uses: docker/setup-buildx-action@v3
with:
buildkitd-config: ./buildkitd.toml
-
name: Login to DockerHub
timeout-minutes: 5
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Python
timeout-minutes: 5
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Create bakefiles
timeout-minutes: 5
run: |
export DHUBREPO=advian
./create_builds.py pyenv > pyenv.hcl

- name: Bake pyenv
timeout-minutes: 1440
run: |
docker buildx bake --pull --provenance=true --sbom=true --push --file ./pyenv.hcl
# FIXME: How to copy the buildx cache between jobs ?
Expand All @@ -57,6 +65,7 @@ jobs:
needs: bake_pyenv
steps:
- name: Free Disk Space (Ubuntu)
timeout-minutes: 20
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
Expand All @@ -70,31 +79,38 @@ jobs:
swap-storage: true
-
name: Checkout
timeout-minutes: 20
uses: actions/checkout@v4
-
name: Set up QEMU
timeout-minutes: 60
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
timeout-minutes: 20
uses: docker/setup-buildx-action@v3
with:
buildkitd-config: ./buildkitd.toml
-
name: Login to DockerHub
timeout-minutes: 5
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Python
timeout-minutes: 5
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Create bakefiles
timeout-minutes: 5
run: |
export DHUBREPO=advian
./create_builds.py tox-base > tox-base.hcl
- name: Bake pyenv
timeout-minutes: 1440
run: |
docker buildx bake --pull --provenance=true --sbom=true --push --file ./tox-base.hcl
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
# See https://pre-commit.com/hooks.html for more hooks
default_language_version:
python: python3
default_install_hook_types:
- pre-commit
- commit-msg
repos:
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.0.0
hooks:
- id: conventional-pre-commit
stages: [commit-msg]
args: []
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand Down
9 changes: 5 additions & 4 deletions Dockerfile_alpine
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apk add --no-cache \
bash \
openssh-client \
# PyEnv deps
bzip2-dev coreutils dpkg-dev dpkg expat-dev patch \
build-base bzip2-dev coreutils dpkg-dev dpkg expat-dev patch \
findutils gcc gdbm-dev libc-dev libffi-dev libnsl-dev libtirpc-dev \
linux-headers make ncurses-dev openssl-dev pax-utils readline-dev \
sqlite-dev tcl-dev tk tk-dev util-linux-dev xz-dev zlib-dev \
Expand All @@ -37,9 +37,10 @@ RUN pyenv install -l
##############################
# Build the version resolver #
##############################
FROM pyenv_clean as pyenv_resolve_build
FROM rust:1.87-alpine$IMAGE_VERSION as pyenv_resolve_build
COPY pyenv_resolve /build
RUN cd /build \
RUN apk add --no-cache musl-dev \
&& cd /build \
&& cargo build --release \
&& cargo install --path . \
&& true
Expand All @@ -48,7 +49,7 @@ RUN cd /build \
# Prebuild given versions #
###########################
FROM pyenv_clean as pyenv_prebuild
COPY --from=pyenv_resolve_build /root/.cargo /root/.cargo
COPY --from=pyenv_resolve_build /usr/local/cargo/bin/pyenv_resolve /usr/local/bin/pyenv_resolve
ARG BUILD_PYTHON_VERSIONS="3.11 3.12 3.13 3.10 3.9"
RUN export RESOLVED_VERSIONS=`pyenv_resolve $BUILD_PYTHON_VERSIONS` \
&& echo RESOLVED_VERSIONS=$RESOLVED_VERSIONS \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile_debian
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update \
bash \
curl \
ca-certificates \
git-core \
git \
make \
llvm \
build-essential \
Expand Down Expand Up @@ -44,7 +44,7 @@ RUN pyenv install -l
##############################
# Build the version resolver #
##############################
FROM pyenv_clean as pyenv_resolve_build
FROM rust:1.87-slim-$IMAGE_VERSION as pyenv_resolve_build
COPY pyenv_resolve /build
RUN cd /build \
&& cargo build --release \
Expand All @@ -55,7 +55,7 @@ RUN cd /build \
# Prebuild given versions #
###########################
FROM pyenv_clean as pyenv_prebuild
COPY --from=pyenv_resolve_build /root/.cargo /root/.cargo
COPY --from=pyenv_resolve_build /usr/local/cargo/bin/pyenv_resolve /usr/local/bin/pyenv_resolve
ARG BUILD_PYTHON_VERSIONS="3.11 3.12 3.13 3.10 3.9"
RUN export RESOLVED_VERSIONS=`pyenv_resolve $BUILD_PYTHON_VERSIONS` \
&& for pyver in $RESOLVED_VERSIONS; do pyenv install $pyver; done \
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile_ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get update \
bash \
curl \
ca-certificates \
git-core \
git \
make \
llvm \
build-essential \
Expand All @@ -40,7 +40,7 @@ RUN pyenv install -l
##############################
# Build the version resolver #
##############################
FROM pyenv_clean as pyenv_resolve_build
FROM rust:1.87-slim-bookworm as pyenv_resolve_build
COPY pyenv_resolve /build
RUN cd /build \
&& cargo build --release \
Expand All @@ -51,7 +51,7 @@ RUN cd /build \
# Prebuild given versions #
###########################
FROM pyenv_clean as pyenv_prebuild
COPY --from=pyenv_resolve_build /root/.cargo /root/.cargo
COPY --from=pyenv_resolve_build /usr/local/cargo/bin/pyenv_resolve /usr/local/bin/pyenv_resolve
ARG BUILD_PYTHON_VERSIONS="3.11 3.12 3.13 3.10 3.9"
RUN export RESOLVED_VERSIONS=`pyenv_resolve $BUILD_PYTHON_VERSIONS` \
&& for pyver in $RESOLVED_VERSIONS; do pyenv install $pyver; done \
Expand Down
10 changes: 6 additions & 4 deletions create_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@

PLATFORMS = ["linux/amd64", "linux/arm64"]
TARGETS = ["pyenv", "tox-base"]
VARIANTS = ["alpine-3.19", "debian-bullseye", "ubuntu-jammy"]
VARIANTS += ["alpine-3.20", "debian-bookworm", "ubuntu-noble"]
VARIANTS = ["alpine-3.20", "debian-bullseye", "ubuntu-jammy"]
VARIANTS += ["alpine-3.21", "debian-bookworm", "ubuntu-noble"]
# Which distro version gets the distro name tag
DISTRO_DEFAULT_VERSIONS = {
"alpine": "3.20",
"alpine": "3.21",
"debian": "bookworm",
"ubuntu": "noble",
}
BUILD_PYTHON_VERSIONS = "3.11 3.12 3.13"


def print_bakefile(reponame: str, target: str) -> None:
"""Print the bakefile"""
hcl_targets = ""
for variant in VARIANTS:
isodate = datetime.datetime.utcnow().date().isoformat()
isodate = datetime.datetime.now(datetime.UTC).date().isoformat()
distro, version = variant.split("-")
distrotag = ""
if version == DISTRO_DEFAULT_VERSIONS[distro]:
Expand All @@ -33,6 +34,7 @@ def print_bakefile(reponame: str, target: str) -> None:
target = "{target}"
args = {{
IMAGE_VERSION = "{version}"
BUILD_PYTHON_VERSIONS = "{BUILD_PYTHON_VERSIONS}"
}}
tags = [{distrotag}"{reponame}/{target}:{distro}-{version}", "{reponame}/{target}:{distro}-{version}-{isodate}"]
}}
Expand Down
42 changes: 28 additions & 14 deletions pyenv_resolve/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.