toradex / vscode-torizon-templates

VS Code Torizon Integrated Development Environment Templates
MIT License
14 stars 20 forks source link

TCB - docker-in-docker build #202

Open dk-coligo opened 3 months ago

dk-coligo commented 3 months ago

The existing github actions does not function for a docker-in-docker (dind) configuration. Due to the build script using directories with root:root ownership a rootless self-hosted runner can not complete this workflow.

The configuration below adds -wd working_directory argument to the tcb-env-setup.sh script to allow absolute path to be passed directly to the docker run torizon/torizoncore-builder. Due to a dind setup, the /workdir needs to be mounted with an absolute path. Github actions provides variables containing the absolute path for the runner directory, however, this is a well documented bug in the runner since 2022:

A workaround for this is to add a build step creating a file with this abs-path to be referenced laterecho "${{ github.workspace }}" >> abs-path . Any ENV var set in actions will be replaced at run-time by the runner replacing the ABS path with a relative sandboxed path for the runner. This is why a file is written, not an ENV.

The scripts/tasks.ps1 now has an additional ENV check to detect if it's in a Actions workflow, and set the abs-path accordingly. I did not handle errors for this abs-path file not existing.

:exclamation: This is only tested for tcb-build stage, no subsequent steps - tcb-platform-push-ostree, or platform-update-fleet :exclamation:

REF: email Signed-off-by: d.kelly@coligo.ai

microhobby commented 2 months ago

@dk-coligo sorry for the delay, we are in the process of a new release, so, I will back to this after the release. We need to add it to our CI/CD integration tests to make sure that this will not break it the already existent experience.

dk-coligo commented 2 months ago

@microhobby we've had to make many other changes to the default scripts. For example, the platform-push stage for the tasks.json. In the developer documentation, there is a dependency on tcb unpack then tcb platform push. When I add this to the depends-on: parameter of the platform-push task in tasks.json, only the unpack command runs and then exits without running the platform-push. So, unpack needs explicit running in the build.yaml stage. I'll comment on the file inline separately so you can find it :)