Commit c36a39d2 authored by Ruben ten Hove's avatar Ruben ten Hove
Browse files

Merge branch 'docker-cache' into 'main'

fix: docker buildx registry cache

See merge request just-ci/templates!222
parents 9bdc8c2d ba5129d3
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -11,9 +11,7 @@ variables:

include:
  - local: pipelines/project-automation.yml
  - local: yaml/yamllint.yml
  # - local: project-automation/pipeline-scheduler.yml
  # - local: project-automation/gitlab/py-in-ci.yml
  - local: docs/prettier.yml

# child pipeline to unit tests all our jobs
+0 −5
Original line number Diff line number Diff line
@@ -16,11 +16,6 @@ repos:
        args: ["--fix=lf"]
        description: Forces to replace line ending by the UNIX 'lf' character.

  - repo: https://github.com/adrienverge/yamllint
    rev: v1.32.0
    hooks:
      - id: yamllint

  - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
    rev: v2.2.0
    hooks:

.yamllint.yml

deleted100644 → 0
+0 −5
Original line number Diff line number Diff line
---
extends: default

rules:
  line-length: disable
+11 −5
Original line number Diff line number Diff line
@@ -26,15 +26,21 @@ variables:
      fi

    - docker buildx inspect --bootstrap
    - docker login ${CI_REGISTRY} -u ${CI_REGISTRY_USER} -p
      ${CI_REGISTRY_PASSWORD}
    - echo "${CI_REGISTRY_PASSWORD}" | docker login ${CI_REGISTRY} -u
      ${CI_REGISTRY_USER} --password-stdin
    - docker buildx create --use
    - |
      if [ "${DOCKER_EXTRA_ARGS}" != "" ]; then
        echo "[*] Applying the extra arguments '${DOCKER_EXTRA_ARGS}'."
      fi
    - |
      docker buildx build --push \
      --tag ${IMAGE_NAME}:${IMAGE_TAG} \
      --tag ${IMAGE_NAME}:${IMAGE_DEV_TAG} \
      if [ "${IMAGE_CACHE}" = "true" ]; then
        DOCKER_EXTRA_ARGS="${DOCKER_EXTRA_ARGS} --cache-to type=registry,ref=${IMAGE_NAME}:build-cache,mode=max"
        DOCKER_EXTRA_ARGS="${DOCKER_EXTRA_ARGS} --cache-from type=registry,ref=${IMAGE_NAME}:build-cache"
      fi
    # prettier-ignore
    - > 
      docker buildx build --push
      --tag ${IMAGE_NAME}:${IMAGE_TAG}
      --tag ${IMAGE_NAME}:${IMAGE_DEV_TAG}
      -f ${IMAGE_CONTAINERFILE} ${DOCKER_EXTRA_ARGS} .