Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build
/build.log
/venv
Empty file added dev/container/.dummy
Empty file.
53 changes: 53 additions & 0 deletions dev/container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Dockerfile for building Cetmodules development image.
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the comment: "Cetmodules" should be "cetmodules" (lowercase) to match the project's naming convention used throughout the repository and documentation.

Suggested change
# Dockerfile for building Cetmodules development image.
# Dockerfile for building cetmodules development image.

Copilot uses AI. Check for mistakes.

# Podman instructions for building and uploading tagged images:
# $ DATE="$(date +"%Y-%m-%d")"
# $ podman build --tag cetmodules-dev:$DATE .
# $ podman login ghcr.io --username <username> -p $(gh auth token)
# $ podman push cetmodules-dev:$DATE ghcr.io/fnalssi/cetmodules-dev:$DATE
# ... and optionally push with destination tag "latest"

# Base image
FROM ubuntu:latest
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ubuntu:latest as a base image is not recommended for production containers. The latest tag is not pinned to a specific version, which can lead to unpredictable behavior and breaking changes when Ubuntu releases a new version. Consider pinning to a specific version like ubuntu:22.04 or ubuntu:24.04.

Suggested change
FROM ubuntu:latest
FROM ubuntu:22.04

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot This is not a production container; it is a development container.


# Set non-interactive frontend to avoid prompts
ENV DEBIAN_FRONTEND=noninteractive

# Install system dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
git \
doxygen \
graphviz \
m4 \
ninja-build \
python3 \
python3-pip \
sudo && \
rm -rf /var/lib/apt/lists/*

# Install Python packages
RUN pip3 install --no-cache-dir --break-system-packages \
cmake \
sphinx \
sphinxcontrib-moderncmakedomain \
sphinx-design \
sphinx-toolbox \
sphinxcontrib-jquery
Comment on lines +31 to +37
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The --break-system-packages flag bypasses Python's externally-managed-environment protection. This is a security and maintainability risk. Consider using a virtual environment inside the container or using the OS package manager's Python packages instead. For example:

RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip3 install --no-cache-dir cmake sphinx ...

Copilot uses AI. Check for mistakes.

# Install Catch2
RUN git clone https://github.com/catchorg/Catch2.git /tmp/Catch2 && \
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Catch2 repository is cloned without specifying a version or tag, which means the build will use whatever is on the default branch at the time. This could introduce breaking changes or incompatibilities. Consider pinning to a specific release tag for reproducibility:

RUN git clone --branch v3.5.2 --depth 1 https://github.com/catchorg/Catch2.git /tmp/Catch2 && \
Suggested change
RUN git clone https://github.com/catchorg/Catch2.git /tmp/Catch2 && \
RUN git clone --branch v3.5.2 --depth 1 https://github.com/catchorg/Catch2.git /tmp/Catch2 && \

Copilot uses AI. Check for mistakes.
cmake -S /tmp/Catch2 -B /tmp/Catch2/build -DBUILD_TESTING=OFF && \
cmake --build /tmp/Catch2/build --target install && \
rm -rf /tmp/Catch2

# Create source and build directories and make them world-writable
RUN mkdir /source /build && \
chmod 777 /source /build

# Set working directory
WORKDIR /build

# Set default command
CMD ["/bin/bash"]
57 changes: 57 additions & 0 deletions dev/container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Cetmodules Development Container
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent capitalization: "Cetmodules" should be "cetmodules" (lowercase) to match the project's naming convention used throughout the repository.

Suggested change
# Cetmodules Development Container
# cetmodules Development Container

Copilot uses AI. Check for mistakes.

This directory contains a `Dockerfile` to create a containerized development environment for `cetmodules`.

## Building the Image

To build the image, run the following command from the root of the repository:

```bash
# For Docker or Podman
docker build -t cetmodules-dev dev/container
```

## Running the Container

The command to run the container differs between Docker and Podman due to differences in how they handle user namespaces.

First, create a local `build` directory if it does not already exist:

```bash
mkdir -p build
```

### For Docker Users

Docker users should map their host user ID directly to the container to ensure correct file ownership on mounted volumes.

```bash
docker run -it --rm \
--user "$(id -u):$(id -g)" \
-v "$(pwd):/source" \
-v "$(pwd)/build:/build" \
cetmodules-dev
```

### For Podman Users (Rootless)

Rootless Podman uses user namespaces to map your host user to the `root` user (UID 0) inside the container. To ensure you have permission to write to mounted volumes, you should run as `root` inside the container. Any files created in the mounted volumes will be correctly owned by your user on the host.

```bash
podman run -it --rm \
-v "$(pwd):/source" \
-v "$(pwd)/build:/build" \
cetmodules-dev
```
*(Note: Running as `root` is the intended usage for rootless Podman and is safe because you are in an unprivileged user namespace.)*


### Usage

Once inside the container, you can perform an out-of-source build like this:

```bash
cmake -S /source -B . -DBUILD_DOCS=ON
cmake --build .
ctest
```
67 changes: 67 additions & 0 deletions dev/setup_cetmodules_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/bin/bash

# Exit immediately if a command exits with a non-zero status.
set -e

# --- OS Detection ---
if [ -f /etc/os-release ]; then
. /etc/os-release
if [[ "$ID" == "ubuntu" ]]; then
PACKAGE_MANAGER="apt-get"
BUILD_DEPS="build-essential"
elif [[ "$ID" == "almalinux" ]]; then
PACKAGE_MANAGER="dnf"
BUILD_DEPS="gcc-c++"
else
echo "Unsupported operating system: $ID"
exit 1
fi
else
echo "/etc/os-release not found. Cannot determine operating system."
exit 1
fi

# --- System Dependency Installation ---
echo "Updating package lists..."
sudo $PACKAGE_MANAGER update -y

echo "Installing system dependencies..."
sudo $PACKAGE_MANAGER install -y git doxygen graphviz python3-venv $BUILD_DEPS

# --- Python Environment Setup ---
echo "Setting up Python virtual environment..."
python3 -m venv venv
source venv/bin/activate

echo "Installing Python packages (CMake, Sphinx, etc.)..."
pip install cmake sphinx sphinxcontrib-moderncmakedomain sphinx-design sphinx-toolbox sphinxcontrib-jquery

# --- Catch2 Installation ---
echo "Cloning and installing Catch2..."
git clone https://github.com/catchorg/Catch2.git
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Catch2 repository is cloned without specifying a version or tag. This means the installation will use the latest commit on the default branch, which could introduce breaking changes or incompatibilities. Consider pinning to a specific release tag, for example:

git clone --branch v3.5.2 --depth 1 https://github.com/catchorg/Catch2.git
Suggested change
git clone https://github.com/catchorg/Catch2.git
git clone --branch v3.5.2 --depth 1 https://github.com/catchorg/Catch2.git

Copilot uses AI. Check for mistakes.
cd Catch2
cmake -S . -B build -DBUILD_TESTING=OFF
sudo cmake --build build --target install
cd ..
rm -rf Catch2

# --- cetmodules Build and Test ---
echo "Cloning, building, and testing cetmodules..."
git clone https://github.com/FNALssi/cetmodules.git
cd cetmodules
cmake -S . -B build -DBUILD_DOCS=ON
cmake --build build
ctest --test-dir build

# --- Documentation Build ---
echo "Building cetmodules documentation..."
cmake --build build --target doc-cetmodules-reference
cd ..
Comment on lines +51 to +59
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script changes directory to cetmodules but never changes back. If the script is sourced instead of executed, this will leave the user in an unexpected directory. Consider adding cd .. at the end or wrapping the cetmodules operations in a subshell.

Suggested change
cd cetmodules
cmake -S . -B build -DBUILD_DOCS=ON
cmake --build build
ctest --test-dir build
# --- Documentation Build ---
echo "Building cetmodules documentation..."
cmake --build build --target doc-cetmodules-reference
cd ..
(
# Enter cetmodules directory in a subshell to avoid affecting user's shell if sourced
cd cetmodules
cmake -S . -B build -DBUILD_DOCS=ON
cmake --build build
ctest --test-dir build
# --- Documentation Build ---
echo "Building cetmodules documentation..."
cmake --build build --target doc-cetmodules-reference
)

Copilot uses AI. Check for mistakes.
Comment on lines +48 to +59
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script clones a fresh copy of the cetmodules repository and builds it, but this doesn't align with typical development workflow. A developer running this script from the cetmodules repository would expect to build and test their current working copy, not a fresh clone from GitHub. This makes the script unsuitable for local development and testing of changes.

Copilot uses AI. Check for mistakes.

# --- Completion ---
echo ""
echo "----------------------------------------------------"
echo "Development environment setup for cetmodules is complete!"
echo "To activate the Python virtual environment, run:"
echo "source venv/bin/activate"
echo "----------------------------------------------------"
Loading