
A Nextflow training environment that works both on a laptop and on an HPC cluster is convenient for a team working through the same exercises. code-server runs VS Code in a browser and can be started as a Slurm job on a compute node, so trainees only need a browser and an SSH connection rather than a local installation.
This guide covers launching code-server as a Slurm job, reaching it from a local machine through an SSH tunnel, installing the relevant VS Code extensions, and verifying that Nextflow, Singularity, nf-core and nf-test are available.
For an introduction to Pixi and package management, see our post on Pixi, a conda-based package manager.
Code-server runs VS Code in a browser, which makes it usable on a cluster without installing an editor locally. It is installed here through Pixi so that the tool versions are managed alongside the rest.
Code-server runs VS Code in a browser, giving the familiar interface while working on a remote system. This suits:
Pixi is a package manager that can install tools such as Nextflow and Singularity. For more detail on Pixi, see our post on Pixi, a conda-based package manager.
In this guide, Pixi manages code-server, Nextflow, Singularity and the nf-core tools inside a SLURM job.
Submitting code-server as a Slurm batch job allocates the resources it needs and keeps it running on a compute node.
Create a Slurm job script that installs and starts code-server:
# Create sbatch scriptcat > ~/code-server-job.sh << 'EOF'#!/bin/bash#SBATCH --job-name=code-server#SBATCH --time=24:00:00#SBATCH --cpus-per-task=2#SBATCH --mem=4GB#SBATCH --output=%x-%j.log
# Install Pixi (one time per node)curl -fsSL https://pixi.sh/install.sh | bashexport PATH="$HOME/.pixi/bin:$PATH"
# Install code-server and all tools using Pixipixi global install code-server open-jdk nextflow singularity nf-core nf-test
# Create code-server configuration directorymkdir -p ~/.config/code-server
# Create configuration filecat > ~/.config/code-server/config.yaml << 'CONFIGEOF'bind-addr: 127.0.0.1:8080auth: passwordpassword: your-secure-passwordcert: falseCONFIGEOF
# Start code-serverecho "Starting code-server on $HOSTNAME:8080"echo "Job ID: $SLURM_JOB_ID"echo "Node: $SLURM_NODENAME"
code-server --bind-addr 0.0.0.0:8080EOF
# Make script executablechmod +x ~/code-server-job.sh
# Submit the jobsbatch ~/code-server-job.shCheck the job status and find the node it is running on:
# Check running jobssqueue -u $USER
# You should see output like:# JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)# 12345 gpu code-serv user R 0:15 1 compute-node-05
# Check the log file for connection detailscat code-server-12345.log
Code-server is running on a compute node through the Slurm job. To reach it from a local machine, an SSH tunnel is created through the login node to that compute node.
First, identify which compute node the code-server job is running on:
# SSH into HPC login nodessh user@hpc.server.edu
# Check your running jobssqueue -u $USER
# Output example:# JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON)# 12345 multi code-serv user R 5:30 1 worker-01
# Note the node name (worker-01 in this example)
# Verify code-server is runningssh worker-01 'curl http://localhost:8080' 2>/dev/null | head -5Port forwarding is set up from the local machine through the login node to the compute node running code-server:
# Replace worker-01 with your actual node name# This creates a tunnel: local:8080 → login node → worker-01:8080ssh -L 8080:worker-01:8080 user@hpc.server.edu
# Keep this terminal open while using code-server# Open browser and navigate to: http://localhost:8080# Enter password: your-secure-password (from sbatch script)The tunnel command format is:
ssh -L local_port:compute_node:remote_port user@login_nodeWhere:
local_port: port on the local machine (8080)compute_node: the node name from squeue (e.g. worker-01)remote_port: the port code-server listens on (8080)login_node: your HPC login node (hpc.server.edu)For a persistent tunnel that does not require keeping a terminal open:
# Run tunnel in backgroundssh -L 8080:worker-01:8080 user@hpc.server.edu -N -f
# To close the tunnel laterkillall sshkillall ssh terminates every ssh process owned by the current user, which may close other sessions as well. Consider closing the specific tunnel instead.
For repeated access, add the HPC host to ~/.ssh/config on the local machine:
Host hpc-dev HostName hpc.server.edu User your_username LocalForward 8080 localhost:8080 ServerAliveInterval 60 ServerAliveCountMax 3Then connect with:
ssh hpc-dev# Port 8080 is now forwarded to your HPC's code-serverNote: this SSH config method forwards to localhost:8080 on the login node. For the SLURM compute-node setup, use the direct command instead, with the compute node hostname.
With the tunnel active, open a browser and navigate to:
http://localhost:8080Enter the password from the code-server configuration. The VS Code welcome screen should appear.
With code-server reachable from the local machine, the next step is to install the relevant extensions and verify the tools.
First, confirm that the tools were installed in the code-server job:
# In the code-server terminal (access via http://localhost:8080)# Check installed tools
nextflow -vsingularity --versionnf-core --versionnf-test --versionIf a tool is missing, it can be installed from the same terminal:
# Install any missing toolspixi global install nextflow singularity nf-core nf-testExtensions can be installed directly in code-server:
With the tools and extensions installed, run a simple test:
# In the code-server terminal, run a simple testnextflow run hello-world.nf
For recurring training sessions, a few small scripts make the setup more convenient.
For regular training, an alias or script can streamline job submission:
# Add to ~/.bashrcalias submit-code-server='sbatch ~/code-server-job.sh && sleep 5 && squeue -u $USER | grep code-server'
# Now you can easily submit with:submit-code-serverA script can also set up the tunnel automatically:
# Save as ~/tunnel-to-code-server.sh on your LOCAL machine#!/bin/bash
# SSH to HPC and check code-server jobNODE=$(ssh user@hpc.server.edu "squeue -u \$USER --format=%N --noheader | grep compute" | head -1)
if [ -z "$NODE" ]; then echo "No compute node found. Submit code-server job first!" exit 1fi
echo "Found code-server on node: $NODE"echo "Creating tunnel to http://localhost:8080"echo "Press Ctrl+C to close tunnel"
ssh -L 8080:$NODE:8080 user@hpc.server.eduMake it executable and use it:
chmod +x ~/tunnel-to-code-server.sh~/tunnel-to-code-server.shconfig.yamlThe example Slurm script allocates:
These can be adjusted:
# For heavier computation (running larger workflows)#SBATCH --cpus-per-task=4#SBATCH --mem=8GB
# For shorter sessions (testing)#SBATCH --time=4:00:00
# To use GPU (if available)#SBATCH --gres=gpu:1The result is a Nextflow training environment with:
Infrastructure:
Tools and frameworks:
Configuration:
local → login node → compute node) reaches code-server without exposing the HPC system.# Step 1: Submit code-server job (one time)sbatch ~/code-server-job.sh
# Step 2: Find compute nodesqueue -u $USER
# Step 3: Create SSH tunnel (from local machine)ssh -L 8080:worker-01:8080 user@hpc.server.edu
# Step 4: Access in browserhttp://localhost:8080
# Step 5: Run workflowsnextflow run main.nf -profile singularitynf-core workflownf-core createsqueue, sacct, sinfo)cat code-server-*.logssh user@hpc.server.edu ssh worker-01 hostnamepixi global install nextflow singularity nf-core nf-test

