chore: use context instead of Dockerfile

This commit is contained in:
Tommy 2025-01-03 13:56:54 +01:00
parent 762bce9289
commit 823c66003c
Signed by: tommy
SSH key fingerprint: SHA256:1LWgQT3QPHIT29plS8jjXc3S1FcE/4oGvsx3Efxs6Uc

View file

@ -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"