It is cache-from

This commit is contained in:
Kamil Trzciński 2021-02-02 13:44:38 +01:00
parent c393e4e804
commit 2269f81b22
2 changed files with 12 additions and 6 deletions

View file

@ -38,13 +38,16 @@ variables:
# http://unix.stackexchange.com/a/137571
- set -- $CI_JOB_NAME
- docker pull "$CI_REGISTRY_IMAGE:$1" || true
- docker build --from-cache="$CI_REGISTRY_IMAGE:$1" -f "Dockerfile.$1" .
- docker build --cache-from="$CI_REGISTRY_IMAGE:$1" -f "Dockerfile.$1" .
.build_and_deploy: &build_and_deploy
extends: .build
script:
# Hack to set an array in /bin/sh
# http://unix.stackexchange.com/a/137571
- set -- $CI_JOB_NAME
- docker pull "$CI_REGISTRY_IMAGE:$1" || true
- docker build --from-cache="$CI_REGISTRY_IMAGE:$1" --label "ci_pipeline_url=$CI_PIPELINE_URL" --label "ci_job_url=$CI_JOB_URL" -t "$CI_REGISTRY_IMAGE:$CI_JOB_NAME" -f "Dockerfile.$CI_JOB_NAME" .
- docker build --cache-from="$CI_REGISTRY_IMAGE:$1" --label "ci_pipeline_url=$CI_PIPELINE_URL" --label "ci_job_url=$CI_JOB_URL" -t "$CI_REGISTRY_IMAGE:$1" -f "Dockerfile.$1" .
- docker push "$CI_REGISTRY_IMAGE:$CI_JOB_NAME"
.test_custom: &test_custom
@ -53,15 +56,18 @@ variables:
# Hack to set an array in /bin/sh
# http://unix.stackexchange.com/a/137571
- set -- $CI_JOB_NAME
- ./scripts/custom-docker-build $1
- ./scripts/custom-docker-build "$1"
rules:
- when: always
.build_and_deploy_custom: &build_and_deploy_custom
extends: .build
script:
- ./scripts/custom-docker-build $CI_JOB_NAME --label "ci_pipeline_url=$CI_PIPELINE_URL" --label "ci_job_url=$CI_JOB_URL" -t "$CI_REGISTRY_IMAGE:$CI_JOB_NAME"
- docker push "$CI_REGISTRY_IMAGE:$CI_JOB_NAME"
# Hack to set an array in /bin/sh
# http://unix.stackexchange.com/a/137571
- set -- $CI_JOB_NAME
- ./scripts/custom-docker-build "$1" --label "ci_pipeline_url=$CI_PIPELINE_URL" --label "ci_job_url=$CI_JOB_URL" -t "$CI_REGISTRY_IMAGE:$1"
- docker push "$CI_REGISTRY_IMAGE:$1"
# Tests

View file

@ -305,7 +305,7 @@ function build_custom_if_needed() {
# This re-uses and builds an existing image if needed
docker pull "$full_image" || true
docker_command=$(generate_command $@ --from-cache="$full_image_name" )
docker_command=$(generate_command $@ --cache-from="$full_image_name" )
echo "Building $build_image_name with $docker_command"
eval $docker_command
}