-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into develop-rnd
- Loading branch information
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# docker:dind Dockerfile: https://github.com/docker-library/docker/blob/master/Dockerfile-dind.template | ||
# FROM docker:dind | ||
FROM docker:25.0.3-dind | ||
|
||
# install Python | ||
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python | ||
RUN apk add gcc musl-dev linux-headers python3-dev | ||
RUN apk add --no-cache python3 py3-pip | ||
RUN apk add vim | ||
|
||
# install CWL libraries | ||
RUN mkdir /usr/share/cwl \ | ||
&& cd /usr/share/cwl \ | ||
&& python -m venv venv \ | ||
&& source venv/bin/activate \ | ||
&& pip install cwltool cwl-runner docker boto3 awscli | ||
|
||
# install nodejs to parse Javascript in CWL files | ||
RUN apk add --no-cache nodejs npm | ||
|
||
# script to execute a generic CWL workflow with arguments | ||
COPY docker_cwl_entrypoint.sh /usr/share/cwl/docker_cwl_entrypoint.sh | ||
|
||
WORKDIR /usr/share/cwl | ||
ENTRYPOINT ["/usr/share/cwl/docker_cwl_entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
# Script to execute a CWL workflow that includes Docker containers | ||
# The Docker engine is started before the CWL execution, and stopped afterwards. | ||
# $1: the CWL workflow URL (example: https://raw.githubusercontent.com/unity-sds/unity-sps-prototype/cwl-docker/cwl/cwl_workflows/echo_from_docker.cwl) | ||
# $2: the CWL job parameters as a JSON formatted string (example: { name: John Doe }) | ||
# $3: optional output directory, defaults to the current directory | ||
# Note: $output_dir must be accessible by the Docker container that executes this script | ||
|
||
set -ex | ||
cwl_workflow=$1 | ||
job_args=$2 | ||
output_dir=${3:-.} | ||
echo "Executing CWL workflow: $cwl_workflow with json arguments: $job_args and output directory: $output_dir" | ||
echo "$job_args" > /tmp/job_args.json | ||
cat /tmp/job_args.json | ||
|
||
# create output directory if it doesn't exist | ||
mkdir -p "$output_dir" | ||
|
||
# Start Docker engine | ||
dockerd > dockerd-logfile 2>&1 | ||
|
||
# Wait until Docker engine is running | ||
# Loop until 'docker version' exits with 0. | ||
until docker version > /dev/null 2>&1 | ||
do | ||
sleep 1 | ||
done | ||
|
||
# Execute CWL workflow | ||
. /usr/share/cwl/venv/bin/activate | ||
cwl-runner --outdir "$output_dir" --no-match-user --no-read-only "$cwl_workflow" /tmp/job_args.json | ||
deactivate | ||
|
||
# Stop Docker engine | ||
pkill -f dockerd |