Commit 36d35fe
Development setup script and analogous
* feat: Create script to set up cetmodules development environment
This script automates the setup of a development environment for
cetmodules on Ubuntu and AlmaLinux. It performs the following steps:
- Detects the operating system (Ubuntu or AlmaLinux) and uses the
appropriate package manager.
- Installs system dependencies such as git, doxygen, graphviz, and
build tools.
- Sets up a Python virtual environment and installs CMake, Sphinx, and
other required Python packages.
- Clones the Catch2 repository, builds it, and installs it.
- Clones the cetmodules repository, configures the build with
documentation enabled, builds the project, and runs the tests.
- Builds the cetmodules documentation.
* Prelims for container definition
* feat(dev): Add Docker-based development environment
Adds a Dockerfile and instructions for building and running a containerized development environment for cetmodules.
The new configuration, located in `dev/container/`, provides a consistent and reproducible environment with all necessary dependencies installed. It is configured to support an out-of-source build workflow and includes a non-root user to avoid file ownership issues when mounting the source directory.
A `README.md` is included with detailed instructions for building the image and running the container.
* fix(dev): Add --break-system-packages to Dockerfile
This commit resolves a build failure in the development container.
Recent versions of Python in Ubuntu/Debian images prevent `pip` from installing packages globally to avoid conflicts with the system's package manager. This change adds the `--break-system-packages` flag to the `pip3 install` command in the `Dockerfile` to override this protection, which is a safe and necessary step within a self-contained container.
* fix(dev): Avoid UID conflict in Dockerfile
This commit resolves a build failure in the development container caused by a UID conflict.
The `useradd` command failed because UID 1000 was already in use in the base Ubuntu image. This change modifies the UID for the `developer` user to 5000 to avoid this conflict.
* Dockerfile tweaks and documentation
* Add missing system requirements
* feat(devcontainer): Improve UID/GID handling and volume mounts
This commit introduces a more robust and user-friendly development container setup.
It replaces the previous mechanism of relying on the `--user` flag with an entrypoint script that dynamically adjusts the in-container `developer` user's UID and GID to match the host user's. This is a best-practice pattern for pre-built images that solves file ownership issues on mounted volumes.
The key changes include:
- An `entrypoint.sh` script to manage user mapping at runtime.
- Use of `gosu` for secure privilege dropping.
- An updated `Dockerfile` to incorporate the entrypoint.
- Revised `README.md` with clear instructions for running the container with both `/source` and `/build` volumes mounted.
fix(devcontainer): Use non-reserved variable names in entrypoint
This commit fixes a bug in the `entrypoint.sh` script that caused the container to fail on startup.
The script was using the reserved bash variable `UID`, which is readonly. This resulted in an error when the script attempted to assign a new value to it.
The fix renames the conflicting variables from `UID` and `GID` to `TARGET_UID` and `TARGET_GID` respectively, resolving the runtime error.
fix(devcontainer): Prevent entrypoint from changing host source permissions
This commit corrects a critical bug in the `entrypoint.sh` script that caused it to recursively change the ownership of the mounted `/source` directory, altering the user's project files on the host.
The `chown -R` command in the script is now restricted to only the `/build` and `/home/developer` directories. This ensures that the container has correct write permissions for build artifacts and its home directory, while leaving the ownership of the user's source code untouched.
This change makes the development container safe to use and prevents it from having unintended and destructive side effects on the host system.
revert(devcontainer): Remove entrypoint and use --user for UID/GID
This commit reverts the entrypoint-based approach and returns to a simpler, more compatible method for handling user permissions that works correctly with both Docker and Podman.
The previous entrypoint-based solution, while a common pattern for Docker, is incompatible with Podman's user namespace mapping (`--userns=keep-id`). This incompatibility led to incorrect file ownership on the host's build directory.
The corrected approach is to:
1. Remove the `entrypoint.sh` script entirely.
2. Simplify the `Dockerfile` by removing the `gosu` dependency and entrypoint logic.
3. Make the `/source` and `/build` directories inside the container world-writable (`chmod 777`).
4. Use the standard `--user "$(id -u):$(id -g)"` flag when running the container.
This method allows the user specified on the command line to write to the mounted volumes without permission errors and ensures that the created files have the correct ownership on the host, which is the desired behavior for both Podman and Docker. The `README.md` has been updated to reflect this final, correct usage.
fix(devcontainer): Remove developer user for Podman compatibility
This commit provides the final, correct implementation for the development container, ensuring compatibility with Podman's user namespace features.
The previous approach of creating a `developer` user inside the `Dockerfile` conflicted with Podman's user mapping when the `--user` flag was used. This resulted in the user inside the container not having the expected ownership of the mounted `/build` volume.
The solution is to remove the `developer` user entirely from the `Dockerfile`. The image is now prepared with world-writable `/source` and `/build` directories, making it a generic environment ready to be used by any user ID passed via the `--user` flag.
This is the simplest and most robust solution, guaranteeing correct file ownership on mounted volumes for both Docker and Podman users.
docs(devcontainer): Add correct run instructions for Docker and Podman
This commit updates the `README.md` to provide clear and distinct instructions for running the development container with Docker and rootless Podman.
The previous instructions were a source of confusion and permission errors due to fundamental differences in how Docker and rootless Podman handle user namespaces.
The new documentation clarifies that:
- Docker users should continue to use `--user "$(id -u):$(id -g)"` to ensure correct file ownership.
- Rootless Podman users should run as the default `root` user inside the container. Podman's user namespace will safely map this to their user on the host, ensuring correct file ownership on mounted volumes.
This change, combined with the simplified `Dockerfile`, provides a robust and easy-to-use solution for all users.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>Dockerfile (#36)1 parent 8d5fcd8 commit 36d35fe
File tree
5 files changed
+180
-0
lines changed- dev
- container
5 files changed
+180
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Whitespace-only changes.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
0 commit comments