ChristopherHX / gitea-actions-runner

MIT License
9 stars 2 forks source link

Request for Docker-in-Docker Support in ChristopherHX/gitea-actions-runner #9

Open vitalyk-ultinarity opened 9 months ago

vitalyk-ultinarity commented 9 months ago

Thank you to @ChristopherHX for providing the ChristopherHX/gitea-actions-runner project, enabling its integration with action/runner.server, which has been immensely beneficial for our project.

While https://gitea.com/gitea/act_runner already implements Docker-in-Docker support, I prefer using action/runner.server. Unfortunately, the current version of ChristopherHX/gitea-actions-runner does not support Docker-in-Docker, preventing deployment on Kubernetes or Docker.

To enable Docker-in-Docker support for ChristopherHX/gitea-actions-runner, it is necessary to package action/runner.server into the container. I would like to inquire whether @ChristopherHX has any plans to add Docker-in-Docker support to the project.

Here is a partial docker-compose configuration that illustrates our usage of your runner:

...
gitea:
  image: gitea/gitea
  ...

runner:
  image: christopherhx/gitea-actions-runner
  restart: always
  depends_on:
    - gitea
  volumes:
    - ./data/act_runner:/data
    - /var/run/docker.sock:/var/run/docker.sock
  environment:
    - GITEA_INSTANCE_URL=<instance url>
    - GITEA_RUNNER_REGISTRATION_TOKEN=<registration token>
    # Additional parameters needed for Docker-in-Docker support
...
ChristopherHX commented 9 months ago

I didn't had any requirements to create such an image yet and this little side project don't have much users.

This would certainly be a good improvement.

To configure dind it is required to enable the the following actions/runner extension https://github.com/actions/runner-container-hooks.

Without actions/runner-container-hooks, will actions/runner refuse to allow the docker intergration to start containers if the runner is already inside a container.

A good starting point would probably be https://github.com/actions/runner/blob/main/images/Dockerfile

If you add the docker runner container tools to the /runner/index.js path of the container you should be able to allow dind

ENV ACTIONS_RUNNER_CONTAINER_HOOKS=/runner/index.js
ENV ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER=1

Warning I'm only using actions/runner in dind not gitea-actions-runner, so some bits are missing this exe must be added to the actions/runner container.

docker-compose.yml
version: "3"

networks:
  runner:
    external: false
volumes:
  runner:
    driver: local
  runner-externals:
    driver: local
  docker-certs:
    driver: local
services:
  runner:
    build: .
    container_name: runner
    environment:
      - DOCKER_TLS_CERTDIR=/certs
      - DOCKER_CERT_PATH=/certs/client
      - DOCKER_TLS_VERIFY=1
      - DOCKER_HOST=tcp://docker:2376
    restart: always
    networks:
      - runner
    volumes:
      - runner:/runner/_work
      - runner-externals:/__e
      - docker-certs:/certs
    depends_on:
      - docker
  docker:
    image: docker:dind-rootless
    restart: always
    privileged: true
    environment:
      - DOCKER_TLS_CERTDIR=/certs
    networks:
      - runner
    volumes:
      - runner:/runner/_work
      - runner-externals:/runner/externals
      - docker-certs:/certs
      - ./var-lib-docker:/var/lib/docker

You have to copy the /runner/externals into the runner-externals volume for this to work.

In this example is dind it's own container.

oilrich25 commented 8 months ago

After my testing, I found that the following is the most convenient solution for the Github Actions self-hosted runner running in a container. It is feasible after testing.

https://github.com/myoung34/docker-github-actions-runner

You can refer to the logs from my build:

# Dockerfile.container_hooks

FROM myoung34/github-runner:2.304.0

ARG RUNNER_CONTAINER_HOOKS_VERSION=0.3.2

ARG RUNNER_DIR=/actions-runner
RUN cd "${RUNNER_DIR}" \
  && curl -fLo runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-docker-${RUNNER_CONTAINER_HOOKS_VERSION}.zip \
  && unzip ./runner-container-hooks.zip -d ./runner-container-hooks-docker \
  && rm -f runner-container-hooks.zip
ENV ACTIONS_RUNNER_CONTAINER_HOOKS="${RUNNER_DIR}/runner-container-hooks-docker/index.js"
# docker-compose.yaml 
version: '2.3'
services:
  worker:
    # image: ghcr.io/myoung34/docker-github-actions-runner:2.304.0
    # runner-container-hooksを仕込むためにDockerfileを指定する
    build:
      context: .
      dockerfile: Dockerfile.container_hooks
    environment:
      REPO_URL: https://github.com/oilrich25/docker-github-action-demo
      RUNNER_NAME: 'my-runner'
      ACCESS_TOKEN: 'xxxxxxxxxxxxxxxxxx'
      RUNNER_WORKDIR: /tmp/runner/work
      RUNNER_SCOPE: 'repo'
      LABELS: 'my-runner'
    security_opt:
      # needed on SELinux systems to allow docker container to manage other docker containers
      - label:disable
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock'
      - '/tmp/runner:/tmp/runner'
      # note: a quirk of docker-in-docker is that this path
      # needs to be the same path on host and inside the container,
      # docker mgmt cmds run outside of docker but expect the paths from within

Execute the following command:

docker-compose build
docker-compose up -d

Next add a CI in Github action for testing:

name: CD

on:
   push:

jobs:
   run_container:
     strategy:
       fail-fast: false
       matrix:
         docker: [my-runner]
     runs-on:
       -self-hosted
       - ${{ matrix.docker }}
     container:
       image: node:16-buster-slim
       options: --cpus 1
     timeout-minutes: 10
     steps:
       - run: env
       - run: ls
       - run: pwd

Eventually you will get a report similar to: https://github.com/oilrich25/docker-github-action-demo/actions/runs/7178788173/job/19547654661

Run '/actions-runner/runner-container-hooks-docker/index.js'
/usr/bin/docker ps --all --quiet --no-trunc --filter label=6d792d72756e6e6572
/usr/bin/docker network prune --force --filter label=6d792d72756e6e6572
/usr/bin/docker network create --label 6d792d72756e6e6572 github_network_89eec40d-35cb-4fd0-bab3-08db62be1761
e587d757ca33774a057430df57ca096c3af8d0006b8cf996e2059fd221a20a0b
/usr/bin/docker pull node:16-buster-slim
16-buster-slim: Pulling from library/node
91f01557fe0d: Pulling fs layer
ecdd21ad91a4: Pulling fs layer
72f5a0bbd6d5: Pulling fs layer
vitalyk-ultinarity commented 8 months ago

Thanks to @ChristopherHX and @oilrich25 for their help. I'm currently testing the configuration provided by @oilrich25 and found it to be feasible and pretty awesome. However, I want to use ChristopherHX/gitea-actions-runner to work with ChristopherHX/runner.server. @ChristopherHX Can you support me? ChristopherHX/gitea-actions-runner This project is the best project I have encountered.

oilrich25 commented 8 months ago

I think you can refer to https://github.com/myoung34/docker-github-actions-runner for inspiration.

oilrich25 commented 8 months ago

@vitalyk-ultinarity You mean that currently you need to use ChristopherHX/gitea-actions-runner and currently use it with Gitea, right? However, currently you don’t want to start ./gitea-actions-runner through the command line?

In fact, @ChristopherHX has implemented a svc service, which is very convenient to install, start, and uninstall through the svc service. what do you think @vitalyk-ultinarity

vitalyk-ultinarity commented 8 months ago

Thank you very much @oilrich25 for your answer, but my current infrastructure is not conducive to installing services directly on the host, I need to manage it via containerization.

ChristopherHX commented 8 months ago

I'm not shure what your goal is.

However, I want to use ChristopherHX/gitea-actions-runner to work with ChristopherHX/runner.server. @ChristopherHX Can you support me?

I recommend to use https://github.com/actions/runner for dind on linux instead of ChristopherHX/runner.server as Worker Backend, the latter is an patched variant of an pretty old actions/runner version.

I think Windows container dind is blocked in https://github.com/ChristopherHX/runner.server without beeing able to disable the check (patch required for this to work)

You probably can add gitea-actions-runner to the DockeFile of https://github.com/ChristopherHX/gitea-actions-runner/issues/9#issuecomment-1851550986 add https://gitea.com/gitea/act_runner/src/branch/main/scripts/run.sh

as an entrypoint and add worker-args to the register command. The registation dir needs to be a docker volume otherwise a single use gitea runner register token will throw on second start of the container

vitalyk-ultinarity commented 8 months ago

I'm trying to do it as follows:

docker run -it -v /var/run/docker.sock:/var/run/docker.sock myoung34/github-runner-base:latest

wget -c https://dl.google.com/go/go1.20.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
export PATH=$PATH:/usr/local/go/bin

git clone https://github.com/ChristopherHX/gitea-actions-runner.git
cd gitea-actions-runner
go build

curl -fLo runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v0.3.2/actions-runner-hooks-docker-0.3.2.zip
unzip ./runner-container-hooks.zip -d ./runner-container-hooks-docker
export ACTIONS_RUNNER_CONTAINER_HOOKS=/root/gitea-actions-runner/runner-container-hooks-docker/index.js 
export ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER=1

mkdir actions-runner && cd actions-runner
curl -O -L https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-linux-x64-2.311.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.311.0.tar.gz
echo '{"workFolder": "_work"} '> .runner

source /etc/os-release
wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y powershell

root@e6612052d0f7:~/gitea-actions-runner# ./act_runner register
INFO Registering runner, arch=amd64, os=linux, version=0.1.5. 
INFO Enter the worker args for example pwsh,actions-runner-worker.ps1,actions-runner/bin/Runner.Worker: 
pwsh,actions-runner-worker.ps1,actions-runner/bin/Runner.Worker
INFO Enter the Gitea instance URL (for example, https://gitea.com/): 
http://192.168.31.28:3000
INFO Enter the runner token:                      
0gwld2fewIXH84fteIYzPG4z9zbzl77ROFpvhAek
INFO Enter the runner name (if set empty, use hostname:e6612052d0f7 ): 

INFO Enter the runner labels, leave blank to use the default labels (comma-separated, for example, self-hosted,ubuntu-latest): 
my-runner
INFO Registering runner, name=e6612052d0f7, instance=http://192.168.31.28:3000, labels=[my-runner]. 
DEBU Successfully pinged the Gitea instance server 
INFO Runner registered successfully.

root@e6612052d0f7:~/gitea-actions-runner# ./act_runner daemon

But an Error: 'RUNNER_NAME' env is required appeared

Current runner version: '2.311.0'
Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v2' (SHA:N/A)
Complete job name: ubuntu
##[group]Run '/root/gitea-actions-runner/runner-container-hooks-docker/index.js'
shell: /root/gitea-actions-runner/actions-runner/externals/node16/bin/node {0}
##[endgroup]
##[error]Error: 'RUNNER_NAME' env is required, please contact your self hosted runner administrator
##[error]Process completed with exit code 1.
##[error]Executing the custom container implementation failed. Please contact your self hosted runner administrator.
##[group]Run '/root/gitea-actions-runner/runner-container-hooks-docker/index.js'
shell: /root/gitea-actions-runner/actions-runner/externals/node16/bin/node {0}
##[endgroup]
##[error]Error: 'RUNNER_NAME' env is required, please contact your self hosted runner administrator
##[error]Process completed with exit code 1.
##[error]Executing the custom container implementation failed. Please contact your self hosted runner administrator.
Cleaning up orphan processes
Finished

I looked through actions/runner-container-hooks https://github.com/actions/runner-container-hooks/blob/main/packages/docker/src/dockerCommands/constants.ts#L2

Then I tried export RUNNER_NAME=my-runner, but I still got the error Error: 'RUNNER_NAME' env is required

vitalyk-ultinarity commented 8 months ago

I found that with ChristopherHX/gitea-actions-runner and actions/runner, the RUNNER_NAME= field cannot be set and it is empty.

https://docs.github.com/en/actions/learn-github-actions/contexts#runner-context

##[group]Run env
env
shell: sh -e {0}
env:
  CACHE_EPOCH: 1
  CCACHE_MAXFILES: 0
  CCACHE_MAXSIZE: 200M
  SCCACHE_CACHE_SIZE: 200M
##[endgroup]
GITHUB_STATE=/__w/_temp/_runner_file_commands/save_state_7a602da3-3c05-493e-b4ad-7d55cceb5e64
DEPLOYMENT_BASEPATH=/opt/runner
USER=root
CACHE_EPOCH=1
CI=true
LSB_OS_VERSION=2004
HOSTNAME=989c81c3c4af
GITHUB_ENV=/__w/_temp/_runner_file_commands/set_env_7a602da3-3c05-493e-b4ad-7d55cceb5e64
HOME=/github/home
GITHUB_EVENT_PATH=/github/workflow/event.json
RUNNER_TEMP=/__w/_temp
GITHUB_REPOSITORY_OWNER=vitalyk-ultinarity
GITHUB_RETENTION_DAYS=
GITHUB_HEAD_REF=
SCCACHE_CACHE_SIZE=200M
GITHUB_GRAPHQL_URL=
CCACHE_MAXSIZE=200M
GITHUB_API_URL=http://192.168.31.28:3000/api/v1
RUNNER_OS=Linux
RUNNER_USER=root
GITHUB_WORKFLOW=build.yml
GITHUB_RUN_ID=1217
ImageOS=ubuntu20
GITHUB_REF_TYPE=branch
GITHUB_BASE_REF=
GITHUB_ACTION_REPOSITORY=
PATH=/opt/hostedtoolcache/node/18.19.0/x64/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
LSB_RELEASE=20.04
RUNNER_TOOL_CACHE=/__w/_tool/linux
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
GITHUB_ACTION=
GITHUB_RUN_NUMBER=147
GITHUB_TRIGGERING_ACTOR=
RUNNER_ARCH=X64
IMAGE_OS=ubuntu20
GITHUB_REF_NAME=main
GITHUB_REPOSITORY=vitalyk-ultinarity/gitea-action-demo
RUNNER_NAME=
DEBIAN_FRONTEND=noninteractive
RUN_TOOL_CACHE=/opt/hostedtoolcache
GITHUB_ACTION_REF=
GITHUB_ACTIONS=true
GITHUB_REF_PROTECTED=false
GITHUB_ACTION_PATH=
GITHUB_JOB=ubuntu
GITHUB_WORKSPACE=/__w/gitea-action-demo/gitea-action-demo
CCACHE_MAXFILES=0
GITHUB_SHA=09517df9b61ee68bbc03edc245338c9ca9c71a40
GITHUB_RUN_ATTEMPT=1
GITHUB_REF=refs/heads/main
GITHUB_ACTOR=vitalyk-ultinarity
GITHUB_PATH=/__w/_temp/_runner_file_commands/add_path_7a602da3-3c05-493e-b4ad-7d55cceb5e64
RUNNER_WORKSPACE=/__w/gitea-action-demo
PWD=/__w/gitea-action-demo/gitea-action-demo
GITHUB_SERVER_URL=http://192.168.31.28:3000
GITHUB_EVENT_NAME=push
GITHUB_OUTPUT=/__w/_temp/_runner_file_commands/set_output_7a602da3-3c05-493e-b4ad-7d55cceb5e64
GITHUB_STEP_SUMMARY=/__w/_temp/_runner_file_commands/step_summary_7a602da3-3c05-493e-b4ad-7d55cceb5e64
ChristopherHX commented 8 months ago

Actually I didn't enable the hooks yet with gitea-actions-runner.

@vitalyk-ultinarity Ah the part to create a .runner file for actions/runner is missing the name property for the hooks

You can add the fields yourself, here is a full .runner file (sample created by registering actions/runner with runner.server)

cat .runner
{
  "isHostedServer": false,
  "agentId": 1,
  "agentName": "ubuntu",
  "poolId": 1,
  "poolName": "Agents",
  "serverUrl": "https://ubuntu.fritz.box:5042/runner/server",
  "gitHubUrl": "https://ubuntu.fritz.box:5042",
  "workFolder": "_work"
}

You have workFolder already set, otherwise nothing would work. You should add agentName to the string of your choice.

ChristopherHX commented 8 months ago

Yeah this line https://github.com/actions/runner/blob/9e3e57ff90c089641a3a5833c2211841da1a37f8/src/Runner.Worker/JobRunner.cs#L166 causes the name to be empty if agentName is not in it's .runner file

vitalyk-ultinarity commented 8 months ago

Yeah this line https://github.com/actions/runner/blob/9e3e57ff90c089641a3a5833c2211841da1a37f8/src/Runner.Worker/JobRunner.cs#L166 causes the name to be empty if agentName is not in it's .runner file

I tried setting agentName but still the output is empty. doesn't work @ChristopherHX ​

root@e6612052d0f7:~/gitea-actions-runner# echo '{"agentName": "my-runner","workFolder": "_work"}' | jq . >actions-runner/.runner 
root@e6612052d0f7:~/gitea-actions-runner# cat actions-runner/.runner 
{
  "agentName": "my-runner",
  "workFolder": "_work"
}

env display

RUNNER_NAME=
DEBIAN_FRONTEND=noninteractive
RUN_TOOL_CACHE=/opt/hostedtoolcache
GITHUB_ACTION_REF=
GITHUB_ACTIONS=true
GITHUB_REF_PROTECTED=false
vitalyk-ultinarity commented 8 months ago
##[group]Run actions/checkout@v2
with:
  repository: vitalyk-ultinarity/gitea-action-demo
  token: ***
  ssh-strict: true
  persist-credentials: true
  clean: true
  fetch-depth: 1
  lfs: false
  submodules: false
  set-safe-directory: true
##[endgroup]
##[group]Run '/root/gitea-actions-runner/runner-container-hooks-docker/index.js'
shell: /root/gitea-actions-runner/actions-runner/externals/node16/bin/node {0}
##[endgroup]
[command]/usr/bin/docker exec -i --workdir=/__w/gitea-action-demo/gitea-action-demo -e CACHE_EPOCH -e CCACHE_MAXFILES -e CCACHE_MAXSIZE -e SCCACHE_CACHE_SIZE -e INPUT_REPOSITORY -e INPUT_REF -e INPUT_TOKEN -e INPUT_SSH-KEY -e INPUT_SSH-KNOWN-HOSTS -e INPUT_SSH-STRICT -e INPUT_PERSIST-CREDENTIALS -e INPUT_PATH -e INPUT_CLEAN -e INPUT_FETCH-DEPTH -e INPUT_LFS -e INPUT_SUBMODULES -e INPUT_SET-SAFE-DIRECTORY -e GITHUB_JOB -e GITHUB_REF_NAME -e GITHUB_RETENTION_DAYS -e GITHUB_ACTION_REF -e GITHUB_REF -e GITHUB_RUN_NUMBER -e GITHUB_ACTION_PATH -e GITHUB_WORKSPACE -e GITHUB_SHA -e GITHUB_ACTION -e GITHUB_REPOSITORY -e GITHUB_BASE_REF -e GITHUB_REF_PROTECTED -e GITHUB_ENV -e GITHUB_RUN_ATTEMPT -e GITHUB_REF_TYPE -e GITHUB_ACTION_REPOSITORY -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKFLOW -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_PATH -e GITHUB_TRIGGERING_ACTOR -e GITHUB_SERVER_URL -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_HEAD_REF -e GITHUB_EVENT_NAME -e GITHUB_STEP_SUMMARY -e GITHUB_STATE -e...
OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd ("/__w/gitea-action-demo/gitea-action-demo") set in config.json failed: no such file or directory: unknown
##[error]Error: The process '/usr/bin/docker' failed with exit code 126
##[error]Process completed with exit code 1.
##[error]Executing the custom container implementation failed. Please contact your self hosted runner administrator.
ChristopherHX commented 8 months ago

Are you shure you don't have more than one runner connected during testing? I mean a runner inside a container still has the old .runner file.

See here RUNNER_NAME is set https://gitea.com/ChristopherHX/actions_runner/actions/runs/83#jobstep-1-67

And C:\Users\Christopher\Documents\actions-runner-win-x64-2.311.0\.runner has content: {"workFolder": "_work", "agentName": "test"}

ChristopherHX commented 8 months ago
[command]/usr/bin/docker exec -i --workdir=/__w/gitea-action-demo/gitea-action-demo -e CACHE_EPOCH -e CCACHE_MAXFILES -e CCACHE_MAXSIZE -e SCCACHE_CACHE_SIZE -e INPUT_REPOSITORY -e INPUT_REF -e INPUT_TOKEN -e INPUT_SSH-KEY -e INPUT_SSH-KNOWN-HOSTS -e INPUT_SSH-STRICT -e INPUT_PERSIST-CREDENTIALS -e INPUT_PATH -e INPUT_CLEAN -e INPUT_FETCH-DEPTH -e INPUT_LFS -e INPUT_SUBMODULES -e INPUT_SET-SAFE-DIRECTORY -e GITHUB_JOB -e GITHUB_REF_NAME -e GITHUB_RETENTION_DAYS -e GITHUB_ACTION_REF -e GITHUB_REF -e GITHUB_RUN_NUMBER -e GITHUB_ACTION_PATH -e GITHUB_WORKSPACE -e GITHUB_SHA -e GITHUB_ACTION -e GITHUB_REPOSITORY -e GITHUB_BASE_REF -e GITHUB_REF_PROTECTED -e GITHUB_ENV -e GITHUB_RUN_ATTEMPT -e GITHUB_REF_TYPE -e GITHUB_ACTION_REPOSITORY -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKFLOW -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_PATH -e GITHUB_TRIGGERING_ACTOR -e GITHUB_SERVER_URL -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_HEAD_REF -e GITHUB_EVENT_NAME -e GITHUB_STEP_SUMMARY -e GITHUB_STATE -e...
OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd ("/__w/gitea-action-demo/gitea-action-demo") set in config.json failed: no such file or directory: unknown
##[error]Error: The process '/usr/bin/docker' failed with exit code 126
##[error]Process completed with exit code 1.
##[error]Executing the custom container implementation failed. Please contact your self hosted runner administrator.

Where is dockerd?

mounting docker.sock into the container of the runner breaks dind and bind mounts won't work. The actions/runner and dockerd needs to be inside the same container for this to work. Otherwise you need to bind mount the exact same absolute path in the runner container as volume to both runner and dockerd at the same PATH

Can you provide the whole dockerfile you have created so far?

vitalyk-ultinarity commented 8 months ago

No, I confirm it is new. And I restarted the gitea-action-runner service. And make sure to add "agentName": "my-runner", to .runner

vitalyk-ultinarity commented 8 months ago
[command]/usr/bin/docker exec -i --workdir=/__w/gitea-action-demo/gitea-action-demo -e CACHE_EPOCH -e CCACHE_MAXFILES -e CCACHE_MAXSIZE -e SCCACHE_CACHE_SIZE -e INPUT_REPOSITORY -e INPUT_REF -e INPUT_TOKEN -e INPUT_SSH-KEY -e INPUT_SSH-KNOWN-HOSTS -e INPUT_SSH-STRICT -e INPUT_PERSIST-CREDENTIALS -e INPUT_PATH -e INPUT_CLEAN -e INPUT_FETCH-DEPTH -e INPUT_LFS -e INPUT_SUBMODULES -e INPUT_SET-SAFE-DIRECTORY -e GITHUB_JOB -e GITHUB_REF_NAME -e GITHUB_RETENTION_DAYS -e GITHUB_ACTION_REF -e GITHUB_REF -e GITHUB_RUN_NUMBER -e GITHUB_ACTION_PATH -e GITHUB_WORKSPACE -e GITHUB_SHA -e GITHUB_ACTION -e GITHUB_REPOSITORY -e GITHUB_BASE_REF -e GITHUB_REF_PROTECTED -e GITHUB_ENV -e GITHUB_RUN_ATTEMPT -e GITHUB_REF_TYPE -e GITHUB_ACTION_REPOSITORY -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKFLOW -e GITHUB_EVENT_PATH -e GITHUB_ACTOR -e GITHUB_PATH -e GITHUB_TRIGGERING_ACTOR -e GITHUB_SERVER_URL -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_HEAD_REF -e GITHUB_EVENT_NAME -e GITHUB_STEP_SUMMARY -e GITHUB_STATE -e...
OCI runtime exec failed: exec failed: unable to start container process: chdir to cwd ("/__w/gitea-action-demo/gitea-action-demo") set in config.json failed: no such file or directory: unknown
##[error]Error: The process '/usr/bin/docker' failed with exit code 126
##[error]Process completed with exit code 1.
##[error]Executing the custom container implementation failed. Please contact your self hosted runner administrator.

Where is dockerd?

mounting docker.sock into the container of the runner breaks dind and bind mounts won't work. The actions/runner and dockerd needs to be inside the same container for this to work. Otherwise you need to bind mount the exact same absolute path in the runner container as volume to both runner and dockerd at the same PATH

Can you provide the whole dockerfile you have created so far?

So far I haven't written a dockerfile. I just ran the container. https://github.com/ChristopherHX/gitea-actions-runner/issues/9#issuecomment-1852922821

vitalyk-ultinarity commented 8 months ago
Current runner version: '2.311.0'
Secret source: Actions
Prepare workflow directory
Prepare all required actions
Complete job name: android
##[group]Run '/root/gitea-actions-runner/runner-container-hooks-docker/index.js'
shell: /root/gitea-actions-runner/actions-runner/externals/node16/bin/node {0}
##[endgroup]
[command]/usr/bin/docker ps --all --quiet --no-trunc --filter label=6d792d72756e6e6572
[command]/usr/bin/docker network prune --force --filter label=6d792d72756e6e6572
[command]/usr/bin/docker network create --label 6d792d72756e6e6572 github_network_c4f17447-ce41-4e35-bcc0-6901b1c60e00
1bae77610d03dc761dc3abf444d9ad1d10b41db2742e4a9266fffaed2ec92c34
[command]/usr/bin/docker pull catthehacker/ubuntu:act-20.04
act-20.04: Pulling from catthehacker/ubuntu
Digest: sha256:bfa792bf5601099c7102bc51133793465e26bd03c9f42d3e8744a41639aff55e
Status: Image is up to date for catthehacker/ubuntu:act-20.04
docker.io/catthehacker/ubuntu:act-20.04
[command]/usr/bin/docker create --label=6d792d72756e6e6572 --network=github_network_c4f17447-ce41-4e35-bcc0-6901b1c60e00 --name 36476e7fa89a4a17a713088d395399ba__d4331e --privileged -e HOME -v=/var/run/docker.sock:/var/run/docker.sock -v=/root/gitea-actions-runner/actions-runner/_work:/__w -v=/root/gitea-actions-runner/actions-runner/externals:/__e -v=/root/gitea-actions-runner/actions-runner/_work/_temp:/__w/_temp -v=/root/gitea-actions-runner/actions-runner/_work/_actions:/__w/_actions -v=/root/gitea-actions-runner/actions-runner/_work/_tool:/__w/_tool -v=/root/gitea-actions-runner/actions-runner/_work/_temp/_github_home:/github/home -v=/root/gitea-actions-runner/actions-runner/_work/_temp/_github_workflow:/github/workflow --entrypoint tail catthehacker/ubuntu:act-20.04 -f /dev/null
40133829bb0260681ef91f483fe431f8d65a08e30bd64251f8dd3599e06b0fd6
[command]/usr/bin/docker start 40133829bb0260681ef91f483fe431f8d65a08e30bd64251f8dd3599e06b0fd6
40133829bb0260681ef91f483fe431f8d65a08e30bd64251f8dd3599e06b0fd6
No service containers provided, skipping
[command]/usr/bin/docker exec 40133829bb0260681ef91f483fe431f8d65a08e30bd64251f8dd3599e06b0fd6 sh -c [ $(cat /etc/*release* | grep -i -e '^ID=*alpine*' -c) != 0 ] || exit 1
[command]/usr/bin/docker port 40133829bb0260681ef91f483fe431f8d65a08e30bd64251f8dd3599e06b0fd6
[command]/usr/bin/docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" 40133829bb0260681ef91f483fe431f8d65a08e30bd64251f8dd3599e06b0fd6
""
Healthcheck is not set for container catthehacker/ubuntu:act-20.04, considered as healthy
All services are healthy
ChristopherHX commented 8 months ago

Ok yeah docker run -it -v /var/run/docker.sock:/var/run/docker.sock myoung34/github-runner-base:latest is a problem

docker run -it myoung34/github-runner-base:latest

That must be removed -v /var/run/docker.sock:/var/run/docker.sock

I would try the following later

docker run -it myoung34/github-runner-base:latest

wget -c https://dl.google.com/go/go1.20.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
export PATH=$PATH:/usr/local/go/bin

git clone https://github.com/ChristopherHX/gitea-actions-runner.git
cd gitea-actions-runner
go build

curl -fLo runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v0.3.2/actions-runner-hooks-docker-0.3.2.zip
unzip ./runner-container-hooks.zip -d ./runner-container-hooks-docker
export ACTIONS_RUNNER_CONTAINER_HOOKS=/root/gitea-actions-runner/runner-container-hooks-docker/index.js 
export ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER=1

mkdir actions-runner && cd actions-runner
curl -O -L https://github.com/actions/runner/releases/download/v2.311.0/actions-runner-linux-x64-2.311.0.tar.gz
tar xzf ./actions-runner-linux-x64-2.311.0.tar.gz
echo '{"workFolder": "_work", "agentName": "container"} '> .runner

source /etc/os-release
wget -q https://packages.microsoft.com/config/ubuntu/$VERSION_ID/packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y powershell

root@e6612052d0f7:~/gitea-actions-runner# ./act_runner register
INFO Registering runner, arch=amd64, os=linux, version=0.1.5. 
INFO Enter the worker args for example pwsh,actions-runner-worker.ps1,actions-runner/bin/Runner.Worker: 
pwsh,actions-runner-worker.ps1,actions-runner/bin/Runner.Worker
INFO Enter the Gitea instance URL (for example, https://gitea.com/): 
*************************************
INFO Enter the runner token:                      
*************************************
INFO Enter the runner name (if set empty, use hostname:e6612052d0f7 ): 

INFO Enter the runner labels, leave blank to use the default labels (comma-separated, for example, self-hosted,ubuntu-latest): 
my-runner
INFO Registering runner, name=e6612052d0f7, instance=http://192.168.31.28:3000, labels=[my-runner]. 
DEBU Successfully pinged the Gitea instance server 
INFO Runner registered successfully.

root@e6612052d0f7:~/gitea-actions-runner# ./act_runner daemon
ChristopherHX commented 8 months ago

I think myoung34/github-runner-base:latest doesn't provide dind, so a docker-compose or it's kubernetes equivalient is required like in https://github.com/ChristopherHX/gitea-actions-runner/issues/9#issuecomment-1850830866.

Alternatively dockerd must be started as a second process in the container.

vitalyk-ultinarity commented 8 months ago

I think myoung34/github-runner-base:latest doesn't provide dind, so a docker-compose or it's kubernetes equivalient is required like in #9 (comment).

Alternatively dockerd must be started as a second process in the container.

Can you test @ChristopherHX? I really can't do it anymore.

Based on https://github.com/actions/runner/blob/main/images/Dockerfile

# Dockerfile
# Source: https://github.com/dotnet/dotnet-docker
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy as build

ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG RUNNER_VERSION=2.311.0
ARG RUNNER_CONTAINER_HOOKS_VERSION=0.3.2
ARG DOCKER_VERSION=24.0.6
ARG BUILDX_VERSION=0.11.2

RUN apt update -y && apt install curl unzip -y

WORKDIR /actions-runner
RUN export RUNNER_ARCH=${TARGETARCH} \
    && if [ "$RUNNER_ARCH" = "amd64" ]; then export RUNNER_ARCH=x64 ; fi \
    && curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-${TARGETOS}-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \
    && tar xzf ./runner.tar.gz \
    && rm runner.tar.gz

RUN curl -f -L -o runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-docker-${RUNNER_CONTAINER_HOOKS_VERSION}.zip \
    && unzip ./runner-container-hooks.zip -d ./hooks \
    && rm runner-container-hooks.zip

RUN export RUNNER_ARCH=${TARGETARCH} \
    && if [ "$RUNNER_ARCH" = "amd64" ]; then export DOCKER_ARCH=x86_64 ; fi \
    && if [ "$RUNNER_ARCH" = "arm64" ]; then export DOCKER_ARCH=aarch64 ; fi \
    && curl -fLo docker.tgz https://download.docker.com/${TARGETOS}/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz \
    && tar zxvf docker.tgz \
    && rm -rf docker.tgz \
    && mkdir -p /usr/local/lib/docker/cli-plugins \
    && curl -fLo /usr/local/lib/docker/cli-plugins/docker-buildx \
        "https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-${TARGETARCH}" \
    && chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx

FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy

ENV DEBIAN_FRONTEND=noninteractive
ENV RUNNER_MANUALLY_TRAP_SIG=1
ENV ACTIONS_RUNNER_PRINT_LOG_TO_STDOUT=1
ENV ImageOS=ubuntu22
ENV ACTIONS_RUNNER_CONTAINER_HOOKS=/home/runner/hooks/index.js

RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
    sudo \
    jq \
    curl \
    lsb-release \
    && rm -rf /var/lib/apt/lists/*

RUN adduser --disabled-password --gecos "" --uid 1001 runner \
    && groupadd docker --gid 123 \
    && usermod -aG sudo runner \
    && usermod -aG docker runner \
    && echo "%sudo   ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \
    && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers

WORKDIR /home/runner

COPY --from=build /actions-runner .
COPY --from=build /usr/local/lib/docker/cli-plugins/docker-buildx /usr/local/lib/docker/cli-plugins/docker-buildx

RUN install -o root -g root -m 755 docker/* /usr/bin/ && rm -rf docker

RUN echo '{"agentName": "my-runner","workFolder": "/home/runner/_work"}' > .runner

WORKDIR /runner

COPY .runner /runner
COPY actions-runner-worker.py /runner

# RUN sudo chown -R runner:docker /runner

RUN curl -LJO https://github.com/ChristopherHX/gitea-actions-runner/releases/download/v0.0.6/gitea-actions-runner-0.0.6-linux-amd64 && mv gitea-actions-runner-0.0.6-linux-amd64 gitea-actions-runner
RUN chmod +x gitea-actions-runner

CMD ["./gitea-actions-runner", "daemon"]
# docker-compose.yml 
networks:
  runner:
    external: false
volumes:
  runner:
    driver: local
  runner-externals:
    driver: local
  docker-certs:
    driver: local
services:
  runner:
    build: .
    container_name: runner
    environment:
      - DOCKER_TLS_CERTDIR=/certs
      - DOCKER_CERT_PATH=/certs/client
      - DOCKER_TLS_VERIFY=1
      - DOCKER_HOST=tcp://docker:2376
    restart: always
    networks:
      - runner
    volumes:
      - runner:/home/runner/_work
      - runner-externals:/__e
      - docker-certs:/certs
    depends_on:
      - docker
  docker:
    image: docker:dind-rootless
    restart: always
    privileged: true
    environment:
      - DOCKER_TLS_CERTDIR=/certs
    networks:
      - runner
    volumes:
      - runner:/home/runner/_work
      - runner-externals:/home/runner/externals
      - docker-certs:/certs
      - ./var-lib-docker:/var/lib/docker
[command]/usr/bin/docker exec -i --workdir=/__w/gitea-action-demo/gitea-action-demo -e CACHE_EPOCH -e CCACHE_MAXFILES -e CCACHE_MAXSIZE -e SCCACHE_CACHE_SIZE -e INPUT_REPOSITORY -e INPUT_REF -e INPUT_TOKEN -e INPUT_SSH-KEY -e INPUT_SSH-KNOWN-HOSTS -e INPUT_SSH-STRICT -e INPUT_PERSIST-CREDENTIALS -e INPUT_PATH -e INPUT_CLEAN -e INPUT_FETCH-DEPTH -e INPUT_LFS -e INPUT_SUBMODULES -e INPUT_SET-SAFE-DIRECTORY -e GITHUB_JOB -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_SHA -e GITHUB_ACTOR -e GITHUB_REF_TYPE -e GITHUB_ACTION -e GITHUB_ENV -e GITHUB_ACTION_REF -e GITHUB_REF_NAME -e GITHUB_WORKSPACE -e GITHUB_GRAPHQL_URL -e GITHUB_TRIGGERING_ACTOR -e GITHUB_RUN_ATTEMPT -e GITHUB_RUN_NUMBER -e GITHUB_SERVER_URL -e GITHUB_RUN_ID -e GITHUB_REPOSITORY -e GITHUB_REF -e GITHUB_REPOSITORY_OWNER -e GITHUB_PATH -e GITHUB_BASE_REF -e GITHUB_HEAD_REF -e GITHUB_ACTION_PATH -e GITHUB_RETENTION_DAYS -e GITHUB_API_URL -e GITHUB_WORKFLOW -e GITHUB_EVENT_NAME -e GITHUB_REF_PROTECTED -e GITHUB_STEP_SUMMARY -e GITHUB_STATE -e...
OCI runtime exec failed: exec failed: unable to start container process: exec: "/__e/node16/bin/node": stat /__e/node16/bin/node: no such file or directory: unknown
##[error]Error: The process '/usr/bin/docker' failed with exit code 126
##[error]Process completed with exit code 1.
##[error]Executing the custom container implementation failed. Please contact your self hosted runner administrator.
vitalyk-ultinarity commented 8 months ago

Still the same error. Executing the custom container implementation failed. Please contact your self hosted runner administrator.

vitalyk-ultinarity commented 8 months ago
root@4aaf494115ec:/runner# ls /home/runner/externals/
node16  node16_alpine  node20  node20_alpine
root@4aaf494115ec:/runner# 
ChristopherHX commented 8 months ago

I will try to get this running now. We are probably in a different timezones.

You would have to mirror /home/runner/externals/ to /__e inside the runner container for my approuch to work.

runner-externals would be an empty volume before syncing the files

ChristopherHX commented 8 months ago

This works for me:

# Dockerfile
# Source: https://github.com/dotnet/dotnet-docker
FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy as build

ARG TARGETOS=linux
ARG TARGETARCH=amd64
ARG RUNNER_VERSION=2.311.0
ARG RUNNER_CONTAINER_HOOKS_VERSION=0.5.0
ARG DOCKER_VERSION=24.0.6
ARG BUILDX_VERSION=0.11.2

RUN apt update -y && apt install curl unzip -y

WORKDIR /actions-runner
RUN export RUNNER_ARCH=${TARGETARCH} \
    && if [ "$RUNNER_ARCH" = "amd64" ]; then export RUNNER_ARCH=x64 ; fi \
    && curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-${TARGETOS}-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \
    && tar xzf ./runner.tar.gz \
    && rm runner.tar.gz

RUN curl -f -L -o runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-docker-${RUNNER_CONTAINER_HOOKS_VERSION}.zip \
    && unzip ./runner-container-hooks.zip -d ./docker-hooks \
    && rm runner-container-hooks.zip

RUN curl -f -L -o runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-k8s-${RUNNER_CONTAINER_HOOKS_VERSION}.zip \
    && unzip ./runner-container-hooks.zip -d ./k8s \
    && rm runner-container-hooks.zip

RUN export RUNNER_ARCH=${TARGETARCH} \
    && if [ "$RUNNER_ARCH" = "amd64" ]; then export DOCKER_ARCH=x86_64 ; fi \
    && if [ "$RUNNER_ARCH" = "arm64" ]; then export DOCKER_ARCH=aarch64 ; fi \
    && curl -fLo docker.tgz https://download.docker.com/${TARGETOS}/static/stable/${DOCKER_ARCH}/docker-${DOCKER_VERSION}.tgz \
    && tar zxvf docker.tgz \
    && rm -rf docker.tgz \
    && mkdir -p /usr/local/lib/docker/cli-plugins \
    && curl -fLo /usr/local/lib/docker/cli-plugins/docker-buildx \
        "https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-${TARGETARCH}" \
    && chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx

FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy

ENV DEBIAN_FRONTEND=noninteractive
ENV RUNNER_MANUALLY_TRAP_SIG=1
ENV ACTIONS_RUNNER_PRINT_LOG_TO_STDOUT=1
ENV ImageOS=ubuntu22
ENV ACTIONS_RUNNER_CONTAINER_HOOKS=/home/runner/docker-hooks/index.js

RUN apt-get update -y \
    && apt-get install -y --no-install-recommends \
    sudo \
    jq \
    curl \
    lsb-release \
    && rm -rf /var/lib/apt/lists/*

RUN adduser --disabled-password --gecos "" --uid 1000 runner \
    && groupadd docker --gid 123 \
    && usermod -aG sudo runner \
    && usermod -aG docker runner \
    && echo "%sudo   ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \
    && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers

WORKDIR /home/runner

VOLUME /home/runner/externals
VOLUME /home/runner/_work

COPY --chown=runner:docker --from=build /actions-runner .
COPY --from=build /usr/local/lib/docker/cli-plugins/docker-buildx /usr/local/lib/docker/cli-plugins/docker-buildx

RUN install -o root -g root -m 755 docker/* /usr/bin/ && rm -rf docker

RUN mkdir /gitea-runner && chown runner:docker -R /gitea-runner

USER runner

RUN echo '{"agentName": "my-runner","workFolder": "/home/runner/_work"}' > .runner

WORKDIR /runner
RUN chown runner:docker /runner && mkdir -p /home/runner/_work && chown -R runner:docker /home/runner/_work

COPY .runner /gitea-runner

WORKDIR /gitea-runner
COPY actions-runner-worker.py /gitea-runner
COPY start.sh /gitea-runner

RUN curl -LJO https://github.com/ChristopherHX/gitea-actions-runner/releases/download/v0.0.6/gitea-actions-runner-0.0.6-linux-amd64 && mv gitea-actions-runner-0.0.6-linux-amd64 gitea-actions-runner
RUN chmod +x gitea-actions-runner

CMD ["bash", "start.sh"]

start.sh

sudo chown -R ubuntu:docker /home/runner/_work
./gitea-actions-runner daemon

docker-compose.yml

# docker-compose.yml 
networks:
  runner:
    external: false
volumes:
  runner:
    driver: local
  runner-externals:
    driver: local
  docker-certs:
    driver: local
services:
  runner:
    build: .
    container_name: runner
    environment:
      - DOCKER_TLS_CERTDIR=/certs
      - DOCKER_CERT_PATH=/certs/client
      - DOCKER_TLS_VERIFY=1
      - DOCKER_HOST=tcp://docker:2376
    restart: always
    networks:
      - runner
    volumes:
      - runner:/home/runner/_work
      - runner-externals:/home/runner/externals
      - docker-certs:/certs
    depends_on:
      - docker
  docker:
    image: docker:dind-rootless
    restart: always
    privileged: true
    environment:
      - DOCKER_TLS_CERTDIR=/certs
    networks:
      - runner
    volumes:
      - runner:/home/runner/_work
      - runner-externals:/home/runner/externals
      - docker-certs:/certs
      - ./var-lib-docker:/var/lib/docker

Please cleanup your named docker runner and runner-externals volumes, otherwise runner-externals won't be filled by docker.

Next steps are

ChristopherHX commented 8 months ago

Link to a ci run on gitea.com https://gitea.com/ChristopherHX/actions_runner/actions/runs/86.

https://gitea.com/ChristopherHX/actions_runner is the same repository, but hosted by Gitea.

ChristopherHX commented 8 months ago

The .runner file of register should have the worker defined as

{
  "id": 575,
  "uuid": "169f0627-b763-4005-8e87-5388e5d9c904",
  "name": "codespaces-388837",
  "token": "****************************",
  "address": "https://gitea.com/",
  "labels": [
    "test-runner"
  ],
  "runner_worker": [
    "python3",
    "actions-runner-worker.py",
    "/home/runner/bin/Runner.Worker"
  ]
}

runner_worker would be set by the configure script, once it's added.

vitalyk-ultinarity commented 8 months ago

OK, I'll test it right away

vitalyk-ultinarity commented 8 months ago

After testing the configuration provided by @ChristopherHX, it worked successfully.

vitalyk-ultinarity commented 8 months ago

So far the testing is going well. @ChristopherHX Are you interested in packaging https://github.com/ChristopherHX/gitea-actions-runner/issues/9#issuecomment-1854076822 into a ghcr.io docker image?

Something like this: https://github.com/actions/runner/blob/main/.github/workflows/publish-image.yml#L55-L58

# docker-compose.yml 
networks:
  runner:
    external: false
volumes:
  runner:
    driver: local
  runner-externals:
    driver: local
  docker-certs:
    driver: local
services:
  runner:
    image: ghrc.io/christopherhx/gitea-actions-runner
    container_name: runner
    environment:
      - RUNNER_NAME: example-name
      - LABELS: linux,x64,gpu
      - GITEA_INSTANCE_URL=<instance url>
      - GITEA_RUNNER_REGISTRATION_TOKEN=<registration token>
      - DOCKER_TLS_CERTDIR=/certs
      - DOCKER_CERT_PATH=/certs/client
      - DOCKER_TLS_VERIFY=1
      - DOCKER_HOST=tcp://docker:2376
    restart: always
    networks:
      - runner
    volumes:
      - runner:/home/runner/_work
      - runner-externals:/home/runner/externals
      - docker-certs:/certs
    depends_on:
      - docker
  docker:
    image: docker:dind-rootless
    restart: always
    privileged: true
    environment:
      - DOCKER_TLS_CERTDIR=/certs
    networks:
      - runner
    volumes:
      - runner:/home/runner/_work
      - runner-externals:/home/runner/externals
      - docker-certs:/certs
      - ./var-lib-docker:/var/lib/docker
ChristopherHX commented 8 months ago

So far the testing is going well. @ChristopherHX Are you interested in packaging #9 (comment) into a ghcr.io docker image?

Yes, after finalizing it.

I'm already uploading images to ghcr here https://github.com/ChristopherHX/runner.server/blob/main/.github/workflows/container.yml using a Dockerfile

vitalyk-ultinarity commented 8 months ago

So far the testing is going well. @ChristopherHX Are you interested in packaging #9 (comment) into a ghcr.io docker image?

Yes, after finalizing it.

I'm already uploading images to ghcr here https://github.com/ChristopherHX/runner.server/blob/main/.github/workflows/container.yml using a Dockerfile

great

vitalyk-ultinarity commented 8 months ago

Thanks to @ChristopherHX for adding docker support for ChristopherHX/gitea-actions-runner/gitea-actions-runner. Just pulled ghcr.io/christopherhx/gitea-actions-runner:v0.0.8 and the test was successful.

vitalyk-ultinarity commented 8 months ago

https://github.com/ChristopherHX/gitea-actions-runner/blob/main/examples/docker-compose-dind/docker-compose.yml#L1-L47 But when I tried it on podman, it didn't seem to work. How to configure it on podman?

ChristopherHX commented 8 months ago

But when I tried it on podman, it didn't seem to work. How to configure it on podman?

I read that a dind image doesn't work with podman, but I have zero knowledge about podman.

The actions runner hooks also have a k8s mode, so that it starts k8s containers instead of using dind, pind or pinp (d = docker, p = podman)

oilrich25 commented 8 months ago

https://github.com/ChristopherHX/gitea-actions-runner/blob/main/examples/docker-compose-dind/docker-compose.yml#L1-L47 But when I tried it on podman, it didn't seem to work. How to configure it on podman?

Please go to https://github.com/ChristopherHX/gitea-actions-runner/issues/12 to discuss.

vitalyk-ultinarity commented 8 months ago

https://github.com/ChristopherHX/gitea-actions-runner/blob/main/examples/docker-compose-dind/docker-compose.yml#L1-L47 But when I tried it on podman, it didn't seem to work. How to configure it on podman?

Please go to #12 to discuss.

Thanks, I saw it. I'll test it later.