Skip to content

Local devcontainers (take 2) #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 25, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
// See .devcontainer/devcontainer.json for production config
//
{
"name": "devcontainers-development",
"name": "nextflow-training (codespaces-dev)",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",

"features": {
"./local-features/init": {},
"../local-features/init": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/java:1": { "version": "latest" },
"ghcr.io/devcontainers/features/java:1": { "version": "21.0.6-ms" },
"ghcr.io/rocker-org/devcontainer-features/miniforge:2": {
"version": "latest"
},
"./local-features/apptainer": {},
"./local-features/tower-agent": {},
"./local-features/conda-packages": {}
"../local-features/apptainer": {},
"../local-features/tower-agent": {},
"../local-features/conda-packages": {}
},
"workspaceFolder": "/workspaces/training",
"remoteUser": "root",
Expand Down
50 changes: 50 additions & 0 deletions .devcontainer/local-dev/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//
// DEVELOPMENT DEVCONTAINER CONFIG
// Base configuration that is pre-built and pushed to GitHub
// See .devcontainer/devcontainer.json for production config
//
{
"name": "nextflow-training (local-dev)",
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",

"features": {
"../local-features/init": {},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"version": "latest"
},
"ghcr.io/devcontainers/features/java:1": { "version": "21.0.6-ms" },
"ghcr.io/rocker-org/devcontainer-features/miniforge:2": {
"version": "latest"
},
"../local-features/apptainer": {},
"../local-features/tower-agent": {},
"../local-features/conda-packages": {}
},
"workspaceFolder": "${localWorkspaceFolder}",
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
"remoteUser": "root",
"remoteEnv": {
// Nextflow installation version
"NXF_HOME": "/workspaces/training/.nextflow",
"NXF_EDGE": "0",
"NXF_VER": "24.10.4",
// Other env vars
"HOST_PROJECT_PATH": "/workspaces/training",
"SHELL": "/bin/bash" // Ush bash
},
"onCreateCommand": "bash ${localWorkspaceFolder}/.devcontainer/setup.sh",
"postCreateCommand": "mkdir -p /workspaces && rm -rf /workspaces/training && ln -s ${localWorkspaceFolder} /workspaces/training",
"customizations": {
"vscode": {
"extensions": ["nf-core.nf-core-extensionpack"],
// Use Python from conda
"settings": {
"python.defaultInterpreterPath": "/opt/conda/bin/python",
"terminal.integrated.cwd": "/workspaces/training",
"terminal.integrated.defaultLocation": "workspace"
},
// Use bash
"terminal.integrated.defaultProfile.linux": "bash"
}
}
}
2 changes: 1 addition & 1 deletion .github/workflows/docker-devcontainer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
- name: Pre-build dev container image
uses: devcontainers/ci@v0.3
with:
configFile: .devcontainer/development/devcontainer.json
configFile: .devcontainer/codespaces-dev/devcontainer.json
imageName: ghcr.io/${{ github.repository }}
imageTag: ${{ env.IMAGE_TAG }}
cacheFrom: ghcr.io/${{ github.repository }}
Expand Down
106 changes: 106 additions & 0 deletions docs/envsetup/03_devcontainer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Local installation using VSCode Devcontainers extension

If you have a local Docker installation or are happy to install one, the easiest way to work locally with these materials is to use Visual Studio Code's devcontainer feature. This approach provides all the necessary tools and dependencies without requiring manual installation.

## Requirements

To use the devcontainer setup, you'll need:

- [Visual Studio Code](https://code.visualstudio.com/)
- A local Docker installation, for example:
- [Docker Desktop](https://docs.docker.com/get-docker/) (for Windows/macOS)
- [Docker Engine](https://docs.docker.com/engine/install/) (for Linux)
- [Colima](https://github.com/abiosoft/colima) (alternative for macOS)
- [Docker Buildx](https://docs.docker.com/build/concepts/overview/#install-buildx) (included in Docker Desktop, but may need separate installation with other Docker setups)
- [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) for VS Code

Your Docker installation must be running before you attempt to open the devcontainer.

To verify that Docker buildx is available, run:

```bash
docker buildx version
```

If this command fails, you'll need to install the buildx extension before proceeding.

## Setup Instructions

Follow these steps to set up your local environment using VS Code devcontainers:

### Install the "Dev Containers" extension in VS Code

- Open VS Code
- Go to Extensions (Ctrl+Shift+X or Cmd+Shift+X on macOS)
- Search for "Dev Containers"
- Click "Install"

![Installing Dev Containers extension in VS Code](img/install_extension.png)

### Clone the repository:

```bash
git clone https://github.com/nextflow-io/training.git
cd training
```

### Open the repository in VS Code:

- Launch VS Code
- Select **File -> Open Folder** from the menu
- Navigate to and select the training repository folder you just cloned
- Click **Open**

### Reopen in Container

If prompted by VS Code to "Reopen in Container", click on it. Alternatively:

- Press F1 (or Ctrl+Shift+P / Cmd+Shift+P on macOS)
- Type "Dev Containers: Reopen in Container"
- **Important**: When prompted to select a configuration, choose the **local-dev** devcontainer configuration

![Reopen in Container prompt](img/reopen_prompt.png)

![Selecting local configuration](img/select_local_config.png)

Wait for the container to build. This may take a few minutes the first time as it downloads and sets up all the necessary components.

Once the container is built and running, you'll have a fully configured environment with all the necessary tools installed, including:

- Java
- Nextflow
- Docker
- Git
- And all other dependencies required for the training

![VS Code with devcontainer running](img/running_container.png)

## Benefits of Using Devcontainers

Using the devcontainer approach offers several advantages:

- **Consistency**: Ensures a consistent development environment across different machines
- **Simplicity**: All dependencies are pre-installed and configured
- **Isolation**: The development environment is isolated from your local system
- **Reproducibility**: Everyone using the devcontainer gets the same setup
- **No manual installation**: No need to manually install Java, Nextflow, and other tools

## Checking Your Environment

Once your devcontainer is running, you can verify that everything is set up correctly by running:

```bash
nextflow info
```

This should display the Nextflow version and runtime information, confirming that your environment is properly configured.

## Troubleshooting

If you encounter issues with the devcontainer setup:

1. Ensure your Docker installation (Docker Desktop, Colima, Docker Engine, etc.) is running before opening the devcontainer
2. Check that you've selected the **local-dev** configuration when prompted
3. Verify that Docker buildx is installed and working by running `docker buildx version`
4. If the container fails to build, try rebuilding it by running the "Dev Containers: Rebuild Container" command
5. For persistent issues, refer to the [VS Code Dev Containers troubleshooting guide](https://code.visualstudio.com/docs/devcontainers/troubleshooting)
Binary file added docs/envsetup/img/install_extension.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/envsetup/img/reopen_prompt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/envsetup/img/running_container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/envsetup/img/select_local_config.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/envsetup/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Let's get started!

For more detailed instructions for GitHub Codespaces, see the [GitHub Codespaces env-setup docs](01_setup.md).
If you cannot use GitHub Codespaces and wish to use a local development environment, see the [documentation for local installation](02_local.md).
If you prefer using VS Code with a pre-configured environment, see the [VS Code Devcontainers setup guide](03_devcontainer.md).

!!! info "Deprecation of Gitpod"

Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ nav:
- envsetup/index.md
- envsetup/01_setup.md
- envsetup/02_local.md
- envsetup/03_devcontainer.md
- Hello Nextflow:
- hello_nextflow/index.md
- hello_nextflow/00_orientation.md
Expand Down