From c4a1a9c457c6a6c7878efa97bda5810bd546a512 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Tue, 9 Sep 2025 15:01:41 +0200 Subject: [PATCH 01/11] WIP --- .icons/nextflow.svg | 6 ++ registry/coder/modules/nextflow/README.md | 22 +++++ registry/coder/modules/nextflow/main.tf | 106 ++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 .icons/nextflow.svg create mode 100644 registry/coder/modules/nextflow/README.md create mode 100644 registry/coder/modules/nextflow/main.tf diff --git a/.icons/nextflow.svg b/.icons/nextflow.svg new file mode 100644 index 000000000..bcc105532 --- /dev/null +++ b/.icons/nextflow.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/registry/coder/modules/nextflow/README.md b/registry/coder/modules/nextflow/README.md new file mode 100644 index 000000000..d214570a3 --- /dev/null +++ b/registry/coder/modules/nextflow/README.md @@ -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, worfklow, 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/nextflow/coder" + version = "0.9.0" + agent_id = coder_agent.example.id +} +``` diff --git a/registry/coder/modules/nextflow/main.tf b/registry/coder/modules/nextflow/main.tf new file mode 100644 index 000000000..00d6a52c7 --- /dev/null +++ b/registry/coder/modules/nextflow/main.tf @@ -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 = number + description = "Subdirectory for HTTP server reports, relative to the project path." + default = "reports" +} + +variable "checkout_demos" { + type = bool + description = "Checkout demos?" + default = false +} + +variable "stub_run" { + type = bool + description = "Execute a stub run?" + default = false +} + +variable "stub_run_command" { + type = string + description = "Shell command to be executed during the stub run." + default = "nextflow run . -stub-run" +} + +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, + CHECKOUT_DEMOS : var.checkout_demos, + 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 +} From c7a5908a73b6c06e2e954a21aa51aadac76d789a Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 12 Sep 2025 12:35:50 +0200 Subject: [PATCH 02/11] run.sh --- registry/coder/modules/nextflow/main.tf | 11 +---- registry/coder/modules/nextflow/run.sh | 53 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 9 deletions(-) create mode 100644 registry/coder/modules/nextflow/run.sh diff --git a/registry/coder/modules/nextflow/main.tf b/registry/coder/modules/nextflow/main.tf index 00d6a52c7..a2096d8be 100644 --- a/registry/coder/modules/nextflow/main.tf +++ b/registry/coder/modules/nextflow/main.tf @@ -38,12 +38,6 @@ variable "http_server_reports_dir" { default = "reports" } -variable "checkout_demos" { - type = bool - description = "Checkout demos?" - default = false -} - variable "stub_run" { type = bool description = "Execute a stub run?" @@ -52,8 +46,8 @@ variable "stub_run" { variable "stub_run_command" { type = string - description = "Shell command to be executed during the stub run." - default = "nextflow run . -stub-run" + 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" { @@ -86,7 +80,6 @@ resource "coder_script" "nextflow" { PROJECT_PATH : var.project_path, HTTP_SERVER_PORT : var.http_server_port, HTTP_SERVER_REPORTS_DIR : var.http_server_reports_dir, - CHECKOUT_DEMOS : var.checkout_demos, STUB_RUN : var.stub_run, STUB_RUN_COMMAND : var.stub_run_command, }) diff --git a/registry/coder/modules/nextflow/run.sh b/registry/coder/modules/nextflow/run.sh new file mode 100644 index 000000000..00e20eb4b --- /dev/null +++ b/registry/coder/modules/nextflow/run.sh @@ -0,0 +1,53 @@ +#!/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-18-jdk -y + sudo apt install 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 -f "$$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} +python3 -m http.server --directory ${HTTP_SERVER_REPORTS_DIR} ${HTTP_SERVER_PORT} + +# 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" + + From cb783bfd4ee4d231f7bcfe37faa23129e5cf1e99 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 12 Sep 2025 12:47:01 +0200 Subject: [PATCH 03/11] fix --- registry/coder/modules/nextflow/main.tf | 2 +- registry/coder/modules/nextflow/run.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/registry/coder/modules/nextflow/main.tf b/registry/coder/modules/nextflow/main.tf index a2096d8be..7d0f2b2ec 100644 --- a/registry/coder/modules/nextflow/main.tf +++ b/registry/coder/modules/nextflow/main.tf @@ -33,7 +33,7 @@ variable "http_server_port" { } variable "http_server_reports_dir" { - type = number + type = string description = "Subdirectory for HTTP server reports, relative to the project path." default = "reports" } diff --git a/registry/coder/modules/nextflow/run.sh b/registry/coder/modules/nextflow/run.sh index 00e20eb4b..f87c440ed 100644 --- a/registry/coder/modules/nextflow/run.sh +++ b/registry/coder/modules/nextflow/run.sh @@ -20,7 +20,7 @@ if ! command -v nextflow > /dev/null 2>&1; then sudo chmod +x /usr/local/bin/nextflow # Verify installation - tmp_verify=$$(mktemp -d coder-nextflow-XXXXXX) + tmp_verify=`mktemp -d coder-nextflow-XXXXXX` nextflow run hello \ -with-report "$$tmp_verify/report.html" \ -with-trace "$$tmp_verify/trace.txt" \ From d8272ead55d0e304e00b29b72f58d164101bfc91 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 12 Sep 2025 10:53:06 +0000 Subject: [PATCH 04/11] fmt --- registry/coder/modules/nextflow/run.sh | 56 ++++++++++++-------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/registry/coder/modules/nextflow/run.sh b/registry/coder/modules/nextflow/run.sh index f87c440ed..a5eb5ea4e 100644 --- a/registry/coder/modules/nextflow/run.sh +++ b/registry/coder/modules/nextflow/run.sh @@ -8,34 +8,33 @@ 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-18-jdk -y - sudo apt install 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 -f "$$tmp_verify" + # Update system dependencies + sudo apt update + sudo apt install openjdk-18-jdk -y + sudo apt install 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 -f "$$tmp_verify" else - echo "Nextflow is already installed\n\n" + 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} +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 @@ -43,11 +42,8 @@ mkdir -p ${HTTP_SERVER_REPORTS_DIR} python3 -m http.server --directory ${HTTP_SERVER_REPORTS_DIR} ${HTTP_SERVER_PORT} # Stub run? -if [ "${STUB_RUN}" = "true" ] -then - nextflow ${STUB_RUN_COMMAND} -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" - - From 08bf0b5d0b1fc3fd9aff98726d277eee2a8ca5c0 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 12 Sep 2025 13:51:22 +0200 Subject: [PATCH 05/11] typo --- registry/coder/modules/nextflow/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder/modules/nextflow/README.md b/registry/coder/modules/nextflow/README.md index d214570a3..2a434db15 100644 --- a/registry/coder/modules/nextflow/README.md +++ b/registry/coder/modules/nextflow/README.md @@ -3,7 +3,7 @@ display_name: Nextflow description: A module that adds Nextflow to your Coder template. icon: ../../../../.icons/nextflow.svg verified: true -tags: [nextflow, worfklow, hpc, bioinformatics] +tags: [nextflow, workflow, hpc, bioinformatics] --- # Nextflow From 3f355fc9c58e173a0e7dfc6a51e371ffe16e5f46 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Mon, 15 Sep 2025 13:59:51 +0200 Subject: [PATCH 06/11] fix: jdk --- registry/coder/modules/nextflow/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder/modules/nextflow/run.sh b/registry/coder/modules/nextflow/run.sh index a5eb5ea4e..0bbf134d7 100644 --- a/registry/coder/modules/nextflow/run.sh +++ b/registry/coder/modules/nextflow/run.sh @@ -10,7 +10,7 @@ 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-18-jdk -y + sudo apt install openjdk-21-jdk -y sudo apt install salmon fastqc multiqc -y # Install nextflow From 3a7ce2502cd9825f0a0cd232edd16dcb0507686d Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Mon, 15 Sep 2025 14:03:58 +0200 Subject: [PATCH 07/11] fix: rm --- registry/coder/modules/nextflow/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/registry/coder/modules/nextflow/run.sh b/registry/coder/modules/nextflow/run.sh index 0bbf134d7..db1b18007 100644 --- a/registry/coder/modules/nextflow/run.sh +++ b/registry/coder/modules/nextflow/run.sh @@ -26,7 +26,7 @@ if ! command -v nextflow > /dev/null 2>&1; then -with-trace "$$tmp_verify/trace.txt" \ -with-timeline "$$tmp_verify/timeline.html" \ -with-dag "$$tmp_verify/flowchart.png" - rm -f "$$tmp_verify" + rm -r "$$tmp_verify" else echo "Nextflow is already installed\n\n" fi From 2590a696b9b26412f3949c55ad5ad97426ee0558 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Mon, 15 Sep 2025 14:29:04 +0200 Subject: [PATCH 08/11] fix: var --- registry/coder/modules/nextflow/run.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/registry/coder/modules/nextflow/run.sh b/registry/coder/modules/nextflow/run.sh index db1b18007..a9d23f54e 100644 --- a/registry/coder/modules/nextflow/run.sh +++ b/registry/coder/modules/nextflow/run.sh @@ -22,11 +22,11 @@ if ! command -v nextflow > /dev/null 2>&1; then # 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" + -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 From cd1681ac944e58b1ff72b47b8cc722d501c6ecda Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Mon, 15 Sep 2025 14:34:57 +0200 Subject: [PATCH 09/11] fix --- registry/coder/modules/nextflow/run.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/registry/coder/modules/nextflow/run.sh b/registry/coder/modules/nextflow/run.sh index a9d23f54e..b1d376826 100644 --- a/registry/coder/modules/nextflow/run.sh +++ b/registry/coder/modules/nextflow/run.sh @@ -10,8 +10,7 @@ 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 -y - sudo apt install salmon fastqc multiqc -y + sudo apt install openjdk-21-jdk graphviz salmon fastqc multiqc -y # Install nextflow export NXF_VER=${NEXTFLOW_VERSION} @@ -39,7 +38,7 @@ fi # Start a web server to preview reports mkdir -p ${HTTP_SERVER_REPORTS_DIR} -python3 -m http.server --directory ${HTTP_SERVER_REPORTS_DIR} ${HTTP_SERVER_PORT} +python3 -m http.server --directory ${HTTP_SERVER_REPORTS_DIR} ${HTTP_SERVER_PORT} & # Stub run? if [ "${STUB_RUN}" = "true" ]; then From 1cf90c3c398f107e7f55f6485c03c0c210f58a3c Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Mon, 15 Sep 2025 14:42:55 +0200 Subject: [PATCH 10/11] output pipes --- registry/coder/modules/nextflow/main.tf | 7 +++++++ registry/coder/modules/nextflow/run.sh | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/registry/coder/modules/nextflow/main.tf b/registry/coder/modules/nextflow/main.tf index 7d0f2b2ec..306b21102 100644 --- a/registry/coder/modules/nextflow/main.tf +++ b/registry/coder/modules/nextflow/main.tf @@ -38,6 +38,12 @@ variable "http_server_reports_dir" { 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?" @@ -80,6 +86,7 @@ resource "coder_script" "nextflow" { 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, }) diff --git a/registry/coder/modules/nextflow/run.sh b/registry/coder/modules/nextflow/run.sh index b1d376826..83abbba5d 100644 --- a/registry/coder/modules/nextflow/run.sh +++ b/registry/coder/modules/nextflow/run.sh @@ -38,7 +38,8 @@ fi # Start a web server to preview reports mkdir -p ${HTTP_SERVER_REPORTS_DIR} -python3 -m http.server --directory ${HTTP_SERVER_REPORTS_DIR} ${HTTP_SERVER_PORT} & +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 From f642ab3501533498dcf77e90b5f650253edacd0c Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Thu, 18 Sep 2025 09:45:17 +0200 Subject: [PATCH 11/11] Move to coder-labs --- registry/{coder => coder-labs}/modules/nextflow/README.md | 2 +- registry/{coder => coder-labs}/modules/nextflow/main.tf | 0 registry/{coder => coder-labs}/modules/nextflow/run.sh | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename registry/{coder => coder-labs}/modules/nextflow/README.md (88%) rename registry/{coder => coder-labs}/modules/nextflow/main.tf (100%) rename registry/{coder => coder-labs}/modules/nextflow/run.sh (100%) diff --git a/registry/coder/modules/nextflow/README.md b/registry/coder-labs/modules/nextflow/README.md similarity index 88% rename from registry/coder/modules/nextflow/README.md rename to registry/coder-labs/modules/nextflow/README.md index 2a434db15..7a62a3ab8 100644 --- a/registry/coder/modules/nextflow/README.md +++ b/registry/coder-labs/modules/nextflow/README.md @@ -15,7 +15,7 @@ A module that adds Nextflow to your Coder template. ```tf module "nextflow" { count = data.coder_workspace.me.start_count - source = "registry.coder.com/coder/nextflow/coder" + source = "registry.coder.com/coder-labs/nextflow/coder" version = "0.9.0" agent_id = coder_agent.example.id } diff --git a/registry/coder/modules/nextflow/main.tf b/registry/coder-labs/modules/nextflow/main.tf similarity index 100% rename from registry/coder/modules/nextflow/main.tf rename to registry/coder-labs/modules/nextflow/main.tf diff --git a/registry/coder/modules/nextflow/run.sh b/registry/coder-labs/modules/nextflow/run.sh similarity index 100% rename from registry/coder/modules/nextflow/run.sh rename to registry/coder-labs/modules/nextflow/run.sh