-
Notifications
You must be signed in to change notification settings - Fork 356
feat: Build docker image with both amd64 and arm64 support #10882
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
Draft
heliocastro
wants to merge
3
commits into
main
Choose a base branch
from
feat/docker_multiarch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -115,56 +115,53 @@ | |
| ENTRYPOINT [ "/bin/bash" ] | ||
|
|
||
| #------------------------------------------------------------------------ | ||
| # PYTHON - Build Python as a separate component with pyenv | ||
| FROM base AS pythonbuild | ||
| # PYTHON - Install Python binaries from astral-sh | ||
| FROM base AS python_install | ||
|
||
|
|
||
| ARG CONAN_VERSION | ||
| ARG CONAN2_VERSION | ||
| ARG CONAN_VERSION | ||
| ARG PIP_VERSION | ||
| ARG PYENV_GIT_TAG | ||
| ARG PYTHON_INSPECTOR_VERSION | ||
| ARG PYTHON_PIPENV_VERSION | ||
| ARG PYTHON_POETRY_PLUGIN_EXPORT_VERSION | ||
| ARG PYTHON_POETRY_VERSION | ||
| ARG PYTHON_SETUPTOOLS_VERSION | ||
| ARG PYTHON_VERSION | ||
| ARG SCANCODE_VERSION | ||
| ARG UV_VERSION | ||
|
|
||
| SHELL ["/bin/bash", "-o", "pipefail", "-c"] | ||
|
|
||
| ENV PYTHON_INSTALL_ROOT=/opt/python | ||
| ENV PATH=$PATH:$PYTHON_INSTALL_ROOT/bin:$PYTHON_INSTALL_ROOT/conan2/bin | ||
|
|
||
| RUN ARCH=$(arch | sed s/aarch64/arm64/) \ | ||
| && astral_release="20250918" \ | ||
| && download_url="https://github.com/astral-sh/python-build-standalone/releases/download/${astral_release}" \ | ||
| && mkdir -p $PYTHON_INSTALL_ROOT \ | ||
| && arch="x86_64" \ | ||
| && if [ "$ARCH" == "arm64" ]; then \ | ||
| arch="aarch64"; \ | ||
| fi \ | ||
| && curl -L "${download_url}/cpython-${PYTHON_VERSION}+${astral_release}-${arch}-unknown-linux-gnu-install_only_stripped.tar.gz" | tar -C /opt -xz | ||
|
|
||
| # This is required mostly because scancode-mini requirements | ||
| RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ | ||
| --mount=type=cache,target=/var/lib/apt,sharing=locked \ | ||
| sudo apt-get update -qq \ | ||
| && DEBIAN_FRONTEND=noninteractive sudo apt-get install -y --no-install-recommends \ | ||
| libreadline-dev \ | ||
| libgdbm-dev \ | ||
| libsqlite3-dev \ | ||
| libssl-dev \ | ||
| libbz2-dev \ | ||
| liblzma-dev \ | ||
| tk-dev \ | ||
| libicu-dev \ | ||
| pkg-config \ | ||
| clang \ | ||
| && sudo rm -rf /var/lib/apt/lists/* | ||
|
|
||
| ENV PYENV_ROOT=/opt/python | ||
| ENV PATH=$PATH:$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PYENV_ROOT/conan2/bin | ||
| RUN curl -kSs https://pyenv.run | bash \ | ||
| && pyenv install -v $PYTHON_VERSION \ | ||
| && pyenv global $PYTHON_VERSION | ||
|
|
||
| RUN ARCH=$(arch | sed s/aarch64/arm64/) \ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To work on Mac you also need to manually install click in version 8.2.1 |
||
| && if [ "$ARCH" == "arm64" ]; then \ | ||
| && if [ "$ARCH" == "arm64" ]; then \ | ||
| pip install -U scancode-toolkit-mini==$SCANCODE_VERSION; \ | ||
| else \ | ||
| curl -Os https://raw.githubusercontent.com/nexB/scancode-toolkit/v$SCANCODE_VERSION/requirements.txt; \ | ||
| pip install -U --constraint requirements.txt scancode-toolkit==$SCANCODE_VERSION setuptools==$PYTHON_SETUPTOOLS_VERSION; \ | ||
| rm requirements.txt; \ | ||
| pip install -U scancode-toolkit==$SCANCODE_VERSION; \ | ||
| fi | ||
|
|
||
| # Extract ScanCode license texts to a directory. | ||
| RUN scancode-license-data --path /opt/scancode-license-data \ | ||
| && find /opt/scancode-license-data -type f -not -name "*.LICENSE" -exec rm -f {} + \ | ||
| && rm -rf /opt/scancode-license-data/static | ||
|
|
||
| RUN pip install --no-cache-dir -U \ | ||
| pip=="$PIP_VERSION" \ | ||
| wheel \ | ||
|
|
@@ -175,19 +172,25 @@ | |
| poetry=="$PYTHON_POETRY_VERSION" \ | ||
| poetry-plugin-export=="$PYTHON_POETRY_PLUGIN_EXPORT_VERSION" \ | ||
| python-inspector=="$PYTHON_INSPECTOR_VERSION" \ | ||
| setuptools=="$PYTHON_SETUPTOOLS_VERSION" | ||
| RUN mkdir /tmp/conan2 && cd /tmp/conan2 \ | ||
| && wget https://github.com/conan-io/conan/releases/download/$CONAN2_VERSION/conan-$CONAN2_VERSION-linux-x86_64.tgz \ | ||
| && tar -xvf conan-$CONAN2_VERSION-linux-x86_64.tgz\ | ||
| setuptools=="$PYTHON_SETUPTOOLS_VERSION" \ | ||
| uv="$UV_VERSION" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| # # Extract ScanCode license texts to a directory. | ||
| # RUN ARCH=$(arch | sed s/aarch64/arm64/) \ | ||
| # if [ "$ARCH" == "arm64" ]; then \ | ||
| # echo "Not av ailable for Arm due distutils problem"; | ||
| # else \ | ||
| # scancode-license-data --path /opt/scancode-license-data; \ | ||
| # find /opt/scancode-license-data -type f -not -name "*.LICENSE" -exec rm -f {} + \; \ | ||
| # fi | ||
|
|
||
| RUN mkdir -p $PYTHON_INSTALL_ROOT/conan2 \ | ||
| && curl -L https://github.com/conan-io/conan/releases/download/$CONAN2_VERSION/conan-$CONAN2_VERSION-linux-x86_64.tgz | tar -C $PYTHON_INSTALL_ROOT/conan2 -zvx bin \ | ||
| # Rename the Conan 2 executable to "conan2" to be able to call both Conan version from the package manager. | ||
| && mkdir $PYENV_ROOT/conan2 && mv /tmp/conan2/bin $PYENV_ROOT/conan2/ \ | ||
| && mv $PYENV_ROOT/conan2/bin/conan $PYENV_ROOT/conan2/bin/conan2 | ||
| && mv $PYTHON_INSTALL_ROOT/conan2/bin/conan $PYTHON_INSTALL_ROOT/conan2/bin/conan2 | ||
|
|
||
| FROM scratch AS python | ||
| COPY --from=pythonbuild /opt/python /opt/python | ||
|
|
||
| FROM scratch AS scancode-license-data | ||
| COPY --from=pythonbuild /opt/scancode-license-data /opt/scancode-license-data | ||
| COPY --from=python_install /opt/python /opt/python | ||
|
|
||
| #------------------------------------------------------------------------ | ||
| # NODEJS - Build NodeJS as a separate component with nvm | ||
|
|
@@ -483,9 +486,9 @@ | |
| && sudo rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Python | ||
| ENV PYENV_ROOT=/opt/python | ||
| ENV PATH=$PATH:$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PYENV_ROOT/conan2/bin | ||
| COPY --from=python --chown=$USER:$USER $PYENV_ROOT $PYENV_ROOT | ||
| ENV PYTHON_INSTALL_ROOT=/opt/python | ||
| ENV PATH=$PATH:$PYTHON_INSTALL_ROOT/shims:$PYTHON_INSTALL_ROOT/bin:$PYTHON_INSTALL_ROOT/conan2/bin | ||
| COPY --from=python --chown=$USER:$USER $PYTHON_INSTALL_ROOT $PYTHON_INSTALL_ROOT | ||
|
|
||
| # NodeJS | ||
| ENV NVM_DIR=/opt/nvm | ||
|
|
@@ -510,8 +513,6 @@ | |
| ENV PATH=$PATH:$RBENV_ROOT/bin:$RBENV_ROOT/shims:$RBENV_ROOT/plugins/ruby-install/bin | ||
| COPY --from=ruby --chown=$USER:$USER $RBENV_ROOT $RBENV_ROOT | ||
|
|
||
| COPY --from=scancode-license-data --chown=$USER:$USER /opt/scancode-license-data /opt/scancode-license-data | ||
|
|
||
| #------------------------------------------------------------------------ | ||
| # Container with all supported package managers. | ||
| FROM minimal-tools AS all-tools | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.