mirror of
https://github.com/OPM/opm-simulators.git
synced 2026-11-05 21:57:18 -06:00
This enhancement allows specifying which Python versions to install during Docker image builds, significantly reducing build times when only testing specific Python versions during debugging. Changes: - Add --python-versions option to build-docker-image command - Pass BUILD_PYTHON_VERSIONS build argument to Docker - Update install_python_versions.py to respect BUILD_PYTHON_VERSIONS env var - Validate requested versions against supported versions in python_versions.json - Maintain backward compatibility (installs all versions if not specified) Usage examples: # Build with only Python 3.12 (much faster for debugging) opm-wheels build-docker-image --docker-os="ubuntu-24.04" --python-versions="3.12" # Build with multiple specific versions omp-wheels build-docker-image --python-versions="3.11,3.12" # Build with all versions (original behavior) opm-wheels build-docker-image Benefits: - Reduces build time from ~7 minutes to ~2 minutes for single Python version - Enables faster iteration during debugging of Docker-specific issues - Particularly valuable when combined with --test-cases-* for focused testing
45 lines
1.5 KiB
Docker
45 lines
1.5 KiB
Docker
FROM debian:11
|
|
|
|
# Set build-time and runtime environment
|
|
# Avoid user-interaction prompts when installing packages.
|
|
ARG DEBIAN_FRONTEND=noninteractive
|
|
ENV DEBIAN_FRONTEND=${DEBIAN_FRONTEND}
|
|
ENV TZ=Etc/UTC
|
|
ENV PYENV_ROOT=/root/.pyenv
|
|
ENV PATH="${PYENV_ROOT}/bin:${PYENV_ROOT}/shims:${PATH}"
|
|
|
|
WORKDIR /test
|
|
|
|
# Make all scripts in the common folder available
|
|
COPY test_wheels/dockerfiles/common/ /test/common/
|
|
# Copy python_versions.json to the expected location
|
|
COPY python_versions.json /test/python_versions.json
|
|
|
|
RUN /test/common/setup_apt.sh
|
|
RUN /test/common/setup_pyenv.sh
|
|
|
|
# Switch to bash for pyenv usage
|
|
SHELL ["/bin/bash", "-c"]
|
|
|
|
# Accept Python versions build argument and set as environment variable
|
|
ARG BUILD_PYTHON_VERSIONS
|
|
ENV BUILD_PYTHON_VERSIONS=${BUILD_PYTHON_VERSIONS}
|
|
|
|
RUN /usr/bin/python3 /test/common/install_python_versions.py
|
|
|
|
# Clone opm-common and opm-simulators to get the unit tests
|
|
ARG OPM_COMMON_REPO=https://github.com/OPM/opm-common.git
|
|
ARG OPM_SIMULATORS_REPO=https://github.com/OPM/opm-simulators.git
|
|
ARG OPM_COMMON_BRANCH=master
|
|
ARG OPM_SIMULATORS_BRANCH=master
|
|
ENV OPM_COMMON_REPO=${OPM_COMMON_REPO}
|
|
ENV OPM_SIMULATORS_REPO=${OPM_SIMULATORS_REPO}
|
|
ENV OPM_COMMON_BRANCH=${OPM_COMMON_BRANCH}
|
|
ENV OPM_SIMULATORS_BRANCH=${OPM_SIMULATORS_BRANCH}
|
|
RUN /test/common/clone_opm_repos.sh
|
|
|
|
# Entrypoint: use unbuffered mode so logs appear in order
|
|
ENTRYPOINT ["/usr/bin/python3", "-u", "/test/common/entrypoint.py"]
|
|
# No default arguments passed to entrypoint
|
|
CMD []
|