From 823c66003c2183f47861e5c22011cda0e9ae8f70 Mon Sep 17 00:00:00 2001 From: Tommy Skaug Date: Fri, 3 Jan 2025 13:56:54 +0100 Subject: [PATCH] chore: use context instead of Dockerfile --- .forgejo/workflows/build-images.yaml | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/.forgejo/workflows/build-images.yaml b/.forgejo/workflows/build-images.yaml index 1d0029c..4bf96b9 100644 --- a/.forgejo/workflows/build-images.yaml +++ b/.forgejo/workflows/build-images.yaml @@ -16,7 +16,7 @@ on: required: false jobs: - # 1) Find all Dockerfiles under apps/* OR use the user-specified Dockerfile + # Find all Dockerfiles under apps/* OR use the user-specified Dockerfile discover-dockerfiles: runs-on: ci-os outputs: @@ -53,7 +53,7 @@ jobs: echo "dockerfiles=$json" >> "$GITHUB_OUTPUT" - # 2) For each Dockerfile discovered, build & push with Kaniko + # For each Dockerfile discovered, build & push with Kaniko build-and-push: runs-on: ci-os needs: discover-dockerfiles @@ -66,8 +66,8 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - id: set-image - name: Determine Image Name + - id: set-image-and-context + name: Determine Image Name and Context run: | # If the user provided a container image name, use it if [ -n "${{ github.event.inputs.image }}" ]; then @@ -79,12 +79,17 @@ jobs: echo "image=$image" >> "$GITHUB_OUTPUT" fi + # Derive the context directory from the Dockerfile path + # e.g. "apps/ci-os/Dockerfile" => "apps/ci-os" + context_dir=$(dirname "${{ matrix.dockerfile }}") + echo "context_dir=$context_dir" >> "$GITHUB_OUTPUT" + - name: Build and Push with Kaniko uses: https://code.252.no/pub/kaniko-action@latest with: - context: ./ - docker_file: ${{ matrix.dockerfile }} - destinations: "code.252.no/${{ github.repository }}/${{ steps.set-image.outputs.image }}:latest" + # Kaniko will look for a file named "Dockerfile" by default. + context: ${{ steps.set-image-and-context.outputs.context_dir }} + destinations: "code.252.no/${{ github.repository }}/${{ steps.set-image-and-context.outputs.image }}:latest" credentials: "code.252.no=tommy:${{ secrets.REGISTRY_TOKEN }}" push: "true" cache: "false"