image: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] variables: KANIKO_CACHE_ARGS: "--cache=false --cache-copy-layers=true --cache-ttl=24h" CONTEXT: $CI_PROJECT_DIR/apps/ .py_build_merge_request: stage: build variables: CI_DEBUG_TRACE: "true" script: - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > "/kaniko/.docker/config.json" - /kaniko/executor --context $CONTEXT --dockerfile $DOCKERFILE_PATH $KANIKO_CACHE_ARGS --cache-repo $CI_REGISTRY_IMAGE --no-push rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" when: always .py_build_unittest_merge_request: stage: build variables: CI_DEBUG_TRACE: "true" artifacts: paths: - $APP_NAME-test-image.tar expire_in: 1 day when: on_success script: - /kaniko/executor --context $CONTEXT --dockerfile $DOCKERFILE_PATH $KANIKO_CACHE_ARGS --cache-repo $CI_REGISTRY_IMAGE --target test --tarPath $APP_NAME-test-image.tar" --no-push --destination $CI_REGISTRY_IMAGE/$APP_NAME:latest rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" when: always .py_unittest_merge_request: image: docker:latest stage: test script: - docker load -i $APP_NAME-test-image.tar - docker images rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" when: always .py_build_push: stage: build variables: IMAGE_TAG_BASE: $CI_REGISTRY_IMAGE/$APP_NAME:$CI_COMMIT_BRANCH-$CI_COMMIT_SHORT_SHA LATEST_TAG: $CI_REGISTRY_IMAGE/$APP_NAME:latest script: - export IMAGE_TAG="$IMAGE_TAG_BASE-$(date +%s)" - mkdir -p /kaniko/.docker - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > "/kaniko/.docker/config.json" # - /kaniko/executor --context $CONTEXT --dockerfile $DOCKERFILE_PATH $KANIKO_CACHE_ARGS --destination $IMAGE_TAG - /kaniko/executor --context $CONTEXT --dockerfile $DOCKERFILE_PATH $KANIKO_CACHE_ARGS --destination $IMAGE_TAG --destination $CI_REGISTRY_IMAGE/$APP_NAME:latest rules: - if: $CI_COMMIT_BRANCH == "master" when: always