diff --git a/scripts/bash/tcb-env-setup.sh b/scripts/bash/tcb-env-setup.sh index 5d319fa6d..c9ad7e929 100755 --- a/scripts/bash/tcb-env-setup.sh +++ b/scripts/bash/tcb-env-setup.sh @@ -43,6 +43,7 @@ tcb_env_setup_cleanup () { unset under_windows unset user_tag unset storage + unset working_directory unset volumes unset network unset remote_tags @@ -95,6 +96,11 @@ tcb_env_setup_usage () { echo " It must be an absolute directory or a Docker volume name. If this" echo " flag is not set, the \"storage\" Docker volume will be used." echo "" + echo " -wd: select working directory for docker mount to /workdir" + echo " (Optional) Pass the directory explicitly for docker run torizon/torizoncore-builder" + echo " to mount as /workdir." + echo " It must be an absolute directory. If this is not set, \$(pwd) with be used" + echo "" echo " -n: do not enable \"host\" network mode." echo " Under Linux the tool runs in \"host\" network mode by default allowing" echo " it to operate as a server without explicit port publishing. Under" @@ -133,6 +139,7 @@ fi # Parse flags volumes=" -v /deploy " storage="storage" +working_directory="working_directory" network=" --network=host " if [ $under_windows = "1" ]; then # Do not use "host" network mode under Windows/WSL @@ -144,6 +151,7 @@ do -a) source=$2;[ "$2" ]||source="empty"; shift; shift;; -t) user_tag="$2";[ "$2" ]||user_tag="empty"; shift; shift;; -s) storage="$2";[ "$2" ]||storage="empty"; shift; shift;; + -wd) working_directory="$2";[ "$2" ]||working_directory=$(pwd); shift; shift;; -d) volumes=" "; shift;; -n) network=" "; shift;; --) shift; break;; @@ -293,7 +301,7 @@ function tcb_dynamic_params() { # TODO Not compatible with ZSH export -f tcb_dynamic_params -alias torizoncore-builder='docker run --rm'"$volumes"'-v "$(pwd)":/workdir -v '"$storage"':/storage -v /var/run/docker.sock:/var/run/docker.sock'"$network"'$(tcb_dynamic_params) '"$*"' torizon/torizoncore-builder:'"$chosen_tag" +alias torizoncore-builder='docker run --rm'"$volumes"' -v '"$working_directory"':/workdir -v '"$storage"':/storage -v /var/run/docker.sock:/var/run/docker.sock'"$network"' '"$(tcb_dynamic_params)"' '"$*"' torizon/torizoncore-builder:'"$chosen_tag" [[ $storage =~ ^[a-zA-Z][a-zA-Z0-9_.-]*$ ]] && storage="Docker volume named '$storage'" diff --git a/scripts/tasks.ps1 b/scripts/tasks.ps1 index 213cd8893..620edb5ff 100644 --- a/scripts/tasks.ps1 +++ b/scripts/tasks.ps1 @@ -649,9 +649,20 @@ function getCliInputs () { # set the relative workspaceFolder (following the pattern that VS Code expects) if ( ($null -eq $env:APOLLOX_WORKSPACE) -and - ($env:APOLLOX_CONTAINER -ne 1) + ($env:APOLLOX_CONTAINER -ne 1) -and + (!$env:GITHUB_WORKSPACE) ) { $Global:workspaceFolder = Join-Path $PSScriptRoot .. +} +elseif ( + $env:GITHUB_WORKSPACE +) { + # If running in a github action, this ENV is set automatically, + # github actions sandboxes runners by re-writing their ABS path, + # so when we do a docker-in-docker build, the mount point for workdir is not found. + # This sets the ABS path from a file called abs-path + $Global:workspaceFolder = Join-Path $PSScriptRoot .. + $Global:working_directory = Get-Content -Path abs-path -ReadCount 1 } else { $Global:workspaceFolder = $env:APOLLOX_WORKSPACE } diff --git a/tcb/.github/workflows/build-torizoncore.yaml b/tcb/.github/workflows/build-torizoncore.yaml index 03cd3f737..03a485870 100644 --- a/tcb/.github/workflows/build-torizoncore.yaml +++ b/tcb/.github/workflows/build-torizoncore.yaml @@ -6,6 +6,7 @@ jobs: build-deploy: runs-on: ubuntu-latest name: Build & Deploy TorizonCore + container: ubuntu:23.10 steps: - uses: actions/checkout@v3 - uses: actions/cache@v3 @@ -13,6 +14,19 @@ jobs: with: path: storage/ key: tcb + - name: Set abs-path file + run: | + echo "${{ github.workspace }}" >> abs-path + cat abs-path + - name: Install build tools in container + run: | + apt-get update + apt-get install -y wget curl libicu-dev + curl -fsSL https://get.docker.com -o get-docker.sh + sh get-docker.sh + + wget -nv https://github.com/PowerShell/PowerShell/releases/download/v7.4.2/powershell_7.4.2-1.deb_amd64.deb + dpkg -i powershell_7.4.2-1.deb_amd64.deb - name: Initial Setup shell: bash @@ -34,6 +48,7 @@ jobs: PLATFORM_CLIENT_SECRET: ${{ secrets.PLATFORM_CLIENT_SECRET }} run: | ./.vscode/tasks.ps1 run tcb-setup + ./.vscode/tasks.ps1 run tcb-unpack ./.vscode/tasks.ps1 run tcb-platform-push-ostree - name: Deploy to Fleet diff --git a/tcb/.vscode/tasks.json b/tcb/.vscode/tasks.json index 88054cb79..a1c6faf43 100644 --- a/tcb/.vscode/tasks.json +++ b/tcb/.vscode/tasks.json @@ -433,7 +433,9 @@ "-s", "${workspaceFolder}/storage", "-t", - "${config:tcb.version}" + "${config:tcb.version}", + "-wd", + "${working_directory}" ], "problemMatcher": [ "$tsc" @@ -444,6 +446,9 @@ }, "dependsOrder": "sequence", "dependsOn": [ + // "tcb-unpack" // This will only run the unpack task, + // and exit without running platform push + ] }, {