templates/.gitlab-ci.yml

48 lines
1.9 KiB
YAML
Raw Normal View History

2022-02-24 22:44:42 +00:00
#before_script:
# - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
build-latest:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
# variables:
# STORAGE_DRIVER: vfs
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- >-
for img in $(ls -1 images/*/Dockerfile | sed 's|^images/\(.*\)/Dockerfile|\1|g');do
/kaniko/executor \
--force \
--cache=true \
--context "${CI_PROJECT_DIR}/images/$img" \
--dockerfile "${CI_PROJECT_DIR}/images/$img/Dockerfile" \
--destination "${CI_REGISTRY_IMAGE}/$img:${CI_COMMIT_TAG}"
done
# Remove --force once https://github.com/GoogleContainerTools/kaniko/issues/1542 is fixed
# docker build -t "$CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA" images/$img
# docker push "$CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA"
# docker tag $CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:latest
# docker push "$CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:latest"
# script: |
# env
# set -x
# for img in $(ls -1 images/*/Dockerfile | sed 's|^images/\(.*\)/Dockerfile|\1|g');do
# docker build -t "$CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA" images/$img
# docker push "$CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA"
# docker tag $CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA $CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:latest
# docker push "$CI_REGISTRY_IMAGE/$img/$CI_COMMIT_REF_NAME:latest"
# done
# set +x
# except:
# - tags
# only:
# changes:
# - "images/*"
# - "images/**/*"
# - "images/**"