|
| 1 | +// For format details, see https://aka.ms/devcontainer.json. For config options, see the |
| 2 | +// README at: https://github.com/devcontainers/templates/tree/main/src/universal |
| 3 | +{ |
| 4 | + "name": "Cotainr dev container", |
| 5 | + |
| 6 | + // Default image to use as a base for the dev container. |
| 7 | + // If you don't have access to this registry, you can build the container locally from the ./github/dockerfiles/Dockerfile. |
| 8 | + "image": "ghcr.io/deic-hpc/cotainr-dev_env-apptainer-1.3.4:main", |
| 9 | + |
| 10 | + // Set security options needed to run Apptainer/SingularityCE in the container. |
| 11 | + // These should be sufficient for running the container using rootless Podman. |
| 12 | + // More settings may be needed for other container runtimes, e.g. Docker. |
| 13 | + "securityOpt": [ |
| 14 | + "systempaths=unconfined", |
| 15 | + "no-new-privileges" |
| 16 | + ], |
| 17 | + |
| 18 | + // Mounts to persist select data between container restarts and rebuilds. |
| 19 | + "mounts": [ |
| 20 | + {// Persist the virtual environment (with paths relative to the dev container setup) |
| 21 | + "source": "uv-venv", |
| 22 | + "target": "/uv-venv", |
| 23 | + "type": "volume" |
| 24 | + }, |
| 25 | + {// Persist the pre-commit environment |
| 26 | + "source": "pre-commit-env", |
| 27 | + "target": "/pre-commit-env", |
| 28 | + "type": "volume" |
| 29 | + }, |
| 30 | + {// Persist the command history |
| 31 | + "source": "commandhistory", |
| 32 | + "target": "/commandhistory", |
| 33 | + "type": "volume" |
| 34 | + } |
| 35 | + ], |
| 36 | + |
| 37 | + // Sync the uv python venv on startup |
| 38 | + // https://code.visualstudio.com/remote/advancedcontainers/start-processes |
| 39 | + "postStartCommand": "uv sync --frozen", |
| 40 | + |
| 41 | + // Set environment variables to use in IDE processes in the container. |
| 42 | + "remoteEnv": { |
| 43 | + "UV_PROJECT_ENVIRONMENT": "/uv-venv", // Set the uv virtual environment path to a persisted mounted volume |
| 44 | + "PRE_COMMIT_HOME": "/pre-commit-env", // Set the pre-commit env path to a persisted mounted volume |
| 45 | + "HISTFILE": "/commandhistory/.bash_history", // Set the history file to a persisted mounted volume |
| 46 | + "PROMPT_COMMAND": "history -a" // Append to the history file after each command |
| 47 | + }, |
| 48 | + |
| 49 | + // Run container as non-root user. More info: https://aka.ms/dev-containers-non-root. |
| 50 | + // https://code.visualstudio.com/remote/advancedcontainers/add-nonroot-user#_specifying-a-user-for-vs-code |
| 51 | + // containerUser is needed over remoteUser to have volumes mounted with the correct permissions for use by the non-root user. |
| 52 | + // This has been tested with Podman. If using Docker, more configuration may be needed to avoid permission errors with the volume mounts. |
| 53 | + // See https://github.com/microsoft/vscode-remote-release/issues/9931 for more details. |
| 54 | + "containerUser": "1000:1000", |
| 55 | + |
| 56 | + // Configure tool-specific properties. |
| 57 | + "customizations": { |
| 58 | + "vscode": { |
| 59 | + // VS Code settings for the container. |
| 60 | + "settings": { |
| 61 | + "terminal.integrated.env.linux": { |
| 62 | + "GIT_EDITOR": "code --wait" // Use VS Code when editing commit messages |
| 63 | + }, |
| 64 | + "python.defaultInterpreterPath": "/uv-venv/bin/python", // Set the default Python interpreter to the uv virtual environment |
| 65 | + "python.terminal.activateEnvironment": true, // Activate the uv virtual environment in the terminal |
| 66 | + "github.copilot.chat.codeGeneration.instructions": [ |
| 67 | + { |
| 68 | + "text": "This dev container is used for developing and testing Cotainr. Cotainr is a tool for building Singularity / Apptainer containers in a rootless setting. It is written in pure Python and uses pytest for testing as well as sphinx for building the documentation. The documentation is written as restructured text." |
| 69 | + } |
| 70 | + ] |
| 71 | + }, |
| 72 | + // VS Code extensions to install in the dev container. |
| 73 | + // https://code.visualstudio.com/docs/devcontainers/containers#_managing-extensions |
| 74 | + "extensions": [ |
| 75 | + "ms-python.python", |
| 76 | + "ms-azuretools.vscode-containers", |
| 77 | + "ms-vscode.makefile-tools", |
| 78 | + "github.vscode-github-actions", |
| 79 | + "streetsidesoftware.code-spell-checker", |
| 80 | + "tamasfe.even-better-toml", |
| 81 | + "redhat.vscode-yaml", |
| 82 | + "DavidAnson.vscode-markdownlint", |
| 83 | + "trond-snekvik.simple-rst" |
| 84 | + ] |
| 85 | + } |
| 86 | + } |
| 87 | +} |
0 commit comments