-
YESSSS to this. Been waiting for ages. Question regarding nodejs support. How do you support nodejs scripts? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi Michele! Thanks for the enthusiasm :-) For nodejs, node is just a command-line tool, so the Action could just look like: onRun:
command: node
args:
- <path to your app.js> Where Docker would be similar. The specification doesn't have a syntactic simplification to instruct it to run a command inside of a docker container, but docker is just something that you can run on the command-line so you could write a shell script to do it. Something like this as the actions:
onRun:
command: bash
args: [ "{{Task.File.DockerTest}" ]
embeddedFiles:
- name: DockerTest
type: TEXT
data: |
#!/bin/bash
# Start docker running in the background (this could also be done with nohup and as part of an Environment's onEnter)
docker run --rm --name test_run ubuntu:24.04 /bin/bash -c "while true; do sleep 10; done" &
# Copy the shell script into the container
docker container cp {{Task.File.ScriptToRun}} test_run:/tmp/script.sh
# Run the script in the container
docker exec test_run bash /tmp/script.sh
# Stop the container (if it was started in an Environment onEnter, then this would be done in the onExit of the same Environment)
docker stop test_run
- name: ScriptToRun
type: TEXT
data: |
#!/bin/bash
echo "Hi there from inside a docker container!" I've also added a docker example that uses environments to the samples in this repository (the pull-request is here) |
Beta Was this translation helpful? Give feedback.
Hi Michele! Thanks for the enthusiasm :-)
For nodejs, node is just a command-line tool, so the Action could just look like:
Where
<path to your app.js>
could be a reference to an embedded file (example), or a file on a shared filesystem.Docker would be similar. The specification doesn't have a syntactic simplification to instruct it to run a command inside of a docker container, but docker is just something that you can run on the command-line so you could write a shell script to do it. Something like this as the
script
element of a Step could be a starting point: