From 3de4902d509b037d6f48c449db54ee2d5c279927 Mon Sep 17 00:00:00 2001 From: Matheus Castello Date: Tue, 14 Jan 2025 11:08:37 -0300 Subject: [PATCH] github: workflow: add docker daemon to sdk build jobs A from scratch docker daemon is required to build with the sdk containers, this is because the default docker in docker uses a abstracted docker socket that is hard to map the host folders to the container. Also the check is more complete when using a clean docker daemon. Signed-off-by: Matheus Castello --- .github/workflows/build-ccpp.yaml | 22 ++++++++++++++-- .github/workflows/build-debug-ccpp.yaml | 32 +++++++++++++++++++---- .github/workflows/build-debug-python.yaml | 5 ++++ .github/workflows/build-debug-rust.yaml | 26 ++++++++++++++---- .github/workflows/build-python.yaml | 5 ++++ .github/workflows/build-rust.yaml | 22 ++++++++++++++-- 6 files changed, 98 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-ccpp.yaml b/.github/workflows/build-ccpp.yaml index 04fefd11..51ccd655 100644 --- a/.github/workflows/build-ccpp.yaml +++ b/.github/workflows/build-ccpp.yaml @@ -7,10 +7,10 @@ on: jobs: ccpp: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: image: torizonextras/torizon-dev:dev - options: --user root + options: --privileged --user root if: github.ref == 'refs/heads/bookworm' || github.ref == 'refs/heads/dev' name: C/C++ Container strategy: @@ -32,6 +32,23 @@ jobs: echo "${{ github.workspace }}" >> abs-path cat abs-path + - name: Update torizon-utils module + run: | + chmod a+rwx . -R + sudo -u torizon pipx inject xonsh ./scripts/utils/pip/ + + - name: Run Docker Daemon + run: | + mkdir -p /var/lib/docker + dockerd \ + --data-root=/var/lib/docker \ + --host=unix:///var/run/docker-alt.sock \ + --tls=false \ + --host=tcp://0.0.0.0:2376 \ + --userland-proxy-path=/usr/libexec/docker/docker-proxy \ + --userland-proxy=false & + sleep 10 + - name: Build ${{ matrix.project.folder }} Dockerfile shell: xonsh {0} env: @@ -39,6 +56,7 @@ jobs: PROJECT_CONTAINER: ${{ matrix.project.container }} VENDOR: ${{ matrix.project.vendor }} DOCKER_LOGIN: localhost:5002 + GITHUB_WORKSPACE_DOCKER: 2376 run: | import os diff --git a/.github/workflows/build-debug-ccpp.yaml b/.github/workflows/build-debug-ccpp.yaml index 25842f22..52691bc0 100644 --- a/.github/workflows/build-debug-ccpp.yaml +++ b/.github/workflows/build-debug-ccpp.yaml @@ -7,10 +7,10 @@ on: jobs: ccpp-debug: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: image: torizonextras/torizon-dev:dev - options: --user root + options: --privileged --user root if: github.ref == 'refs/heads/bookworm' || github.ref == 'refs/heads/dev' name: C/C++ Container Debug strategy: @@ -27,11 +27,34 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Cleanup Space + run: | + # our builds are a bit larger than expected + # so we need to clean up the space from the runner + sudo nsenter -t 1 -m -u -n -i -- df -h + - name: Get Host Absolute Workspace Path run: | echo "${{ github.workspace }}" >> abs-path cat abs-path + - name: Update torizon-utils module + run: | + chmod a+rwx . -R + sudo -u torizon pipx inject xonsh ./scripts/utils/pip/ + + - name: Run Docker Daemon + run: | + mkdir -p /var/lib/docker + dockerd \ + --data-root=/var/lib/docker \ + --host=unix:///var/run/docker-alt.sock \ + --tls=false \ + --host=tcp://0.0.0.0:2376 \ + --userland-proxy-path=/usr/libexec/docker/docker-proxy \ + --userland-proxy=false & + sleep 10 + - name: Build ${{ matrix.project.folder }} Dockerfile shell: xonsh {0} env: @@ -39,6 +62,7 @@ jobs: PROJECT_CONTAINER: ${{ matrix.project.container }} VENDOR: ${{ matrix.project.vendor }} DOCKER_LOGIN: localhost:5002 + GITHUB_WORKSPACE_DOCKER: 2376 run: | import os @@ -70,9 +94,7 @@ jobs: with open(".vscode/settings.json", "w") as file: json.dump(settings_json, file, indent=4) - # FIXME: this is bad, but it's the only to make it work here - chmod 777 . -R - + chmod a+rwx . -R xonsh ./.vscode/tasks.xsh run run-torizon-binfmt xonsh ./.vscode/tasks.xsh run @(f"build-debug-{os.environ['PROJECT_ARCH']}") xonsh ./.vscode/tasks.xsh run @(f"build-container-torizon-debug-{os.environ['PROJECT_ARCH']}") diff --git a/.github/workflows/build-debug-python.yaml b/.github/workflows/build-debug-python.yaml index 94b76e83..4e64e1fa 100644 --- a/.github/workflows/build-debug-python.yaml +++ b/.github/workflows/build-debug-python.yaml @@ -28,6 +28,11 @@ jobs: echo "${{ github.workspace }}" >> abs-path cat abs-path + - name: Update torizon-utils module + run: | + chmod a+rwx . -R + sudo -u torizon pipx inject xonsh ./scripts/utils/pip/ + - name: Build ${{ matrix.project.folder }} Dockerfile shell: xonsh {0} env: diff --git a/.github/workflows/build-debug-rust.yaml b/.github/workflows/build-debug-rust.yaml index eafc7e5a..06c0b813 100644 --- a/.github/workflows/build-debug-rust.yaml +++ b/.github/workflows/build-debug-rust.yaml @@ -7,10 +7,10 @@ on: jobs: rust-debug: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: image: torizonextras/torizon-dev:dev - options: --user root + options: --privileged --user root if: github.ref == 'refs/heads/bookworm' || github.ref == 'refs/heads/dev' name: Rust Container Debug strategy: @@ -28,6 +28,23 @@ jobs: echo "${{ github.workspace }}" >> abs-path cat abs-path + - name: Update torizon-utils module + run: | + chmod a+rwx . -R + sudo -u torizon pipx inject xonsh ./scripts/utils/pip/ + + - name: Run Docker Daemon + run: | + mkdir -p /var/lib/docker + dockerd \ + --data-root=/var/lib/docker \ + --host=unix:///var/run/docker-alt.sock \ + --tls=false \ + --host=tcp://0.0.0.0:2376 \ + --userland-proxy-path=/usr/libexec/docker/docker-proxy \ + --userland-proxy=false & + sleep 10 + - name: Build ${{ matrix.project.folder }} Dockerfile shell: xonsh {0} env: @@ -35,6 +52,7 @@ jobs: PROJECT_CONTAINER: ${{ matrix.project.container }} VENDOR: ${{ matrix.project.vendor }} DOCKER_LOGIN: localhost:5002 + GITHUB_WORKSPACE_DOCKER: 2376 run: | import os @@ -66,9 +84,7 @@ jobs: with open(".vscode/settings.json", "w") as file: json.dump(settings_json, file, indent=4) - # FIXME: this is bad, but it's the only to make it work here - chmod 777 . -R - + chmod a+rwx . -R xonsh ./.vscode/tasks.xsh run run-torizon-binfmt xonsh ./.vscode/tasks.xsh run @(f"build-debug-{os.environ['PROJECT_ARCH']}") xonsh ./.vscode/tasks.xsh run @(f"copy-debug-executable-{os.environ['PROJECT_ARCH']}") diff --git a/.github/workflows/build-python.yaml b/.github/workflows/build-python.yaml index db621547..8eb46c22 100644 --- a/.github/workflows/build-python.yaml +++ b/.github/workflows/build-python.yaml @@ -28,6 +28,11 @@ jobs: echo "${{ github.workspace }}" >> abs-path cat abs-path + - name: Update torizon-utils module + run: | + chmod a+rwx . -R + sudo -u torizon pipx inject xonsh ./scripts/utils/pip/ + - name: Build ${{ matrix.project.folder }} Dockerfile shell: xonsh {0} env: diff --git a/.github/workflows/build-rust.yaml b/.github/workflows/build-rust.yaml index 2d2226ce..688d9a98 100644 --- a/.github/workflows/build-rust.yaml +++ b/.github/workflows/build-rust.yaml @@ -7,10 +7,10 @@ on: jobs: rust: - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 container: image: torizonextras/torizon-dev:dev - options: --user root + options: --privileged --user root if: github.ref == 'refs/heads/bookworm' || github.ref == 'refs/heads/dev' name: Rust Container strategy: @@ -28,6 +28,23 @@ jobs: echo "${{ github.workspace }}" >> abs-path cat abs-path + - name: Update torizon-utils module + run: | + chmod a+rwx . -R + sudo -u torizon pipx inject xonsh ./scripts/utils/pip/ + + - name: Run Docker Daemon + run: | + mkdir -p /var/lib/docker + dockerd \ + --data-root=/var/lib/docker \ + --host=unix:///var/run/docker-alt.sock \ + --tls=false \ + --host=tcp://0.0.0.0:2376 \ + --userland-proxy-path=/usr/libexec/docker/docker-proxy \ + --userland-proxy=false & + sleep 10 + - name: Build ${{ matrix.project.folder }} Dockerfile shell: xonsh {0} env: @@ -35,6 +52,7 @@ jobs: PROJECT_CONTAINER: ${{ matrix.project.container }} VENDOR: ${{ matrix.project.vendor }} DOCKER_LOGIN: localhost:5002 + GITHUB_WORKSPACE_DOCKER: 2376 run: | import os