add: nextflow module (#416)

This commit is contained in:
Marcin Tojek 2025-09-18 11:30:48 +02:00 committed by GitHub
parent cb990bbee0
commit 54b9bf3038
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 183 additions and 0 deletions

6
.icons/nextflow.svg Normal file
View File

@ -0,0 +1,6 @@
<svg width="251" height="251" viewBox="0 0 251 251" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 47.0195C39.45 49.6394 71.06 81.3272 73.54 120.815H119.61C117.05 55.8589 64.93 3.64245 0 0.942627V47.0195Z" fill="#0DC09D"/>
<path d="M73.8 131.324C71.18 170.771 39.49 202.379 0 204.859V250.926C64.96 248.366 117.18 196.249 119.88 131.324H73.8Z" fill="#0DC09D"/>
<path d="M176.201 120.545C178.821 81.0972 210.511 49.4894 250.001 47.0095V0.942627C185.041 3.50245 132.821 55.619 130.121 120.545H176.201Z" fill="#0DC09D"/>
<path d="M250.001 204.849C210.551 202.229 178.941 170.542 176.461 131.054H130.391C132.951 196.01 185.071 248.226 250.001 250.926V204.849Z" fill="#0DC09D"/>
</svg>

After

Width:  |  Height:  |  Size: 693 B

View File

@ -0,0 +1,22 @@
---
display_name: Nextflow
description: A module that adds Nextflow to your Coder template.
icon: ../../../../.icons/nextflow.svg
verified: true
tags: [nextflow, workflow, hpc, bioinformatics]
---
# Nextflow
A module that adds Nextflow to your Coder template.
![Nextflow](../../.images/nextflow.png)
```tf
module "nextflow" {
count = data.coder_workspace.me.start_count
source = "registry.coder.com/coder-labs/nextflow/coder"
version = "0.9.0"
agent_id = coder_agent.example.id
}
```

View File

@ -0,0 +1,106 @@
terraform {
required_version = ">= 1.0"
required_providers {
coder = {
source = "coder/coder"
version = ">= 2.5"
}
}
}
# Add required variables for your modules and remove any unneeded variables
variable "agent_id" {
type = string
description = "The ID of a Coder agent."
}
variable "nextflow_version" {
type = string
description = "Nextflow version"
default = "25.04.7"
}
variable "project_path" {
type = string
description = "The path to Nextflow project, it will be mounted in the container."
}
variable "http_server_port" {
type = number
description = "The port to run HTTP server on."
default = 9876
}
variable "http_server_reports_dir" {
type = string
description = "Subdirectory for HTTP server reports, relative to the project path."
default = "reports"
}
variable "http_server_log_path" {
type = string
description = "HTTP server logs"
default = "/tmp/nextflow_reports.log"
}
variable "stub_run" {
type = bool
description = "Execute a stub run?"
default = false
}
variable "stub_run_command" {
type = string
description = "Nextflow command to be executed in the stub run."
default = "run rnaseq-nf -with-report reports/report.html -with-trace reports/trace.txt -with-timeline reports/timeline.html -with-dag reports/flowchart.png"
}
variable "order" {
type = number
description = "The order determines the position of app in the UI presentation. The lowest order is shown first and apps with equal order are sorted by name (ascending order)."
default = null
}
variable "share" {
type = string
default = "owner"
validation {
condition = var.share == "owner" || var.share == "authenticated" || var.share == "public"
error_message = "Incorrect value. Please set either 'owner', 'authenticated', or 'public'."
}
}
variable "group" {
type = string
description = "The name of a group that this app belongs to."
default = null
}
resource "coder_script" "nextflow" {
agent_id = var.agent_id
display_name = "nextflow"
icon = "/icon/nextflow.svg"
script = templatefile("${path.module}/run.sh", {
NEXTFLOW_VERSION : var.nextflow_version,
PROJECT_PATH : var.project_path,
HTTP_SERVER_PORT : var.http_server_port,
HTTP_SERVER_REPORTS_DIR : var.http_server_reports_dir,
HTTP_SERVER_LOG_PATH : var.http_server_log_path,
STUB_RUN : var.stub_run,
STUB_RUN_COMMAND : var.stub_run_command,
})
run_on_start = true
}
resource "coder_app" "nextflow" {
agent_id = var.agent_id
slug = "nextflow-reports"
display_name = "Nextflow Reports"
url = "http://localhost:${var.http_server_port}"
icon = "/icon/nextflow.svg"
subdomain = true
share = var.share
order = var.order
group = var.group
}

View File

@ -0,0 +1,49 @@
#!/usr/bin/env sh
set -eu
BOLD='\033[0;1m'
RESET='\033[0m'
printf "$${BOLD}Starting Nextflow...$${RESET}\n"
if ! command -v nextflow > /dev/null 2>&1; then
# Update system dependencies
sudo apt update
sudo apt install openjdk-21-jdk graphviz salmon fastqc multiqc -y
# Install nextflow
export NXF_VER=${NEXTFLOW_VERSION}
curl -s https://get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
sudo chmod +x /usr/local/bin/nextflow
# Verify installation
tmp_verify=$(mktemp -d coder-nextflow-XXXXXX)
nextflow run hello \
-with-report "$${tmp_verify}/report.html" \
-with-trace "$${tmp_verify}/trace.txt" \
-with-timeline "$${tmp_verify}/timeline.html" \
-with-dag "$${tmp_verify}/flowchart.png"
rm -r "$${tmp_verify}"
else
echo "Nextflow is already installed\n\n"
fi
if [ ! -z ${PROJECT_PATH} ]; then
# Project is located at PROJECT_PATH
echo "Change directory: ${PROJECT_PATH}"
cd ${PROJECT_PATH}
fi
# Start a web server to preview reports
mkdir -p ${HTTP_SERVER_REPORTS_DIR}
echo "Starting HTTP server in background, check logs: ${HTTP_SERVER_LOG_PATH}"
python3 -m http.server --directory ${HTTP_SERVER_REPORTS_DIR} ${HTTP_SERVER_PORT} > "${HTTP_SERVER_LOG_PATH}" 2>&1 &
# Stub run?
if [ "${STUB_RUN}" = "true" ]; then
nextflow ${STUB_RUN_COMMAND} -stub-run
fi
printf "\n$${BOLD}Nextflow ${NEXTFLOW_VERSION} is ready. HTTP server is listening on port ${HTTP_SERVER_PORT}$${RESET}\n"