Skip to content

Commit

Permalink
Simplify docker image to only include rustup and essential system libs (
Browse files Browse the repository at this point in the history
rerun-io#5932)

### What
- Resolves: rerun-io#5906

A lot of stuff in the docker container is now in pixi or managed via
other explicit configuration steps.

The wheel-testing job was the only one that had issues. I moved the job
invocations over to pixi and introduced a new `wheel-test` pixi env to
avoid needing to pull torch into the normal pixi env.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/5932?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/5932?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/5932)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
jleibs authored Apr 12, 2024
1 parent 6861093 commit 1b432d2
Show file tree
Hide file tree
Showing 11 changed files with 2,368 additions and 202 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/contrib_rerun_py.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
name: Build Wheels
runs-on: ubuntu-latest-16-cores
container:
image: rerunio/ci_docker:0.13.0
image: rerunio/ci_docker:0.14.0
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable_build_and_upload_rerun_c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ jobs:
linux-arm64)
runner="buildjet-8vcpu-ubuntu-2204-arm"
target="aarch64-unknown-linux-gnu"
container="'rerunio/ci_docker:0.13.0'"
container="'rerunio/ci_docker:0.14.0'"
lib_name="librerun_c.a"
;;
linux-x64)
runner="ubuntu-latest-16-cores"
target="x86_64-unknown-linux-gnu"
container="'rerunio/ci_docker:0.13.0'"
container="'rerunio/ci_docker:0.14.0'"
lib_name="librerun_c.a"
;;
windows-x64)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable_build_and_upload_rerun_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ jobs:
linux-arm64)
runner="buildjet-8vcpu-ubuntu-2204-arm"
target="aarch64-unknown-linux-gnu"
container="'rerunio/ci_docker:0.13.0'"
container="'rerunio/ci_docker:0.14.0'"
bin_name="rerun"
;;
linux-x64)
runner="ubuntu-latest-16-cores"
target="x86_64-unknown-linux-gnu"
container="'rerunio/ci_docker:0.13.0'"
container="'rerunio/ci_docker:0.14.0'"
bin_name="rerun"
;;
windows-x64)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/reusable_build_and_upload_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,14 @@ jobs:
linux-arm64)
runner="buildjet-8vcpu-ubuntu-2204-arm"
target="aarch64-unknown-linux-gnu"
container="'rerunio/ci_docker:0.13.0'" # Required to be manylinux compatible
container="'rerunio/ci_docker:0.14.0'" # Required to be manylinux compatible
compat="manylinux_2_31"
;;
linux-x64)
runner="ubuntu-latest-16-cores"
target="x86_64-unknown-linux-gnu"
compat="manylinux_2_31"
container="'rerunio/ci_docker:0.13.0'" # Required to be manylinux compatible
container="'rerunio/ci_docker:0.14.0'" # Required to be manylinux compatible
;;
windows-x64)
runner="windows-latest-8-cores"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_bundle_and_upload_rerun_cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: rerunio/ci_docker:0.13.0 # Need container for arrow dependency.
image: rerunio/ci_docker:0.14.0 # Need container for arrow dependency.

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable_run_notebook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: rerunio/ci_docker:0.13.0 # Required to run the wheel or we get "No matching distribution found for attrs>=23.1.0" during `pip install rerun-sdk`
image: rerunio/ci_docker:0.14.0 # Required to run the wheel or we get "No matching distribution found for attrs>=23.1.0" during `pip install rerun-sdk`

steps:
- uses: actions/checkout@v4
Expand Down
49 changes: 12 additions & 37 deletions .github/workflows/reusable_test_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ jobs:
linux-arm64)
runner="buildjet-8vcpu-ubuntu-2204-arm"
target="aarch64-unknown-linux-gnu"
container="'rerunio/ci_docker:0.13.0'"
container="'rerunio/ci_docker:0.14.0'"
;;
linux-x64)
runner="ubuntu-latest-16-cores"
target="x86_64-unknown-linux-gnu"
container="'rerunio/ci_docker:0.13.0'"
container="'rerunio/ci_docker:0.14.0'"
;;
windows-x64)
runner="windows-latest-8-cores"
Expand Down Expand Up @@ -147,66 +147,41 @@ jobs:
with:
pixi-version: v0.18.0

# The pip-cache setup logic doesn't work in the ubuntu docker container
# That's probably fine since we bake these deps into the container already
- name: Setup python
if: ${{ inputs.PLATFORM != 'linux-x64' }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
cache: "pip"
cache-dependency-path: "scripts/ci/requirements.txt"

# These should already be in the docker container, but run for good measure. A no-op install
# should be fast, and this way things don't break if we add new packages without rebuilding
# docker
- run: pip install -r scripts/ci/requirements.txt
shell: bash

- name: Download Wheel
uses: actions/download-artifact@v4
with:
name: ${{ inputs.WHEEL_ARTIFACT_NAME }}
path: wheel

- name: Install wheel dependencies
# First we install the dependencies manually so we can use `--no-index` when installing the wheel.
# This needs to be a separate step for some reason or the following step fails
# TODO(jleibs): pull these deps from pyproject.toml
# TODO(jleibs): understand why deps can't be installed in the same step as the wheel
shell: bash
run: |
pip install attrs>=23.1.0 'numpy>=1.23,<2' pillow pyarrow>=14.0.2 pytest==7.1.2 torch==2.1.0 typing_extensions>=4.5
- name: Get version
id: get-version
shell: bash
run: |
echo "wheel_version=$(python3 scripts/ci/crates.py get-version)" >> "$GITHUB_OUTPUT"
echo "wheel_version=$(pixi run scripts/ci/crates.py get-version)" >> "$GITHUB_OUTPUT"
- name: Install built wheel
# Now install the wheel using a specific version and --no-index to guarantee we get the version from
# the pre-dist folder. Note we don't use --force-reinstall here because --no-index means it wouldn't
# find the dependencies to reinstall them.
shell: bash
run: |
pip uninstall rerun-sdk
pip install rerun-sdk==${{ steps.get-version.outputs.wheel_version }} --no-index --find-links wheel
pixi run -e wheel-test pip uninstall rerun-sdk
pixi run -e wheel-test pip install rerun-sdk==${{ steps.get-version.outputs.wheel_version }} --no-index --find-links wheel
- name: Verify built wheel version
shell: bash
run: |
python3 -m rerun --version
which rerun
rerun --version
pixi run -e wheel-test python -m rerun --version
pixi run -e wheel-test which rerun
pixi run -e wheel-test rerun --version
- name: Run unit tests
shell: bash
run: cd rerun_py/tests && pytest -c ../pyproject.toml
run: cd rerun_py/tests && pixi run -e wheel-test pytest -c ../pyproject.toml

- name: Run e2e test
shell: bash
run: RUST_LOG=debug scripts/run_python_e2e_test.py --no-build # rerun-sdk is already built and installed
run: pixi run -e wheel-test RUST_LOG=debug scripts/run_python_e2e_test.py --no-build # rerun-sdk is already built and installed

- name: Run tests/roundtrips.py
if: ${{ inputs.PLATFORM != 'windows-x64' && !inputs.FAST }}
Expand All @@ -215,7 +190,7 @@ jobs:
# --target x86_64-unknown-linux-gnu because otherwise cargo loses the target cache… even though this is the target anyhow…
# --no-py-build because rerun-sdk is already built and installed
run: |
RUST_LOG=debug tests/roundtrips.py --release --target x86_64-unknown-linux-gnu --no-py-build
pixi run -e wheel-test RUST_LOG=debug tests/roundtrips.py --release --target x86_64-unknown-linux-gnu --no-py-build
- name: Run docs/snippets/compare_snippet_output.py
if: ${{ inputs.PLATFORM != 'windows-x64' && !inputs.FAST }}
Expand All @@ -224,4 +199,4 @@ jobs:
# --target x86_64-unknown-linux-gnu because otherwise cargo loses the target cache… even though this is the target anyhow…
# --no-py-build because rerun-sdk is already built and installed
run: |
RUST_LOG=debug docs/snippets/compare_snippet_output.py --release --target x86_64-unknown-linux-gnu --no-py-build
pixi run -e wheel-test RUST_LOG=debug docs/snippets/compare_snippet_output.py --release --target x86_64-unknown-linux-gnu --no-py-build
73 changes: 5 additions & 68 deletions ci_docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM ubuntu:20.04
LABEL maintainer="[email protected]"
# Remember to update the version in publish.sh
# TODO(jleibs) use this version in the publish.sh script and below in the CACHE_KEY
LABEL version="0.13.0"
LABEL version="0.14.0"
LABEL description="Docker image used for the CI of https://github.com/rerun-io/rerun"

# Install the ubuntu package dependencies
Expand Down Expand Up @@ -37,78 +37,15 @@ RUN set -eux; \
sudo; \
rm -rf /var/lib/apt/lists/*;

# Need a more recent pip for manylinux packages to work properly
RUN python3 -m pip install -U pip

# Need a more recent clang-format for codegen
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && \
apt update -y && \
apt upgrade -y && \
wget https://apt.llvm.org/llvm.sh && \
chmod +x llvm.sh && \
./llvm.sh 15 && \
apt-get install clang-format-15 && \
ln -sf clang-format-15 /usr/bin/clang-format && \
rm -rf /var/lib/apt/lists/*;

# Need a more recent flatbuffers for codegen
RUN git clone --depth 1 --branch v23.5.9 https://github.com/google/flatbuffers.git && \
cd flatbuffers && \
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release && \
make -j4 && \
make install && \
cd .. && rm -rf flatbuffers


# We need a more modern patchelf than ships on ubuntu-20.04
RUN arch=$(if [ "$TARGETARCH" = "arm64" ]; then echo "aarch64"; else echo "x86_64"; fi) && \
curl --fail -L https://github.com/NixOS/patchelf/releases/download/0.17.2/patchelf-0.17.2-${arch}.tar.gz | tar -xz ./bin/patchelf

# TODO(andreas): Update cargo-deny below when updating rust version to 1.70.0 or above!
ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH \
RUST_VERSION=1.76.0 \
RUSTUP_VERSION=1.26.0

# Install Rust
# Borrowed from: https://github.com/rust-lang/docker-rust/blob/a8a2a9d/1.71.0/bookworm/Dockerfile
RUN arch=$(if [ "$TARGETARCH" = "arm64" ]; then echo "aarch64"; else echo "x86_64"; fi) && \
set -eux; \
rustArch="${arch}-unknown-linux-gnu"; \
rustupSha256=$(if [ "$TARGETARCH" = "arm64" ]; then echo "673e336c81c65e6b16dcdede33f4cc9ed0f08bde1dbe7a935f113605292dc800"; else echo "0b2f6c8f85a3d02fde2efc0ced4657869d73fccfce59defb4e8d29233116e6db"; fi); \
url="https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${rustArch}/rustup-init"; \
wget "$url"; \
echo "${rustupSha256} *rustup-init" | sha256sum -c -; \
chmod +x rustup-init; \
./rustup-init -y --no-modify-path --profile default --default-toolchain $RUST_VERSION --default-host ${rustArch}; \
rm rustup-init; \
chmod -R a+w $RUSTUP_HOME $CARGO_HOME; \
rustup --version; \
cargo --version; \
rustc --version;

# Install stuff from `rust-toolchain`
ADD rust-toolchain rust-toolchain
# `show` is currently the only way to install whatever is in `rust-toolchain`
# This is subject to change, but there is no alternative: https://github.com/rust-lang/rustup/issues/1397
RUN rustup show

# Install some cargo tools we know we'll always need
# We can't do this until after we've installed rust / cargo above
# Latest cargo-deny requires a rust update!
RUN cargo install [email protected]
RUN cargo install cargo-cranky
RUN cargo install cargo-benchcmp
PATH=/usr/local/cargo/bin:$PATH

# Install the python build dependencies
ADD rerun_py/requirements-build.txt requirements-build.txt
RUN pip install -r requirements-build.txt
ADD rerun_py/requirements-lint.txt requirements-lint.txt
RUN pip install -r requirements-lint.txt
# Install Rustup
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Increment this to invalidate cache
ENV CACHE_KEY=rerun_docker_v0.13.0
ENV CACHE_KEY=rerun_docker_v0.14.0

# See: https://github.com/actions/runner-images/issues/6775#issuecomment-1410270956
RUN git config --system --add safe.directory '*'
Expand Down
2 changes: 1 addition & 1 deletion ci_docker/publish.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
set -eux

VERSION=0.13.0 # Bump on each new version. Remember to update the version in the Dockerfile too.
VERSION=0.14.0 # Bump on each new version. Remember to update the version in the Dockerfile too.

# The build needs to run from top of repo to access the requirements.txt
cd `git rev-parse --show-toplevel`
Expand Down
Loading

0 comments on commit 1b432d2

Please sign in to comment.