vegardit / docker-gitea-act-runner

Docker image based on debian:stable-slim to run Gitea's act_runner as a Docker container
https://buymeacoffee.com/vegardit
Apache License 2.0
147 stars 14 forks source link

dind-rootless-latest need git as dependency #57

Open imlonghao opened 1 month ago

imlonghao commented 1 month ago

Hello,

I'm using vegardit/gitea-act-runner:dind-rootless-latest and trying to build a docker image.

Runner config

version: "3.8"
services:
  runner:
    image: vegardit/gitea-act-runner:dind-rootless-latest
    privileged: true
    environment:
      GITEA_INSTANCE_URL: https://git.**REDACTED**
      GITEA_RUNNER_REGISTRATION_TOKEN: **REDACTED**
      GITEA_RUNNER_NAME: **REDACTED**
      GITEA_RUNNER_MAX_PARALLEL_JOBS: 2
      ACT_CACHE_SERVER_HOST: **REDACTED**
      ACT_CACHE_SERVER_PORT: 22380
    ports:
      - 22380:22380
    volumes:
      - ./data:/data

Gitea action config

name: Build Server

on:
  push:
    branches:
      - main

jobs:
  docker:
    runs-on: ubuntu-latest
    container:
      image: catthehacker/ubuntu:act-22.04
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Fix Docker Permission
        uses: https://github.com/imlonghao/gitea-runner-docker-permission-fix@main
      - name: Login to Docker Hub
        uses: docker/login-action@v3
        with:
          registry: git.**REDACTED**
          username: imlonghao
          password: **REDACTED**
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v5
        with:
          images: git.**REDACTED**-server
          tags: |
            type=sha
            type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}            
      - name: Build and push
        uses: docker/build-push-action@v5
        with:
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          file: Dockerfile.server

I got this error on the Build and push phase

[command]/usr/bin/docker buildx version
github.com/docker/buildx 0.12.0-1 542e5d810e4a1a155684f5f3c5bd7e797632a12f
::endgroup::
[command]/usr/bin/docker buildx build --file Dockerfile.server --iidfile /tmp/docker-actions-toolkit-E6zD2Y/iidfile --secret id=GIT_AUTH_TOKEN,src=/tmp/docker-actions-toolkit-E6zD2Y/tmp-149-vIMXPDX5m5Bl --tag git.**REDACTED**-server:latest --tag git.**REDACTED**-server:sha-5c1d154 --metadata-file /tmp/docker-actions-toolkit-E6zD2Y/metadata-file --push https://git.**REDACTED**/imlonghao/**REDACTED**.git#**REDACTED**35d02e1754
#0 building with "default" instance using docker driver
#1 [internal] load git source https://git.**REDACTED**.git#**REDACTED**135d02e1754
#1 ERROR: failed to init repo at /data/.local/share/docker/fuse-overlayfs/5xrld60bvz69ds96yah8z4d6z/diff: exec: "git": executable file not found in $PATH
------
 > [internal] load git source https://git.**REDACTED**.git#**REDACTED**135d02e1754:
------
ERROR: failed to solve: failed to read dockerfile: failed to init repo at /data/.local/share/docker/fuse-overlayfs/5xrld60bvz69ds96yah8z4d6z/diff: exec: "git": executable file not found in $PATH
::error::buildx failed with: ERROR: failed to solve: failed to read dockerfile: failed to init repo at /data/.local/share/docker/fuse-overlayfs/5xrld60bvz69ds96yah8z4d6z/diff: exec: "git": executable file not found in $PATH

Patching the image with this Dockerfile works for me

FROM vegardit/gitea-act-runner:dind-rootless-latest
RUN sudo apt update && sudo apt install -y --no-install-recommends git && sudo rm -rf /var/lib/apt/lists/*

I suggest we can add git to https://github.com/vegardit/docker-gitea-act-runner/blob/55af759535bfb6b05a683816358db58c50da0d99/image/Dockerfile#L64

sebthom commented 1 month ago

Interesting, I don't really understand why this is necessary. To my understanding all commands incl. git should be executed within the catthehacker/ubuntu:act-22.04 container and not on the host.

imlonghao commented 1 month ago

Yeah, it's a little weird behavior. I have another action worker running in vegardit/gitea-act-runner:latest image, which works fine without the git installed. So I sometimes just keep restarting the action job until it got assign to this runner.