impossible de surcharger la variable DOCKERFILE_DIR quand WITH_DOCKER_JOBS==TRUE
Impossible d'utiliser les jobs prédéfinis : docker:build:latest
, docker:build:version
, docker:build:tag
et de prendre en compte une surcharge de la variable DOCKERFILE_DIR
Par exemple le gitlab-ci.yaml
suivant ne fonctionne pas (cf. https://gitlab.gpf-tech.ign.fr/geoplateforme/altimetrie/api-rest-calcul-altimetrique/-/jobs/99750) :
variables:
WITH_DOCKER_JOBS: "true"
DOCKER_IMG_NAME: "altimetry-rest-api"
DOCKERFILE_DIR: "docker/"
BUILD_ARGS: " --no-cache "
# Templates
include:
- project: geoplateforme/templates
ref: main
file:
- "/ci/docker-v4.yml"
Il faudrait modifier le docker-v4.yaml
, par exemple :
.docker-build-latest:
extends: .docker-build
before_script:
- |
if [[ -f .appVersion ]]; then
export TAG_NAME=$(cat .appVersion)
fi
rules:
- if: $CI_COMMIT_TAG != null
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH =~ /^release-/
.docker-build-version:
extends: .docker-build
variables:
TAG_NAME: $CI_COMMIT_REF_SLUG
rules:
- if: $CI_COMMIT_TAG != null
when: never
- if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH && $CI_COMMIT_BRANCH !~ /^release-/
when: manual
allow_failure: true
.docker-build-tag:
extends: .docker-build
before_script:
- export TAG_NAME="$(git describe --tags --abbrev=0)"
- if [[ -z "${TAG_NAME}" ]]; then export TAG_NAME="latest"; fi
rules:
- if: $CI_COMMIT_TAG != null
docker:build:latest:
extends: .docker-build-latest
rules:
- if: $WITH_DOCKER_JOBS != "true"
when: never
docker:build:version:
extends: .docker-build-version
rules:
- if: $WITH_DOCKER_JOBS != "true"
when: never
docker:build:tag:
extends: .docker-build-tag
rules:
- if: $WITH_DOCKER_JOBS != "true"
when: never
Ce qui permettrai de faire dans le gitlab-ci.yaml
d'un projet :
variables:
WITH_DOCKER_JOBS: "false"
# Templates
include:
- project: geoplateforme/templates
ref: main
file:
- "/ci/docker-v4.yml"
docker:build:tag:
extends: .docker-build-tag
variables:
DOCKERFILE_DIR: "docker/"
@simon.henry est ce que ca parait cohérent ?