Add .gitlab-ci.yml

parent 4949e075
Pipeline #6748 failed with stages
in 4 seconds
image: registry-git.herzen.spb.ru/docker/kub
stages:
- build
- publish
- cleanup
before_script:
- mkdir -p /root/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /root/.docker/config.json
# =================================== Build ===================================
build:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
script:
- /kaniko/executor --context=$CI_PROJECT_DIR --build-arg CONTEXT=$CI_PROJECT_DIR --build-arg REF=$CI_BUILD_REF --build-arg ERRORREPORTING=E_ALL --dockerfile=$CI_PROJECT_DIR/Dockerfile --destination=$CI_REGISTRY_IMAGE:$CI_BUILD_REF
# ================================ Publish to kubernetes =============================
publish:
stage: publish
script:
- export ENV KUBECONFIG=/config-production
- sed -i "s#IMAGE#$CI_REGISTRY_IMAGE:$CI_BUILD_REF#g" deploy.yaml
- kubectl apply -f deploy.yaml
only:
- tags
- master
# Cleanup registry
cleanup:
image: python:3.6-alpine
stage: cleanup
script:
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- wget https://raw.githubusercontent.com/n0madic/gitlab-registry-images-cleaner/master/gricleaner.py
- wget https://raw.githubusercontent.com/n0madic/gitlab-registry-images-cleaner/master/requirements.txt
- pip install -r requirements.txt
- python gricleaner.py -r $CI_PROJECT_PATH -m 5 -d 1 -u cleaner -p kar9Hz4RBKYKG3w -g $CI_REGISTRY -j https://git.herzen.spb.ru/jwt/auth/
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment