[Solved] Gitea Actions run a job from a custom image

Hello,

I’m new to Gitea Actions and I’m looking for documentation and/or help about how to run a job from a custom Docker image. I’m using Gitea with a docker-compose install.

I created Docker image of my Python app like so

Dockerfile

FROM python:3.11-buster

RUN pip install poetry

COPY pyproject.toml .
COPY tests/ /tests/
COPY python_test_app/ /python_test_app/

RUN poetry install

ENTRYPOINT ["poetry", "run", "python", "python_test_app/__init__.py"]
$ docker build . -t python-test-app

I modified config.yaml for my runner like so

 labels:
    - "ubuntu-latest:docker://gitea/runner-images:ubuntu-latest"
    - "ubuntu-22.04:docker://gitea/runner-images:ubuntu-22.04"
    - "ubuntu-20.04:docker://gitea/runner-images:ubuntu-20.04"
    - "python-test-app:docker://gitea/runner-images:python-test-app"  # what I added

I created a Gitea repository and enable actions and put the following .gitea/workflows/run_custom.yml

on:
  push:
    branches:
    - 'main'
jobs:
  test:
    runs-on: python-test-app
    steps:
      - run: echo "hello"

When I’m pushing to this repository I was expecting image be pulled (in fact this image ever exists on host) and poetry run python python_test_app/__init__.py be executed.

Unfortunately that’s not the case. I get

Act-Runner(version:v0.2.9) received task 60 of job 63, be triggered by event: push
workflow prepared
evaluating expression 'success()'
expression 'success()' evaluated to 'true'
🚀  Start image=gitea/runner-images:python-test-app
  🐳  docker pull image=gitea/runner-images:python-test-app platform= username= forcePull=true
  🐳  docker pull gitea/runner-images:python-test-app
pulling image 'docker.io/gitea/runner-images:python-test-app' ()
Error response from daemon: manifest for gitea/runner-images:python-test-app not found: manifest unknown: manifest unknown

So image is not pulled (even if this image is available on the host).

I think I did a mistake with

- "python-test-app:docker://gitea/runner-images:python-test-app"

but couldn’t see how to fix it.

For example I wonder if I should publish this image on a private registry to be used by Gitea Actions or if Gitea act-runner can find image simply on the host.

I looked at Using Docker images from private repository to run actions in and What's the idiomatic way of using gitea-hosted container images in Actions jobs? - #2 by abackstrom but it didn’t helped me much (probably because I still have to learn more about Gitea and Gitea Actions)

Some help will be very nice!

I was looking to do this today. This is how I figured out how to do it.

I’m using the built-in docker container registry in gitea to host my docker images I’m building from.

The image needs a version of nodejs for act runner to use. I need to build for ubuntu-20.04, so I had to install a more decent version. here’s my docker file minus some project-specific bits.

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
    apt-get install -y build-essential curl python3 python3-venv python3-pip dpkg-dev \
    ca-certificates git gnupg dirmngr xz-utils libatomic1 \
    ghostscript jq python3 python3-pip python3-venv python3-beaker python3-cairo \
    python3-dateutil python3-fusepy python3-future python3-hl7 python3-humanize \
    python3-itsdangerous python3-ldap python3-lxml \
    python3-openpyxl python3-paramiko python3-pexpect python3-pip \
    python3-psycopg2 python3-redis python3-reportlab python3-requests \
    python3-setuptools python3-simplejson python3-six python3-werkzeug \
    python3-yaml telnet tmux vim wget zip unzip
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
RUN apt-get install -y nodejs
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Then push your image to the gitea registry

  docker build -t ubuntu-PROJECT:20.04 .
  docker tag ubuntu-PROJECT:20.04 gitea.ORGANIZATION.com/ORG/ubuntu-PROJECT:20.04
  docker login gitea.ORGANIZATION.com
  docker push gitea.ORGANIZATION.com/ORG/ubuntu-PROJECT:20.04

Then, where you run act runner you need to run docker login as the user your service uses. This way act runner can pull the image.

Finally put the label in the act_runner configuration file

here’s my set

  labels:
    - "ubuntu-latest:docker://gitea/runner-images:ubuntu-latest"
    - "ubuntu-22.04:docker://gitea/runner-images:ubuntu-22.04"
    - "ubuntu-20.04:docker://gitea/runner-images:ubuntu-20.04"
    - "ubuntu-PROJECT-20.04:docker://gitea.ORGANIZATION.com/ORG/ubuntu-PROJECT:20.04"

You can now use runs-on: ubuntu-PROJECT-20.04 in your workflow file.

1 Like