Skip to content

Add CDEPS Dev Container to repo - #447

Open
danrosen25 wants to merge 1 commit into
ESCOMP:mainfrom
danrosen25:feature/devcontainer
Open

danrosen25 wants to merge 1 commit into
ESCOMP:mainfrom
danrosen25:feature/devcontainer

Conversation

@danrosen25

Copy link
Copy Markdown
Collaborator

Description of changes

This PR introduces a Dev Container configuration to the repository. Moving forward, anyone working on this project can spin up a fully configured, isolated development environment with a single click.

Why use Dev Containers?

  • Packages all tools and dependencies into a unified environment.
  • New contributors can bypass local installation steps. Cloning the repo and opening it in a container handles all the setup automatically.
  • Keeps all project-specific tools and libraries isolated inside the container, preventing global version conflicts on your local machine.
  • Automatically provisions recommended workspace extensions.
  • Containers can be utilized in cloud IDE architectures GitHub Codespaces.

How to Use It

  1. Ensure you have Docker Desktop and VS Code installed.
  2. Install the official VS Code Dev Containers Extension.
  3. Open this project folder in VS Code. When prompted by the pop-up, click "Reopen in Container" (or trigger it manually via the Command Palette F1 ➔ Dev Containers: Reopen in Container).

Specific notes

  • Contributors: @danrosen25
  • CDEPS Issues Fixed (include github issue #): None
  • Are there dependencies on other component PRs (if so list): No
  • Are changes expected to change answers (bfb, different to roundoff, more substantial): No
  • Any User Interface Changes (namelist or namelist defaults changes): No
  • Testing performed (e.g. aux_cdeps, CESM prealpha, etc): N/A
  • Hashes used for testing: N/A

@billsacks

Copy link
Copy Markdown
Member

@mvertens @uturuncoglu @DeniseWorthen @ekluzek @samsrabin @Katetc @slevis-lmwg - I invited @danrosen25 to open this for discussion about whether we want it. My feeling is that I'm happy to include it if at least some others would find it useful. As some of the main recent contributors to CDEPS, do any of you have feelings on this?

@ekluzek ekluzek added enhancement New feature or request answers are bfb labels Sep 29, 2026
@danrosen25

Copy link
Copy Markdown
Collaborator Author

@mvertens @uturuncoglu @DeniseWorthen @ekluzek @samsrabin @Katetc @slevis-lmwg @billsacks
As a follow up to Bill's comment. It would also be nice to add regression testing directly to the repository. I'm doing some work on memory allocation clean up but I can't easily test changes in this container. I'd like to be able to run tests in this Dev Container, but tests don't exist.

@Katetc

Katetc commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

I could see a docker file being the kind of thing that might get out-of-date if nobody is actively maintaining it. CDEPS is most functionally useful with CMEPS. Would it make sense to build the environment within CMEPS so it could be used by a variety of configurations? And, that would be an easier place to keep up-to-date with any machine, software version or library changes needed.

@danrosen25

Copy link
Copy Markdown
Collaborator Author

@Katetc
Maintaining the Dev Container should be similar to the work needed to maintain the CI. They should actually be consolidated so that the CI utilizes the Dev Container BUT I recommend caching library binaries first because they take a while to build. I recommend utilizing Spack to build libraries and cache libraries because it's the easiest way to maintain a complex software stack. The Dev Container provided utilizes Spack to build libraries but it doesn't cache library binaries.

@ekluzek ekluzek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is a really cool capability to look at and think about.

Because of licensing issues we need to have people use podman instead of Docker. I suggest one change for that. The VS Code Dev Container extension also needs to be updated to use podman rather than Dockier. So that should be explained somewhere.

I also think that the contents here should replace most of what's in the workflow for extbuild.yml. We don't want to maintain that workflow alongside this one.

I've tried getting it to work on Derecho and ran into trouble (the docker daemon wasn't running). I also tried on my Mac laptop, it got farther but also failed, but I think because of problems I'm having in getting podman-compose installed on my Mac.

So these are things I think are needed:

  • Use podman rather than Docker
  • Add instructions about changing the Dev Container extension in VS code
  • The instructions that are in the header of this PR need to go into some README document
  • Have the exbuild github workflow use this rather than it's own setup


## Prerequisites

- Docker or another Docker-compatible container runtime

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For licensing reasons we've been endorsing using podman. And podman is available on Derecho and other machines, while Docker is not.

So I think it should explicitly say podman here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
- Docker or another Docker-compatible container runtime
- Podman or another Docker-compatible container runtime

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The podman daemon also needs to be running, which should be mentioned somewhere.

@samsrabin

Copy link
Copy Markdown
Member

In addition to the testing and portability benefits of regular containers, I really like devcontainers as a way to isolate coding agents from the rest of the filesystem. See, e.g., Anthropic's instructions for a Claude devcontainer, which also uses VS Code. There's nothing LLM-focused in this devcontainer, but it existing means someone can extend it to build e.g. a Claude-focused one, rather than starting from scratch.

So I give this a big thumbs up in principle, although I haven't personally reviewed it.

@samsrabin

Copy link
Copy Markdown
Member

After a quick look at the changed files: I would want this PR to include GitHub Workflows to build (on PRs) and publish (on commits to main) the devcontainer whenever it's changed. I've done this for a container in CTSM and can provide guidance if needed.

@danrosen25

Copy link
Copy Markdown
Collaborator Author

@ekluzek
I haven't used Podman. I think Podman is runnable on Derecho but it might require more steps on local machines (both reduced and increased portability)? I think the Dockerfile needs modifications to remove the USER=cdepsdev for Podman compatibility, this was done to isolate the development environment from root.
https://code.visualstudio.com/remote/advancedcontainers/docker-options#_podman

CTNR_USER="cdepsdev"
...
# Create non-root user with sudo privileges
ENV HOME=/home/${CTNR_USER}
RUN <<SETUP_USER
    groupadd ${CTNR_USER}
    useradd -m -d ${HOME} -s /bin/bash -g ${CTNR_USER} ${CTNR_USER}
    adduser ${CTNR_USER} sudo
    echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
SETUP_USER
USER ${CTNR_USER}
WORKDIR ${HOME}

@danrosen25

Copy link
Copy Markdown
Collaborator Author

@samsrabin
I agree. The main reason I switched to Dev Containers is to isolate agents from my entire file system. Although guardrails are in place, I do not want agents reading my ssh keys (etc) if they break free of guardrails.
Question: How are you building images for the AArch64 architecture? The reason I haven't fully automated GitHub actions to build container images in the past is because emulation is slow and Docker isn't available on the GitHub Mac OS runners.

@samsrabin

Copy link
Copy Markdown
Member

Question: How are you building images for the AArch64 architecture? The reason I haven't fully automated GitHub actions to build container images in the past is because emulation is slow and Docker isn't available on the GitHub Mac OS runners.

Ah, that's a complication I've not actually run into—I've never used a devcontainer for CI/CD, only local development. In fact, now that I think about it, I don't think I actually built or ran the model in my devcontainer. I was using it purely for editing code, then testing on Derecho. That's obviously not an ideal workflow—my idea of "human in the loop" doesn't preclude me from letting LLMs build the model or even run simple tests.

@danrosen25

danrosen25 commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

@samsrabin
Can you point me to your CTSM dev container? I want to understand what you're building and pushing.

You might be interested in this work. For ESMF I have a script for building and pushing a multi-architecture container image package. I made an attempt to build images on their native architectures, for speed. I then cache the image and join them into a single manifest. The issue became that there's no native architecture that can build an AArch64 image so I'm building that on amd64 with emulation (slow). I left the infrastructure in place so that if the Mac OS runners (or another machine with AArch64) start supporting Docker builds then I can switch it over easily. I mitigate the slow emulation builds through installing as many binaries as possible via apt.
https://github.com/esmf-org/esmf/blob/develop/.github/workflows/deploy-devcontainers.yml

@samsrabin

Copy link
Copy Markdown
Member

I wasn't actually building and pushing the devcontainer; that was just a local experiment. What I'm doing for CTSM is building a container for our documentation. It's actually hosted in a separate repo, ESMCI/doc-builder. I have workflows that (1) build and test on PRs and (2) build and publish on merges to master.

I'm also using emulation to build the arm64 version, but because this container is small and rarely-updated, it hasn't been an issue.

However, I think there's a solution for you: The native macOS runners don't have Docker, but the arm64 ones do. That would result in containers that can run without emulation on Apple Silicon Macs (everything released in the last ~6 years).

@danrosen25

Copy link
Copy Markdown
Collaborator Author

@samsrabin
I didn't see that GitHub released the ubuntu-24.04-arm. Thanks! That should be exactly what I was needing.
https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Arm64-Readme.md

I only have to change one line of code, perfect.
https://github.com/esmf-org/esmf/blob/b6b90e9e0cb70a53bc40413187993119c6fc0b95/.github/workflows/deploy-devcontainers.yml#L138

@NickSzapiro-NOAA

Copy link
Copy Markdown
Contributor

Maybe this is of interest @natalie-perlin, on container in UFS subcomponent and moving more testing upstream

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

answers are bfb enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants