-
Notifications
You must be signed in to change notification settings - Fork 7
Stabilize and automate the dev container build #54
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
Conversation
This commit resolves a series of build and runtime errors to create a stable,
portable, and fully automated dev container environment that works on both
`arm64` and `x86_64` architectures out-of-the-box.
- Stabilize Dockerfile Build:
- Upgrades the base image from `bullseye` to `bookworm`.
- Consolidates all `apt-get` dependencies into a single, correctly ordered
layer, installing necessary tools for cross-compilation
(`gcc-x86-64-linux-gnu`, `libc6-dev-amd64-cross`).
- Fixes `rustup` permission errors by installing the toolchain as `root`
and granting ownership to the `vscode` user.
- Adds `--break-system-packages` to the `pip install` command to comply
with Debian `bookworm`'s package management policies.
- Improve Architecture Portability:
- Makes the `bin/build` and `bin/test` scripts architecture-aware, allowing
them to run seamlessly on both `arm64` and `x86_64` hosts without manual
configuration.
- Fixes a bug that caused inconsistent naming of the shared library (`.so`)
file between build and test runs.
- Fix Container Startup on ARM64:
- Centralizes QEMU and `binfmt` setup within the `Dockerfile` build,
creating an architecture-aware initialization process.
- This allows for the removal of legacy, conflicting setup methods that
caused startup failures on `arm64` hosts:
- Removes the privileged `docker run` command for `qemu-user-static`
from the `postCreate` script.
- Disables the redundant QEMU setup in the `docker-in-docker` feature
by configuring `install-qemu: false` for the feature.
This commit implements a small refactor to make the dev container setup more resilient and truly multi-platform. - Installs `aarch64` cross-compilation packages (`gcc-aarch64-linux-gnu`, `libc6-dev-arm64-cross`) in the `Dockerfile` to enable building for ARM64 on x86_64 hosts. - Updates `bin/build-arch` to use the correct `strip` binary (native or cross-compile) by checking both the host and target architectures. - Adds a 30-second timeout to the `postCreate` script to prevent it from hanging if the Docker daemon fails to start. - Adds a comment to `bin/test` clarifying why language runtime tests are now enabled for all architectures. - Merges the `update-alternatives` command into the main `RUN` layer, reducing the total number of image layers.
This commit updates the CI configuration to resolve build failures and align the test environments with modern, supported versions. - Replaces deprecated `ubuntu-20.04` runners with `ubuntu-22.04` in the GitHub Actions workflow, fixing the hanging jobs. - Adds QEMU and Docker Buildx to `arm64` jobs to enable cross-platform image builds. - Upgrades the Debian test environment from a Bullseye-based image to a Bookworm-based one, and updates Node.js from v18 to v22 (LTS). - Updates the Python 2.7 test environment to use an `ubuntu:22.04` base image and installs Python 2.7 via the `deadsnakes` PPA.
|
Once you get tests passing, I’ll look into it this. It’s going to take a bit to test since you are updating rust I want to make sure it doesn’t break anything. |
|
This also seems like a lot of code for not too much gain. If you want to update rust then have that as a PR. If you want to add Amazon Linux 2023 have that as a new PR. Seems like you just let AI go wild and told it to update all the things. Separating these features out makes it easier to test and also review. |
|
Closing for now, I appreciate the effort but it’s doing a bit too much at once. I don’t want to get kicked from the free GitHub actions tier running tests this frequently. Feel free to open smaller, targeted PRs. Again thank you for the effort. |
Summary
This pull request overhauls the project's
.devcontainerenvironment to create a stable, fully automated, and multi-platform development experience. While the initial motivation was to upgrade the base image from Debian Bullseye to Bookworm, the process revealed several underlying issues with the existing setup that required manual intervention and failed completely onarm64(Apple Silicon) architectures.These changes ensure that any developer on a modern
arm64orx86_64machine can clone the repository, rundevcontainer up, and have a working, buildable, and testable environment with zero manual configuration.Key Problems Addressed
Dockerfilewas inefficient, had out-of-date package names, and suffered fromrustuppermission errors that prevented a clean build.arm64hosts due to a series ofexec format errorissues. The build and test scripts also had hardcoded defaults and inconsistent logic that broke thearm64test workflow.postCreateCommandscript used a legacy pattern to configure multi-architecture support that was the root cause of the startup failures onarm64machines.Solutions and Technical Details
This PR implements a holistic solution by modernizing the
Dockerfile, making the build scripts intelligent, and refactoring the container startup process.1.
DockerfileStabilizationThe
Dockerfilewas completely refactored to be more efficient and robust:mcr.microsoft.com/devcontainers/rust:2-1-bookworm.apt-getpackages are installed in a single, correctly ordered layer. This includes addinggcc-x86-64-linux-gnuandlibc6-dev-amd64-crossto fully support cross-compilation of C-based crates likering.rustupPermissions: The Rust toolchain is now installed asrootduring the image build, and ownership of the/usr/local/rustupand/usr/local/cargodirectories is then granted to thevscodeuser. This provides a clean and reliable toolchain setup.pipCompatibility: Added the--break-system-packagesflag topip installto comply with Debian Bookworm's new policies on externally managed environments.2. Architecture-Aware Build and Test Scripts
The build and test scripts are now portable:
bin/buildandbin/testscripts now auto-detect the container's architecture usinguname -m.CRYPTEIA_BUILD_TARGETandCRYPTEIA_BUILD_SUFFIXare set correctly, whether the container is running on anarm64orx86_64host..sofile was built with one name but the test suite looked for another, causingLD_PRELOADfailures.3. Modernizing the QEMU and
binfmtSetupThis was the most critical fix for
arm64stability. The original setup used an outdated pattern that is not reliable in modern container environments.The "Old Pattern" (in
postCreate): ThepostCreatescript previously randocker run --privileged multiarch/qemu-user-static. This was a common workaround to register QEMU's handlers with the host kernel'sbinfmt_miscservice. The logic was that aDockerfilebuild is sandboxed and cannot interact with the kernel, so a privileged, running container had to do it after startup. The fatal flaw in this pattern is that this secondary container did not inherit the parent's architecture settings, causing it to pull anamd64image on anarm64host and fail.The "New Pattern" (in
Dockerfile): We now handle this entirely within theDockerfile. By installing theqemu-user-staticandbinfmt-supportpackages and runningupdate-binfmts, we prepare the image with all the necessary tools. Modern container runtimes like Docker Desktop and OrbStack are smart enough to use these tools to correctly configure the host kernel when the container starts. This approach is more reliable, self-contained, and completely avoids the architecture mismatch that was causing the startup failure.As a result, we were able to disable the conflicting QEMU setup in the
docker-in-dockerfeature ("install-qemu": false) and remove the legacypostCreatecommand, leading to a much cleaner and more robust startup sequence.