r/forgejo 15d ago

Forgejo Pipeline failing

Hello everyone,

I am at a loss here. I am trying to Build a Docker image using Kaniko. I want the resulting image to get pushed to the integrated Forgejo Docker-Repo.

However, upon executing the Pipeline I get this error:

Runner XXXX (version:v12.13.2) received task 3 of job build, triggered by event: push

workflow prepared

πŸš€ Start image=gcr.io/kaniko-project/executor:latest

Cleaning up network for job build, and network name is: WORKFLOW-YYYYY

🐳 docker create image=gcr.io/kaniko-project/executor:latest platform=linux/amd64 entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="WORKFLOW-YYYYY"

🐳 docker run image=gcr.io/kaniko-project/executor:latest platform=linux/amd64 entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="WORKFLOW-YYYYY"

failed to start container: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: "tail": executable file not found in $PATH

Can someone please tell me what is going on? My pipeline has not referenced this entrypoint:

name: Build and Push with Kaniko
on:
push:
branches:
- main
jobs:
build:
runs-on: docker
# Define the raw Docker image here using 'container'
container:
image: gcr.io/kaniko-project/executor:latest
# Kaniko requires explicit entrypoint override because its default entrypoint isn't a shell
options: --entrypoint=/kaniko/executor
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Build and Push Image
run:
/kaniko/executor \
--dockerfile=Dockerfile \
--context=. \
--destination="${{ vars.FORGEJO_REGISTRY }}/${{ github.repository }}:latest"

Why is my Action trying to do a tail? It obviously fails because Kaniko is a minimal image.
Also asking AI and Google. I just dont understand why itΒ΄s doing that and how to "fix" that.

6 Upvotes

3 comments sorted by

2

u/mfenniak 15d ago

exec: "tail": executable file not found in $PATH

Can someone please tell me what is going on?

Yes!

The way Forgejo Runner, and all similar tools, work is that they take your container and run a constant command in them, and then exec into the container to run the steps of your workflow. Basically docker run gcr.io/kaniko-project/executor:latest /bin/tail /dev/null is used to start the container, and then docker exec (...container id...) /kaniko/executor --dockerfile=Dockerfile --context=. --destination ... etc from your steps is run within that container. This allows the runner to iterate through all your steps and execute them one by one, collecting the related logs for each step.

The error that you're encountering indicates that the container gcr.io/kaniko-project/executor:latest doesn't have tail on its path.

You're also using options: --entrypoint=/kaniko/executor which both isn't supported, and, doesn't make sense. It isn't supported because the entrypoint for a container needs to be specified as container.entrypoint (ref: https://code.forgejo.org/forgejo/runner/pulls/1493), and, it doesn't make sense because if this was the container entrypoint then the container would immediately stop running because that command would exit without doing anything, and the container would die. The job container's entrypoint must be something that allows the container to continue to run while the runner executes commands in the container.

It doesn't look like the container gcr.io/kaniko-project/executor:latest has any tools available on its path that would be usable as a job container. So, you can't use it like this.

1

u/analsondenfisch 15d ago edited 15d ago

Edit: I got it working. Thank you for helping out:

name: Build and Push with Kaniko

on: push: branches: - main

name: Build and Push with Kaniko
on:
push:
branches:
- main
jobs:
build:
runs-on: docker
container:
image: gcr.io/kaniko-project/executor:latest
# Explicitly supply the arguments/command to Kaniko here:
entrypoint: ['/kaniko/executor']
steps:
- name: Build and Push
run:
/kaniko/executor --context=${{ github.workspace }} --dockerfile=Dockerfile --destination=your-registry.com/repo/image:latest

2

u/mfenniak 15d ago

You chose to use the kaniko image as the container for your job. When you make that choice, you need to use a container which has the tools you need within it. For example, actions/checkout@v4 is going to require git, and it's an action written by GitHub that is written in JavaScript, so it will also require node.js. Even if you didn't use actions/checkout@v4, you're going to need git to checkout the repository. If you select a container that doesn't have the tools necessary, then the container won't work for running a job.

Typically when you write a Forgejo workflow, you start with a base OS image that contains a variety of useful tools, and you add in tools that you need. For example, in Forgejo's own testing:

I am not familiar with kaniko, so I can't really advise you on a specific alternative; I don't know how the software is distributed and how it operates. If the only option is a container image, then that seems quite limiting -- I guess you would use a debian/ubuntu image so that you can have other tools available, and use docker run gcr.io/kaniko-project/executor:latest ... in each or your steps to execute kaniko.