Skip to content

Commit

Permalink
feat(docker): use host network instead of docker bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
pbelmann committed Oct 28, 2024
1 parent 7fb762b commit cf5c770
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 12 deletions.
5 changes: 5 additions & 0 deletions lib/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class Utils {
}
}

static String getDockerNetwork(){
return " --net=host ";
}


static String getCreateDatabaseDirCommand(db){
return "if [ ! -z " + db + " ]; then mkdir " + db + " -p; fi"
}
Expand Down
11 changes: 6 additions & 5 deletions modules/annotation/module.nf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ process pMMseqs2 {
// Another mount flag is used to get a key file (aws format) into the docker-container.

// This file is then used by s5cmd. The necessary mount points are generated by “constructParametersObject()”.
containerOptions constructParametersObject("mmseqs2") + " --entrypoint='' "
containerOptions constructParametersObject("mmseqs2") + " --entrypoint='' " + Utils.getDockerNetwork()

tag "Sample: $sample, Database: $dbType"

Expand Down Expand Up @@ -104,7 +104,7 @@ process pMMseqs2_taxonomy {
// Therefore this place has to be mounted to the docker container to be accessible during run time.
// Another mount flag is used to get a key file (aws format) into the docker-container.
// This file is then used by s5cmd. The necessary mount points are generated by “constructParametersObject()”.
containerOptions constructParametersObject("mmseqs2_taxonomy") + " --entrypoint='' "
containerOptions constructParametersObject("mmseqs2_taxonomy") + " --entrypoint='' " + Utils.getDockerNetwork()

tag "Sample: $sample, Database_taxonomy: $dbType"

Expand Down Expand Up @@ -148,7 +148,7 @@ process pResistanceGeneIdentifier {

container "${params.rgi_image}"

containerOptions Utils.getDockerMount(params?.steps?.annotation?.rgi?.database, params)
containerOptions Utils.getDockerMount(params?.steps?.annotation?.rgi?.database, params) + Utils.getDockerNetwork()

tag "Sample: $sample, BinID: $binID"

Expand Down Expand Up @@ -296,7 +296,7 @@ process pHmmSearch {
// Re-Use the gtdb-tk container for Prodigal to safe space
container "${params.gtdbtk_image}"

containerOptions Utils.getDockerMount(params?.steps?.binning?.magscot?.hmmSearch?.database, params)
containerOptions Utils.getDockerMount(params?.steps?.binning?.magscot?.hmmSearch?.database, params) + Utils.getDockerNetwork()

tag "Sample: $sample"

Expand Down Expand Up @@ -370,7 +370,8 @@ process pKEGGFromMMseqs2 {
// Another mount flag is used to get a key file (aws format) into the docker-container.
// This file is then used by s5cmd.

containerOptions Utils.getDockerMount(params.steps?.annotation?.keggFromMMseqs2?.database, params)
containerOptions Utils.getDockerMount(params.steps?.annotation?.keggFromMMseqs2?.database, params) + Utils.getDockerNetwork()

publishDir params.output, mode: "${params.publishDirMode}", saveAs: { filename -> getOutput("${sample}", params.runid, "keggFromMMseqs2", filename) }, \
pattern: "{**.tsv}"

Expand Down
2 changes: 2 additions & 0 deletions modules/fragmentRecruitment/mashScreen.nf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ process pMashScreen {

container "${params.mash_image}"

containerOptions Utils.getDockerNetwork()

when params?.steps?.fragmentRecruitment?.mashScreen != null

input:
Expand Down
6 changes: 3 additions & 3 deletions modules/magAttributes/module.nf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ process pCheckM {
when params.steps.containsKey("magAttributes") && params.steps.magAttributes.containsKey("checkm") \
&& !params.steps.magAttributes.containsKey("checkm2")

containerOptions Utils.getDockerMount(params.steps?.magAttributes?.checkm?.database, params)
containerOptions Utils.getDockerMount(params.steps?.magAttributes?.checkm?.database, params) + Utils.getDockerNetwork()

beforeScript Utils.getCreateDatabaseDirCommand("${params.polished.databases}")

Expand Down Expand Up @@ -88,7 +88,7 @@ process pCheckM2 {

when params.steps.containsKey("magAttributes") && params.steps.magAttributes.containsKey("checkm2")

containerOptions Utils.getDockerMount(params.steps?.magAttributes?.checkm2?.database, params)
containerOptions Utils.getDockerMount(params.steps?.magAttributes?.checkm2?.database, params) + Utils.getDockerNetwork()

beforeScript "mkdir -p ${params.polished.databases}"

Expand Down Expand Up @@ -128,7 +128,7 @@ process pGtdbtk {

when params.steps.containsKey("magAttributes") && params.steps.magAttributes.containsKey("gtdb")

containerOptions Utils.getDockerMount(params?.steps?.magAttributes?.gtdb?.database, params)
containerOptions Utils.getDockerMount(params?.steps?.magAttributes?.gtdb?.database, params) + Utils.getDockerNetwork()

beforeScript Utils.getCreateDatabaseDirCommand("${params.polished.databases}")

Expand Down
2 changes: 1 addition & 1 deletion modules/plasmids/module.nf
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ process pPLSDB {
saveAs: { filename -> getOutput("${sample}", params.runid, "PLSDB", filename) }, \
pattern: "{**.tsv}"

containerOptions Utils.getDockerMount(params.steps?.plasmid?.PLSDB?.database, params)
containerOptions Utils.getDockerMount(params.steps?.plasmid?.PLSDB?.database, params) + Utils.getDockerNetwork()

when params.steps.containsKey("plasmid") && params.steps.plasmid.containsKey("PLSDB")

Expand Down
6 changes: 3 additions & 3 deletions modules/plasmids/processes.nf
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ process pViralVerifyPlasmid {

shell = ['/bin/bash']

containerOptions Utils.getDockerMount(params?.steps?.plasmid?.ViralVerifyPlasmid?.database, params)
containerOptions Utils.getDockerMount(params?.steps?.plasmid?.ViralVerifyPlasmid?.database, params) + Utils.getDockerNetwork()

container "${params.viralVerify_image}"

Expand Down Expand Up @@ -121,7 +121,7 @@ process pMobTyper {

beforeScript Utils.getCreateDatabaseDirCommand("${params.polished.databases}")

containerOptions Utils.getDockerMount(params.steps?.plasmid?.MobTyper?.database, params)
containerOptions Utils.getDockerMount(params.steps?.plasmid?.MobTyper?.database, params) + Utils.getDockerNetwork()

secret { "${S3_MobTyper_ACCESS}"!="" ? ["S3_MobTyper_ACCESS", "S3_MobTyper_SECRET"] : [] }

Expand Down Expand Up @@ -183,7 +183,7 @@ process pPlaton {

tag "Sample: $sample, BinId: $binID"

containerOptions " --user root:root " + Utils.getDockerMount(params.steps?.plasmid?.Platon?.database, params)
containerOptions " --user root:root " + Utils.getDockerMount(params.steps?.plasmid?.Platon?.database, params) + Utils.getDockerNetwork()

publishDir params.output, mode: "${params.publishDirMode}", saveAs: { filename -> getOutput("${sample}", params.runid, "Platon", filename) }, \
pattern: "{**.tsv}"
Expand Down
2 changes: 2 additions & 0 deletions modules/qualityControl/ontQC.nf
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ process pPorechopDownload {

container "${params.porechop_image}"

containerOptions Utils.getDockerNetwork()

input:
tuple val(sample), env(readUrl)

Expand Down
2 changes: 2 additions & 0 deletions modules/qualityControl/shortReadQC.nf
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ process pFastpSplitDownload {

container "${params.fastp_image}"

containerOptions Utils.getDockerNetwork()

input:
tuple val(sample), env(read1Url), env(read2Url)

Expand Down

0 comments on commit cf5c770

Please sign in to comment.