Newer
Older
# template job for building images
# To use:
#
# include:
# - project: 'cspp_geo/geosphere/geosphere-deploy'
# file: '/helpers/docker_base.yaml'
# - project: 'cspp_geo/geosphere/geosphere-deploy'
# file: '/helpers/build_image.yaml'
#
# build_image_grb:
# extends: .build_image
# variables:
# IMAGE_NAME: "cspp-geo-grb"
# IMAGE_DIR: "cspp_geo_grb"
.build_image:
variables:
IMAGE_NAME: ""
IMAGE_DIR: ""
script:
- image_url="${CI_REGISTRY_IMAGE}/${IMAGE_NAME}"
- if [ -z "$CI_COMMIT_TAG" ]; then
docker_tag=$CI_COMMIT_SHORT_SHA;
docker_tag=$CI_COMMIT_TAG;
fi;
- echo $docker_tag
- docker pull ${image_url}:latest || true
- docker build --cache-from ${image_url}:latest -t "${image_url}:latest" -t "${image_url}:${docker_tag}" ${IMAGE_DIR}
- docker push ${image_url}:${docker_tag}
- docker push ${image_url}:latest