docker / setup-buildx-action

GitHub Action to set up Docker Buildx
https://github.com/marketplace/actions/docker-setup-buildx
Apache License 2.0
984 stars 156 forks source link

action stopped working on self-hosted runner #377

Closed elyulka closed 1 week ago

elyulka commented 1 week ago

Contributing guidelines

I've found a bug, and:

Description

action worked and suddenly stopped without any change from our side.

Expected behaviour

action runs without error

Actual behaviour

fails with first error "Unable to locate executable file: docker" despite it exists and worked before.

Repository URL

No response

Workflow run URL

No response

YAML workflow

name: Build and publish Docker images

on:
  workflow_dispatch:
  push:
    branches: [development, staging, master]
    paths-ignore:
      - "tests/*"
      - ".gitignore"
      - "docker-compose.*.yml"
      - "docker-compose.yml"
      - "*.md"
      - "docs/*.m*"
      - "dockerfiles/nginx-unit/**"
  pull_request:
    types: [opened, synchronize]
    paths-ignore:
      - ".gitignore"
      - "docker-compose.*.yml"
      - "docker-compose.yml"
      - "*.md"
      - "docs/*.m*"
      - "public/docs/*.yaml"
      - "dockerfiles/nginx-unit/**"

defaults:
  run:
    shell: 'bash -Eeuo pipefail -x {0}'

concurrency:
  group: ${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read
  packages: write

env:
  REGISTRY: ghcr.io
  DOCKER_TAG: ci-run-${{ github.run_number }}
  PROJECT: xxx
  IMAGE_PREFIX: ${{ github.repository_owner }}/xxx

jobs:
  build:
    name: Build and publish image
    timeout-minutes: 15
    runs-on: [self-hosted]
    outputs:
      env: ${{ steps.env.outputs.APP_ENV }}
    env:
        DOCKERFILE: docker_settings/prod/Dockerfile.debian
        GH_CACHE: --cache-from type=gha --cache-to type=gha,mode=max
        CMD_BUILD: docker buildx build --load
    steps:
      - name: 'Calculate PR commits + 1'
        id: precalc
        run: |
          echo "pr_fetch_depth=$(( ${{ github.event_name == 'pull_request' && github.event.pull_request.commits || 1 }} + 1 ))" >> $GITHUB_OUTPUT
          if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
            echo "COMMIT_RANGE=${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV
          else
            echo "COMMIT_RANGE=${{ github.sha }}..${{ github.sha }}" >> $GITHUB_ENV
          fi

      - name: 'Checkout last commit or all PR commits + 1'
        uses: actions/checkout@v4
        with:
          ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || '' }}
          fetch-depth: ${{ steps.precalc.outputs.pr_fetch_depth }}

      - name: 'Determine environment'
        id: env
        run: |
          if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
            echo "APP_ENV=integration" >> $GITHUB_OUTPUT
          else
            if [ "$GITHUB_REF" = "refs/heads/master" ]; then
              echo "APP_ENV=production" >> $GITHUB_OUTPUT
            elif [ "$GITHUB_REF" = "refs/heads/staging" ]; then
              echo "APP_ENV=staging" >> $GITHUB_OUTPUT
            else
              echo "APP_ENV=integration" >> $GITHUB_OUTPUT
            fi
          fi

      - name: 'Set Env'
        run: |
          echo "APP_ENV=${{ steps.env.outputs.APP_ENV }}" >> $GITHUB_ENV

      - name: 'Calculate changed .php files'
        run: |
          {
            echo 'CHANGED_FILES<<EOF'
            echo $(git diff --name-only --diff-filter=ACMRTUXB "${COMMIT_RANGE}" | grep -e '\.php$')
            echo EOF
          } >> "$GITHUB_ENV"

      - name: Set Test image name
        run: |
          echo "CLI_TEST_IMAGE=${IMAGE_PREFIX}-cli-dev:test" >> "$GITHUB_ENV"

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3

Workflow logs

Run docker/setup-buildx-action@v3

Docker info
  Unable to locate executable file: docker. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.
Download buildx from GitHub Releases
  Use 0.18.0 version spec cache key for v0.18.0
  Restored from hosted tool cache /home/docker/actions-runner/_work/_tool/buildx-dl-bin/0.18.0/linux-x64
  Buildx binary found in /home/docker/.docker/buildx/.bin/0.18.0/linux-x64/docker-buildx
Install buildx
  Standalone mode
  Fixing perms
  Added Buildx to PATH
  Binary path: /home/docker/actions-runner/_work/_temp/docker-actions-toolkit-YCcK5q/buildx-bin-standalone/buildx
Buildx version
  /home/docker/actions-runner/_work/_temp/docker-actions-toolkit-YCcK5q/buildx-bin-standalone/buildx version
  github.com/docker/buildx v0.18.0 fa4461b9a1ec45c[23](https://github.com/xxx/xxx/actions/runs/11740439660/job/32710956276#step:8:25)d1b9e32dee0d0a8ed29900b
Creating a new builder instance
  /home/docker/actions-runner/_work/_temp/docker-actions-toolkit-YCcK5q/buildx-bin-standalone/buildx create --name builder-a9957423-2c78-4912-9d97-c2cf6ef09b0f --driver docker-container --buildkitd-flags --allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host --use
  ERROR: failed to initialize builder builder-a9957423-2c78-4912-9d97-c2cf6ef09b0f (builder-a9957423-2c78-4912-9d97-c2cf6ef09b0f0): Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Error: ERROR: failed to initialize builder builder-a9957423-2c78-4912-9d97-c2cf6ef09b0f (builder-a9957423-2c78-4912-9d97-c2cf6ef09b0f0): Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

BuildKit logs

No response

Additional info

No response

crazy-max commented 1 week ago

What output gives this Docker info step right before the Calculate PR commits + 1 one?:

      - name: Docker info
        run: docker info

      - name: 'Calculate PR commits + 1'
        id: precalc
        ...
elyulka commented 1 week ago

@crazy-max It seems runner stopped seeing docker from the host os.

Run docker info
  docker info
  shell: /usr/bin/bash -Eeuo pipefail -x {0}
  env:
    REGISTRY: ghcr.io
    DOCKER_TAG: ci-run-434
    PROJECT: stho-backend
    IMAGE_PREFIX: softrize/stho-backend
    DOCKERFILE: docker_settings/prod/Dockerfile.debian
    GH_CACHE: --cache-from type=gha --cache-to type=gha,mode=max
    CMD_BUILD: docker buildx build --load
+ docker info
/home/docker/actions-runner/_work/_temp/d44879dc-f30[2](https://github.com/xxx/xxx/actions/runs/11742373570/job/32712963139#step:2:2)-4927-a04d-1e41fcbf2af5.sh: line 1: docker: command not found
Error: Process completed with exit code 12[7](https://github.com/xxx/xxx/actions/runs/11742373570/job/32712963139#step:2:7).
crazy-max commented 1 week ago

Ok closing this issue as this seems to be an issue with your self hosted runner and not the action but let us know how things go.