Where is the Dockerfile located when its configured to generate dynamically

I have an enhancement to use Kaniko for Docker builds on Gitlab but the pipeline is failing to locate the dynamically generated Dockerfile with error :

$ echo "Docker build"
Docker build
$ cd ./src
$ pwd
$ cp /builds/group/subgroup/labs/src/Dockerfile /builds/group/subgroup/labs
cp: can't stat '/builds/group/subgroup/labs/src/Dockerfile': No such file or directory
Cleaning up project directory and file based variables
ERROR: Job failed: command terminated with exit code 1

For context the pipeline was designed to generate a Dockerfile dynamically for any particular project:

     script: |
        echo "checking dockerfile existence"
        if ! [ -e Dockerfile ]; then 
        echo "dockerfile doesn't exist. Trying to create a new dockerfile from csproj."
        docker_entrypoint=$(grep -m 1 AssemblyName ./src/*.csproj | sed -r 's/\s*<[^>]*>//g' | sed -r 's/\r$//g').dll
        cat > Dockerfile << EOF
        FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
        WORKDIR /app
        COPY ./publish .
        ENTRYPOINT dotnet $docker_entrypoint
        echo "dockerfile created"
        echo "dockerfile exists"

In the main pipeline all that was needed was to reference .ci-scripts.yml as appropriate and do docker tag , docker push etc . This is working perfectly without Kaniko usage.

After switching to Kaniko for Docker builds, Kaniko itself expects a Dockerfile at the location ${CI_PROJECT_DIR}/Dockerfile. In my context this is the path /builds/group/subgroup/labs .
The main pipeline looks like this :

    - aaa
    name: gcr.io/kaniko-project/executor:v1.6.0-debug
    entrypoint: [""]
    - develop
  stage: docker
    - echo "Docker build"
    - pwd
    - cd ./src
    - pwd
  extends: .create_dockerfile
    DEV_TAG: dev-latest
    - cp /builds/group/subgroup/labs/src/Dockerfile /builds/group/subgroup/labs
    - mkdir -p /kaniko/.docker
    - echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
    - >-
      --context "${CI_PROJECT_DIR}"
      --dockerfile "${CI_PROJECT_DIR}/Dockerfile"
      --destination "${CI_REGISTRY_IMAGE}:${DEV_TAG}"

In the block above I maintained the dynamically generated Dockerfile at the same path (./src) by switching from default Docker build directory (/builds/group/subgroup/labs) to (/builds/group/subgroup/labs/src). The assumption is that even with dynamic generation the Dockerfile should still be maintained at (./src)

The dynamically generated Dockerfile should be available at the default Docker build path /builds/group/subgroup/labs after the script ci-script.yml finishes executing.

When I maintain a Dockerfile at the project root (at /src ) (without Kaniko usage) the Docker-build runs successfully but once I switch to dynamically generating the Dockerfile (with Kaniko usage) the pipeline cannot find the Dockerfile. When the Dockerfile is maintained at project root this way as opposed to dynamic generation I have to copy the file to the Kaniko load path via :

- cp ./src/Dockerfile /builds/group/subgroup/labs/Dockerfile
- mkdir -p /kaniko/.docker

I have a blank on how ci-script.yml is working (it was done by someone no longer around). I have tried to pwd in the script itself so as to check which directory its executing from :

    script: |
        echo "checking dockerfile existence"

but I get an error

$ - pwd # collapsed multi-line command
/scripts-1175-34808/step_script: eval: line 123: -: not found

Where exactly does Gitlab store Dockerfiles that are being generated on the fly?

Is the generated Dockerfile treated as an artifact and if so at which path will it be?