Skip to content

Local devcontainers enablement #539

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

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 20 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
12 changes: 9 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/devcontainers/universal:linux
FROM mcr.microsoft.com/devcontainers/base:jammy

USER root

Expand Down Expand Up @@ -41,9 +41,15 @@ ENV NXF_EDGE=0
ENV NXF_VER=24.10.4
ENV NXF_HOME=/workspaces/.nextflow

# Install Conda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
bash Miniconda3-latest-Linux-x86_64.sh -b -p /opt/conda && \
rm Miniconda3-latest-Linux-x86_64.sh

ENV PATH="/opt/conda/bin:$PATH"

# Install nextflow, nf-core, Mamba, and pytest-workflow
RUN conda config --remove channels defaults && \
conda config --add channels bioconda && \
RUN conda config --add channels bioconda && \
conda config --add channels conda-forge && \
conda config --set channel_priority strict && \
conda update --quiet --yes --all && \
Expand Down
34 changes: 34 additions & 0 deletions .devcontainer/codespaces/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "nextflow-training (codespaces)",

// Update this to pin the release tag before release
"image": "ghcr.io/nextflow-io/training:latest",
// Uncomment this and comment "image" when testing Dockerfile changes
// "build": { "dockerfile": "../Dockerfile", "context": ".." },

"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"version": "latest"
}
},
"workspaceFolder": "/workspaces/training",
"remoteEnv": {
"NXF_HOME": "/workspaces/.nextflow",
"HOST_PROJECT_PATH": "/workspaces/training"
},
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "/opt/conda/bin/python"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"nf-core.nf-core-extensionpack", // nf-core recommended extensions
"nextflow.nextflow", // Nextflow VS Code extension
"codezombiech.gitignore" // Language support for .gitignore files
]
}
},
"remoteUser": "root"
}
41 changes: 0 additions & 41 deletions .devcontainer/devcontainer.json

This file was deleted.

1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
39 changes: 39 additions & 0 deletions .devcontainer/local/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "nextflow-training (local)",

"build": {
"dockerfile": "../Dockerfile",
"context": "..",
"options": ["--platform=linux/amd64"]
Copy link
Member

Choose a reason for hiding this comment

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

Do we really want to force people to use amd64? Is this needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It actually was. I got some weird Docker shim error without it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But maybe if you build the arm image it won't be needed

Copy link
Member

Choose a reason for hiding this comment

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

},

"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {
"version": "latest"
}
},
"workspaceFolder": "${localWorkspaceFolder}",
"workspaceMount": "source=${localWorkspaceFolder},target=${localWorkspaceFolder},type=bind",
"remoteEnv": {
"NXF_HOME": "/workspaces/training/.nextflow",
"HOST_PROJECT_PATH": "/workspaces/training"
},
"postCreateCommand": "sudo mkdir -p /workspaces && sudo rm -rf /workspaces/training && sudo ln -s ${localWorkspaceFolder} /workspaces/training",
"customizations": {
"vscode": {
"settings": {
"python.defaultInterpreterPath": "/opt/conda/bin/python",
"terminal.integrated.cwd": "/workspaces/training",
"terminal.integrated.defaultLocation": "workspace"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"nf-core.nf-core-extensionpack", // nf-core recommended extensions
"nextflow.nextflow", // Nextflow VS Code extension
"codezombiech.gitignore" // Language support for .gitignore files
]
}
},
"remoteUser": "root"
}
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/buildx/working-with-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

When 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** 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** 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