π§© The Problem
You have multiple (group) projects (frontend, backend, etc.) and you want:
A single Dockerfile in a central repo ( cicd-template/frontend/gitlab-template.yml )
All group app repos reuse it
No duplication, no drift, better control
You try:
include : - project : " kelvyn-labs/cicd-template" ref : master file : " /frontend/gitlab-ci.yml"
But during the pipeline:
docker build -f frontend/Dockerfile .
π β It fails β file not found
π§ Why This Happens
In GitLab:
include:project only imports CI YAML , not repository files
Your pipeline still runs inside:
nextjs-cicd-template
So it cannot access files from:
cicd-template
β Common (Wrong) Solutions
Copy Dockerfile into every repo β
Use Git submodules β (heavy, messy)
Assume include gives file access β
β
The Correct Solution
Use:
CI_JOB_TOKEN + GitLab Repository Files API
When a CI/CD pipeline job is about to run, GitLab generates a unique token and makes it available to the job as the CI_JOB_TOKEN predefined variable.β¦