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
2 changes: 1 addition & 1 deletion .devcontainer/.env
File renamed without changes.
5 changes: 4 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"version": "23"
}
},
"initializeCommand": "mkdir -p \"${localEnv:HOME}/.codex\"",
"initializeCommand": {
"codex-home": "mkdir -p \"${localEnv:HOME}/.codex\"",
"compose-env": "bash \"${localWorkspaceFolder}/.devcontainer/initialize-compose-env.sh\""
},
"postCreateCommand": "curl -fsSL --output /tmp/codex-install.sh https://chatgpt.com/codex/install.sh && CODEX_NON_INTERACTIVE=1 sh /tmp/codex-install.sh; status=$?; rm -f /tmp/codex-install.sh; exit $status",
"mounts": [
"source=${localEnv:HOME}/.codex,target=/home/dev/.codex,type=bind"
Expand Down
15 changes: 15 additions & 0 deletions .devcontainer/initialize-compose-env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

set -euo pipefail

repo_root=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)
compose_env="${repo_root}/.env.compose"
user_name=${USER:-$(id -un)}
checkout_name=$(basename -- "${repo_root}")

cp "${repo_root}/.devcontainer/.env.defaults" "${compose_env}"
printf '\nCOMPOSE_PROJECT_NAME=simphony-%s-%s\n' ${user_name} ${checkout_name} >> ${compose_env}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Quote the Compose environment redirection

When the checkout resides in a path containing whitespace, ${compose_env} expands into multiple redirection words, so Bash exits with ambiguous redirect under set -e before .env.compose is populated. This makes devcontainer up unable to initialize for such checkouts; quote the redirection target and the two printf arguments.

Useful? React with 👍 / 👎.

if [[ -f "${repo_root}/.env.local" ]]; then
printf '\n' >> "${compose_env}"
cat "${repo_root}/.env.local" >> "${compose_env}"
fi
Comment on lines +6 to +15
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
.github/
.devcontainer/
.env
.env.*
.venv
__pycache__/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*~
/.env.*
dd4hepplugins/examples/drich-dev/
dd4hepplugins/examples/calibrations/
dd4hepplugins/examples/fieldmaps/
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ devcontainer exec bash
The source tree is mounted into the container. Once inside, use the same CMake
commands above and rerun only the relevant build and tests as you work.

The root `.env` selects the OS and toolchain versions. See [Choose dependency
versions](docs/getting-started.md#choose-dependency-versions) before changing
them.
The `.devcontainer/.env.defaults` file selects the default OS and toolchain
versions. See [Choose dependency
versions](docs/getting-started.md#choose-dependency-versions) to override them
locally.

To run GPU-backed code, install the [NVIDIA Container
Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html)
Expand Down
31 changes: 20 additions & 11 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,21 @@ create one with `git switch -c new-branch`.

### Choose dependency versions

Skip this section if the default dependency versions meet your needs. The root
`.env` file selects the OS and toolchain used to build the Dev Container.
`.devcontainer/.env` links to it so Compose can discover the same settings.
Edit `.env` when you want to use another supported combination or experiment
with a new dependency version.
If the default dependency versions meet your needs, skip this section and
continue to [Start the environment](#start-the-environment).

The `.devcontainer/.env.defaults` file contains the default OS and toolchain
used to build the Dev Container. To use another supported combination or
experiment with a new dependency version, put your overrides in the `.env.local`
file at the repository root. During `devcontainer up`, the initialization step
combines the defaults and local overrides into the `.env.compose` file that
Compose reads.

The defaults match the `base` alias in the [published container
matrix](../README.md#published-container-images). Start with another `base`
combination from this matrix when possible.

After editing `.env`, recreate the container so it uses the new values:
After editing `.env.local`, recreate the container so it uses the new values:

```shell
devcontainer up --remove-existing-container
Expand Down Expand Up @@ -89,15 +93,20 @@ devcontainer up --remove-existing-container
You do not need to recreate the container after switching source branches. The
checkout remains mounted directly into the environment.

The default Compose project name keeps different system users from colliding,
even when they share a Docker daemon. If one account uses multiple checkouts or
runs concurrent jobs, set a unique project name before starting the container:
The default Compose project name includes the system user and checkout
directory name, keeping users and checkouts from colliding when they share a
Docker daemon. To use a different name, append it to `.env.local` before
starting the container:

```shell
export COMPOSE_PROJECT_NAME="simphony-${USER}-my_cool_feature"
echo "COMPOSE_PROJECT_NAME=simphony-${USER}-my_cool_feature" >> .env.local
```

The same configuration also works with the VS Code Dev Containers extension.
Replace `my_cool_feature` with a short unique name for that checkout.

This configuration also works with IDEs and tools that support the [Development
Container Specification](https://containers.dev/). When using VS Code, its Dev
Containers extension also installs the recommended extensions.

### Build and test

Expand Down
Loading