act: command not found (in image node:12.6-buster-slim, as opposed to GH Actions)
Hi,
as documented here GitHub configures passwordless sudo, so I can have sudo in my shell scripts to perform individual commands as root.
Given this minimal workflow:
on: push
name: Test
jobs:
build:
runs-on: ubuntu-latest
steps:
- run: sudo id
The result on Actions is uid=0(root) gid=0(root) groups=0(root)
Running this workflow in act
yields this result:
$ act
[Test/build] 🚀 Start image=node:12.6-buster-slim
[Test/build] 🐳 docker run image=node:12.6-buster-slim entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
[Test/build] 🐳 docker cp src=/Users/fwilhe/temp/test-actions/. dst=/github/workspace
[Test/build] ⭐ Run sudo id
| /github/workflow/0: line 2: sudo: command not found
[Test/build] ❌ Failure - sudo id
Error: exit with `FAILURE`: 127
Not sure what the most elegant solution would be without re-building the node:12.6-buster-slim
image to install sudo and configure it passwordless. But I think the goal should be to be 1:1 compatible with actions, if possible.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 30
- Comments: 45 (23 by maintainers)
seems like git is not inside the node:12.6-buster-slim image either. Which is counter intuitive.
Maybe act could use a <Github-runner-name>.Dockerfile that the user can customize to make sure whatever tools they need is available in the used image. This could live in
~/.act/
or the current project directory?See https://github.com/nektos/act#runners.
You can customize the image used for the runs-on. I’ve created an image that is a match to GitHub runners, but its like 15GB!
Why isn’t the
gh
command installed though?So I tried using the medium instead of slim for git, but noticed medium doesn’t have yarn 😕
Ok, so I’ve been thinking a bit and came up with this
node:12.6-buster-slim
(we could build upon that image to add below image env vars but leave it with just node.js, to make it a bit more compatible)ubuntu:act-*
, includes required env vars for some software setup (likeruby/setup-ruby
), includes more tools (gawk
,curl
,git
,ssh
,etc.)nektos/act-environments-ubuntu:18.04
big
and mine aslarge
(quay.io/catthehacker/virtual-environments | https://github.com/CatTheHacker/virtual-environments)Looking for feedback/suggestions
Yes, I agree. But the initial argument against using the huge github image seems to be its size. Such tools as
make
are tiny and are incredibly popular in this context, so it’s not clear to me what’s the practical motivation of not including it into the default image.In my opinion, most of the people interested in this project are interested in it because they already use github actions in their projects, not the other way around. Asking them to change their existing CI configuration (especially on a company/organization level) just to be able to test it with a particular tool doesn’t seem to be practical.
Just my opinion though.
Don’t use GitHub actions or run full GitHub Actions docker image then.
I wonder if there’s a way we could make an intermediary image that has 90% of the needed CLI tools for 10% of the footprint of the giant image. The only way we could reasonably do that (beyond intuition) is scanning a corpus of public GH Actions and seeing what works.
Then again, maybe it would give people a false sense of security as these issues would crop up less often - so it would be “stranger” and more likely to result in bug reports. 🤔
Not sure if this is useful for anyone, but out of curiosity I’ve tried to build a ‘minimal’ runner image based on github’s packer scripts. The repo is here, the image is published to DockerHub both for x86 and arm.
The idea is to keep the pre-installed amount of tools low because I assume most workflows anyway use
setup-*
actions.I know about existing images, but maybe mine fill a gap and are useful for some people?
Let me know if this is useful to you.
I think at least the documentation should be updated, it currently states “The environment variables and filesystem are all configured to match what GitHub provides.” but should say that that is only the case if you use this non-default image.
I think that docker for mac/windows is actually not very good with large images, but that an 18GB image in general isn’t that crazy given the high speed internet and large disks available today.
I’m not the author of act, so I can only guess that the motivation is to use an off-the-shelf image, and not to build one and then discuss with everyone what should be included or not.
No, I’m not asking anyone to do that, I just say what worked for me.
Tough problem. The runners that GitHub Actions offers are huge. I didn’t feel right using an 18GB image as the default, requiring users of
act
to download that large of an image to run it.I chose the
node
image because it was required to run node actions and still light enough. Not sure how to proceed…not sure what good enough looks like for the default docker image.Open to ideas 🙏
Hi @cplee
thanks for the work you put into this.
I know that the image is configurable, and I’ve locally tested with an image where I installed sudo. So this is kind of a workaround, but the reason I opened this issue is that this limits compatibility with workflows that run on GitHub. My intention was to point out where the documented (and actual) behavior of Actions is unequal the default of
act
, which makes it less useful compared to what it could be.As mentioned I’m not sure what solution I would propose, as maintaining separate images seems inappropriate.
@catthehacker: I will feature nektos/act in GitHub’s upcoming summer fest. I figured you are in a similar time zone and might be interested in listening in. Here is the registration link (everybody is welcome - and there will be :octocat: swag for the first 200 registrants): https://resources.github.com/webcasts/Summerfest-2021-South-Europe/
I would use already existing exit code
127
which stands for command not found but I will usecommand-not-found
or write small Go program to make proper error message and add it to image.@jonico that’s an amazing idea, I’ll try to work on that.
It would be really nice if there were clear instructions on how a user can build and enable an image of their own that matches the one used by github. Here’s are two clear question to answer:
@tyeth Would something like this be okay?
I propose we offer the large or slim image upon initial install (I used choco) and also include a configuration command (
act --default-image slim/github/other
) with the addition of--global
affecting all images not the current workspace. Or something along those lines.I’m just here to avoid never using act again because like mentioned above the readme clearly states it just works out the box and matches github actions like for like but locally in docker. This is not the case, and as a lazy user (I’d imagine 90% of your userbase) I would be happy to be asked once during install or just have to set my preferred default once and forget it. But to be honest I’m confused. In my head if you take the same docker image as github does and the action specify then yes it would be large but that’s what the user signed up for. Still I feel your pain and appreciate the idea of slim by default. Also I dislike installers that don’t have command line options like
-y
to answer yes to everything.Separately, nice to see a healthy community and thanks for all the hard work / input all. Can’t wait to see this move forward, but I’d be keen to hear if anyone had similar utility by using the official local github build agent, I imagine that’s probably accessible/hackable enough (able to get access to terminal and files).
see #196 for discussion on creating a slim runner
@catthehacker: Wonderful 😻 - I would suggest to change the error message to “Please see https://github.com/nektos/act/issues/107 for potential reasons and solutions.” but this is probably just 🚲 shedding 😊
I was debugging another issue and wanted to check if the large image would solve it. It looks like I’m stuck with the micro image that I’ve chosen at the very first install. Is there a way to force-reset to the large one?
I’ve tried a bunch of things:
act
~/.actrc
~/.cache/act
-P ...
with the commandAfter reinstalling it fails almost instantly and never attempts to download the large image, and it looks like
containers
section of the workflow overrides theruns-on
.Logs
I think that’s fair @CatTheHacker . If possible, I would like to see another Small image with essential Unix tools such as
sudo
,curl
,awk
, etc.Got the same issue on NixOS, running this simple workflow.
I guess there is not enough agreement on what is “common”. In the end you would include everything that github installs in the runner, which @cplee already did in that 20 gig image.
I have to say that building my own “runtime” image worked well for me.
The nice thing with that image is that you can also use it to run the whole action in via
and to not rely on any “setup” actions. That makes it much easier to reproduce the github build on your local machine using
act
.Hope that helps.