Custom Docker Action can't find node script #25167
-
I have been trying to setup a GitHub Action that runs a single node script (called index.js). This script has a node module as dependency, which is why I am not able to run it as a Javascript action and wanted to try using docker for the first time ever. Now GitHub Actions executes my dockerfile and sets up the container. Copying the package(-lock).json files and installing them via npm ci works perfectly. I then copy the script in the same directory and set the entrypoint accordingly.
When GitHub Actions then runs the container after building it, it automatically sets the working directory to /github/workspace, which is why I have replicated this in my Dockerfile ( WORKDIR /github/workspace/ ). Using the unelegant ls outputs (forgive me, I’m new to Linux scripting in general), I can verify that the script and node_modules folder are located in /github/workspace/ . When the container is then run, it instantly terminates with the following error:
This suggests that the file does not exist. The debug output I added when building the container shows me otherwise though (root directory shortened for legibility):
Am I missing something obvious here? When I build the docker container locally and then execute it, it works perfectly fine. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @muhlex , Please don’t set the working directory to /github/workspace in the action Dockerfile. You could just copy it to the root path. Please try to the method below:
|
Beta Was this translation helpful? Give feedback.
-
Thanks a lot. That actually does it. I tried doing it that way from the beginning but probably messed up something in regards to relative and absolute file paths. |
Beta Was this translation helpful? Give feedback.
Hi @muhlex ,
Please don’t set the working directory to /github/workspace in the action Dockerfile. You could just copy it to the root path. Please try to the method below: