Skip to content

Commit 081f18f

Browse files
committed
js_sandbox: use smaller node:alpine image
1 parent 4a26c64 commit 081f18f

File tree

7 files changed

+25
-12
lines changed

7 files changed

+25
-12
lines changed

.github/workflows/ci-tests.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ jobs:
124124
wget --no-verbose https://github.com/sylabs/singularity/releases/download/v3.10.4/singularity-ce_3.10.4-jammy_amd64.deb
125125
sudo apt-get install -y ./singularity-ce_3.10.4-jammy_amd64.deb
126126
127+
- name: pull some containers
128+
run: |
129+
export CWL_SINGULARITY_CACHE=$(echo $GITHUB_WORKSPACE)/singularity_cache
130+
mkdir -p ${CWL_SINGULARITY_CACHE}
131+
singularity pull --name ${CWL_SINGULARITY_CACHE}/node_alpine.sif docker://docker.io/node:alpine
132+
ls -lh ${CWL_SINGULARITY_CACHE}
133+
echo ${CWL_SINGULARITY_CACHE}
134+
echo "CWL_SINGULARITY_CACHE=${CWL_SINGULARITY_CACHE}" >> $GITHUB_ENV
135+
127136
- name: Set up Python
128137
uses: actions/setup-python@v4
129138
with:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ diff-cover.html: coverage.xml
152152

153153
## test : run the cwl-utils test suite
154154
test: $(PYSOURCES)
155-
python -m pytest -rs ${PYTEST_EXTRA}
155+
python -m pytest -rsx ${PYTEST_EXTRA}
156156

157157
## testcov : run the cwl-utils test suite and collect coverage
158158
testcov: $(PYSOURCES)

cwl_utils/cwl_v1_0_expression_refactor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def etool_to_cltool(
190190
)
191191
listing = [cwl.Dirent(entryname="expression.js", entry=contents, writable=None)]
192192
iwdr = cwl.InitialWorkDirRequirement(listing)
193-
containerReq = cwl.DockerRequirement(dockerPull="node:slim")
193+
containerReq = cwl.DockerRequirement(dockerPull="node:alpine")
194194
softwareHint = cwl.SoftwareRequirement(
195195
packages=[cwl.SoftwarePackage(package="nodejs")]
196196
)

cwl_utils/cwl_v1_1_expression_refactor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def etool_to_cltool(
190190
)
191191
listing = [cwl.Dirent(entryname="expression.js", entry=contents, writable=None)]
192192
iwdr = cwl.InitialWorkDirRequirement(listing)
193-
containerReq = cwl.DockerRequirement(dockerPull="node:slim")
193+
containerReq = cwl.DockerRequirement(dockerPull="node:alpine")
194194
softwareHint = cwl.SoftwareRequirement(
195195
packages=[cwl.SoftwarePackage(package="nodejs")]
196196
)

cwl_utils/cwl_v1_2_expression_refactor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def etool_to_cltool(
190190
)
191191
listing = [cwl.Dirent(entryname="expression.js", entry=contents, writable=None)]
192192
iwdr = cwl.InitialWorkDirRequirement(listing)
193-
containerReq = cwl.DockerRequirement(dockerPull="node:slim")
193+
containerReq = cwl.DockerRequirement(dockerPull="node:alpine")
194194
softwareHint = cwl.SoftwareRequirement(
195195
packages=[cwl.SoftwarePackage(package="nodejs")]
196196
)

cwl_utils/sandboxjs.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def new_js_proc(
307307

308308
if nodejs is None or nodejs is not None and required_node_version is False:
309309
try:
310-
nodeimg = "docker.io/node:slim"
310+
nodeimg = "docker.io/node:alpine"
311311
if container_engine == "singularity":
312312
nodeimg = f"docker://{nodeimg}"
313313

@@ -322,10 +322,14 @@ def new_js_proc(
322322
singularity_cache = os.environ.get("CWL_SINGULARITY_CACHE")
323323
if singularity_cache:
324324
singularityimgs = glob.glob(
325-
singularity_cache + "/node_slim.sif"
325+
singularity_cache + "/node_alpine.sif"
326326
)
327327
else:
328-
singularityimgs = glob.glob(os.getcwd() + "/node_slim.sif")
328+
singularityimgs = glob.glob(
329+
os.getcwd() + "/node_alpine.sif"
330+
)
331+
if singularityimgs:
332+
nodeimg = singularityimgs[0]
329333
else:
330334
raise Exception(
331335
f"Unknown container_engine: {container_engine}."
@@ -338,7 +342,7 @@ def new_js_proc(
338342
len(dockerimgs.split("\n")) <= 1
339343
)
340344
if need_singularity or need_docker or force_docker_pull:
341-
# pull node:slim docker container
345+
# pull node:alpine docker container
342346
nodejs_pull_commands = [container_engine, "pull"]
343347
if force_docker_pull:
344348
nodejs_pull_commands.append("--force")
@@ -400,15 +404,15 @@ def new_js_proc(
400404
pass
401405
else:
402406
raise
403-
except subprocess.CalledProcessError:
404-
pass
407+
except subprocess.CalledProcessError as e:
408+
_logger.debug("Error while attempting to run nodejs: %s", e)
405409

406410
# docker failed and nodejs not on system
407411
if nodejs is None:
408412
raise JavascriptException(
409413
"NodeJSEngine requires Node.js engine to evaluate and validate "
410414
"Javascript expressions, but couldn't find it. Tried {trynodes}, "
411-
f"{container_engine} run node:slim".format(
415+
f"{container_engine} run node:alpine".format(
412416
trynodes=", ".join(trynodes), container_engine=container_engine
413417
)
414418
)

tests/test_js_sandbox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def test_singularity_cache(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> N
154154
)
155155
== 42 * 23
156156
)
157-
assert (cache_path / "node_slim.sif").exists()
157+
assert (cache_path / "node_alpine.sif").exists()
158158

159159

160160
def test_caches_js_processes(mocker: Any) -> None:

0 commit comments

Comments
 (0)