nektos / act

Run your GitHub Actions locally 🚀
https://nektosact.com
MIT License
55.1k stars 1.38k forks source link

Using -P platform with local image #1633

Open dannystaple opened 1 year ago

dannystaple commented 1 year ago

Act version

0.2.42

Feature description

I would like to be able to use a local image for the -P flag. For example:

act --eventpath myevent.json \
  -P ubuntu-latest=my-local-latest

The intent would be to take the medium image and add other parts I might need, for example the python components if the intent is to test pipelines around the python ecosystem.

Currently running this, it will force pull from a remote on dockerhub, however, this may simply be a local image that I do not intend to put onto dockerhub.

ChristopherHX commented 1 year ago

Use --pull=false. The reason that this flag now defaults to true is a breaking change in act with older default docker images.

You have to manually keep uptodate, if you use this flag.

dannystaple commented 1 year ago

Worked a treat - just updating the docs to reflect that.

joanrodriguez commented 1 year ago

Hey, the flag doesn't work for me if I never uploaded the image to Docker Hub....

Steps to reproduce:

Do I make a mistake with the flags or the feature doesn't exist?

ChristopherHX commented 1 year ago

I cannot reproduce your error. You should see forcePull=false in the log and if act finds you image it will use it.

forcePull=true will always pull the image (--pull) forcePull=false will pull the image if missing (--pull=false)

dannystaple commented 1 year ago

@joanrodriguez I take it the line continuation characters are not posted just for aesthetics or that this was all on one line? Can you show the docker image in docker list. It isn't looking for a local arm64 image when you have a x86 image is it?

joanrodriguez commented 1 year ago

Hey guys, I had some conflicting stuff in my .~/.actrc. After emptying it and removing the architecture arg, I'm able to use a local docker image :)

$ docker images
REPOSITORY                                    TAG                        IMAGE ID       CREATED         SIZE
spingwun/docker-github-actions-runner         latest                     a8ed893ffe96   16 hours ago    1.83GB
$ act --pull=false -P ubuntu-latest=spingwun/docker-github-actions-runner -P self-hosted=spingwun/docker-github-actions-runner
WARN  ⚠ You are using Apple M1 chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. ⚠  
[main/checks] 🚀  Start image=spingwun/docker-github-actions-runner
[main/db    ] 🚀  Start image=spingwun/docker-github-actions-runner
[main/build ] 🚀  Start image=spingwun/docker-github-actions-runner
[main/build ]   🐳  docker pull image=spingwun/docker-github-actions-runner platform= username= forcePull=false
[main/db    ]   🐳  docker pull image=spingwun/docker-github-actions-runner platform= username= forcePull=false
[main/checks]   🐳  docker pull image=spingwun/docker-github-actions-runner platform= username= forcePull=false
[main/db    ]   🐳  docker create image=spingwun/docker-github-actions-runner platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[main/db    ]   🐳  docker run image=spingwun/docker-github-actions-runner platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[main/checks]   🐳  docker create image=spingwun/docker-github-actions-runner platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[main/build ]   🐳  docker create image=spingwun/docker-github-actions-runner platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[main/checks]   🐳  docker run image=spingwun/docker-github-actions-runner platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]
[main/build ]   🐳  docker run image=spingwun/docker-github-actions-runner platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[]

You can't really tell that it didn't pull it from the logs but it was instantaneous and I had deleted the Docker image from the hub so it definitely worked :)

Thanks again

thomashutcheson-msm commented 1 year ago

Hey, the flag doesn't work for me if I never uploaded the image to Docker Hub....

Steps to reproduce:

  • Create Docker image locally and give repository name (foobar/docker-github-actions-runner)
  • Run this:
    act --container-architecture linux/arm64/v8
    --pull=false
    -P ubuntu-latest=foobar/docker-github-actions-runner
    -P self-hosted=foobar/docker-github-actions-runner

Returns: Error: Error response from daemon: pull access denied for foobar/docker-github-actions-runner, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

Do I make a mistake with the flags or the feature doesn't exist?

I was getting this error too, then realised I needed to add the tag as well as repository name. my-self-hosted-image:v1 now I can run act -j my_github_workflow -P self-hosted=my-self-hosted-image:v1 --pull=false

dgrebb commented 1 year ago

The only question that wasn't answered here, which ended up being the issue for me:

act --container-architecture linux/amd64 --pull=false -P ubuntu-latest=custom-image-name:latest ...

This will look for that image in the specific architecture.

If your custom image wasn't build with that architecture, act will then attempt to pull an image from the registry, even with the --pull=false flag set.

@dannystaple this issue and your subsequent comment saved me days of banging my head against a wall. Thank you!

@joanrodriguez I take it the line continuation characters are not posted just for aesthetics or that this was all on one line? Can you show the docker image in docker list. It isn't looking for a local arm64 image when you have a x86 image is it?

I needed to docker buildx build --platform linux/amd64 my custom image.

surgiie commented 3 months ago

--pull=false doesnt work with me.

[deployment/Deployment/build-and-deploy]   🐳  docker pull image=self-hosted-workers-prod:latest platform= username= forcePull=false
[deployment/Deployment/build-and-deploy] [DEBUG]   🐳  docker pull self-hosted-workers-prod:latest
[deployment/Deployment/build-and-deploy] [DEBUG] Image exists? false
[deployment/Deployment/build-and-deploy] [DEBUG] pulling image 'docker.io/library/self-hosted-workers-prod:latest' ()
Error: Error response from daemon: pull access denied for self-hosted-workers-prod, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

Im building image with --platform linux/amd64 as suggested above but its still trying to pull.

Im also able to run a container with said image:

docker run -it self-hosted-workers-prod:latest /bin/bash

Feels like my flag is being ignored. Using act version : 0.2.65

Any one have the same issue?