Commit 09376c65 authored by Bruno Martin's avatar Bruno Martin
Browse files

set gitlab ci

parent e4e79bd6
Pipeline #7377 canceled with stages
......@@ -9,117 +9,76 @@ stages:
variables:
DJANGO_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/django:$CI_BUILD_REF_NAME
NGINX_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/nginx:$CI_BUILD_REF_NAME
DJANGO_HOMOLOG_IMAGE: $CI_REGISTRY_IMAGE/django:$CI_BUILD_REF_NAME-$CI_COMMIT_SHORT_SHA
NGINX_hOMOLOG_IMAGE: $CI_REGISTRY_IMAGE/nginx:$CI_BUILD_REF_NAME-$CI_COMMIT_SHORT_SHA
KUBECONFIG: /etc/k8s-config
#############
## Production
#############
build to production:
##########
## Homolog
##########
build to homolog:
stage: build
script:
- docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker build -f compose/production/Dockerfile --target django -t $DJANGO_RELEASE_IMAGE .
- docker tag $DJANGO_RELEASE_IMAGE "$CI_REGISTRY_IMAGE/django:latest"
- docker push $DJANGO_RELEASE_IMAGE
- docker push "$CI_REGISTRY_IMAGE/django:latest"
- docker build -f compose/production/Dockerfile --target nginx -t $NGINX_RELEASE_IMAGE .
- docker tag $NGINX_RELEASE_IMAGE "$CI_REGISTRY_IMAGE/nginx:latest"
- docker push $NGINX_RELEASE_IMAGE
- docker push "$CI_REGISTRY_IMAGE/nginx:latest"
- docker build -f compose/production/Dockerfile --target django -t $DJANGO_HOMOLOG_IMAGE .
- docker push $DJANGO_HOMOLOG_IMAGE
- docker build -f compose/production/Dockerfile --target nginx -t $NGINX_HOMOLOG_IMAGE .
- docker push $NGINX_HOMOLOG_IMAGE
only:
- tags
environment: production
- /master/
environment: homolog
variables:
GIT_SUBMODULE_STRATEGY: recursive
tags:
- docker
# deploy to production:
# stage: deploy
# image: cdrx/rancher-gitlab-deploy
# script:
# - upgrade --environment <env_name> --stack <stack_name> --service <service_name> --no-finish-upgrade --sidekicks
# only:
# - tags
# environment: production
# variables:
# GIT_STRATEGY: none
# tags:
# - docker
deploy to homolog:
stage: deploy
image: hacklab/kubectl:latest
script:
- echo ${kube_config} | base64 -d > ${KUBECONFIG}
- kubectl -n ctb-escola-dev --record deployment.apps/django set image deployment.v1.apps/django django=$DJANGO_HOMOLOG_IMAGE nginx=$NGINX_HOMOLOG_IMAGE
only:
- /master/
environment: homolog
variables:
GIT_STRATEGY: none
tags:
- docker
##########
## Homolog
##########
build to homolog:
#############
## Production
#############
build to production:
stage: build
script:
- docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker build -f compose/production/Dockerfile --target django -t $DJANGO_RELEASE_IMAGE .
- docker tag $DJANGO_RELEASE_IMAGE "$CI_REGISTRY_IMAGE/django:master"
- docker tag $DJANGO_RELEASE_IMAGE "$CI_REGISTRY_IMAGE/django:latest"
- docker push $DJANGO_RELEASE_IMAGE
- docker push "$CI_REGISTRY_IMAGE/django:master"
- docker push "$CI_REGISTRY_IMAGE/django:latest"
- docker build -f compose/production/Dockerfile --target nginx -t $NGINX_RELEASE_IMAGE .
- docker tag $NGINX_RELEASE_IMAGE "$CI_REGISTRY_IMAGE/nginx:master"
- docker tag $NGINX_RELEASE_IMAGE "$CI_REGISTRY_IMAGE/nginx:latest"
- docker push $NGINX_RELEASE_IMAGE
- docker push "$CI_REGISTRY_IMAGE/nginx:master"
- docker push "$CI_REGISTRY_IMAGE/nginx:latest"
only:
- /master/
environment: homolog
- tags
environment: production
variables:
GIT_SUBMODULE_STRATEGY: recursive
tags:
- docker
# test to homolog:
# stage: test
# script:
# - docker build -f compose/test/django/Dockerfile -t $DJANGO_RELEASE_IMAGE .
# - docker tag $DJANGO_RELEASE_IMAGE "$CI_REGISTRY_IMAGE/django:test"
# - docker run -d --env-file=./compose/test/test_env --name=postgres postgres:9.6
# - docker run --env-file=./compose/test/test_env --link=postgres:postgres "$CI_REGISTRY_IMAGE/django:test" /test.sh
# only:
# - /master/
# environment: homolog
# variables:
# GIT_STRATEGY: none
# tags:
# - docker
# deploy to homolog:
# stage: deploy
# image: cdrx/rancher-gitlab-deploy
# script:
# - upgrade --environment <env_name> --stack <stack_name> --service <service_name> --no-finish-upgrade --sidekicks
# only:
# - /master/
# environment: homolog
# tags:
# - docker
##########
## Develop
##########
build to develop:
stage: build
deploy to production:
stage: deploy
image: hacklab/kubectl:latest
script:
- docker login -u "gitlab-ci-token" -p "$CI_JOB_TOKEN" $CI_REGISTRY
- docker build -f compose/test/django/Dockerfile -t $DJANGO_RELEASE_IMAGE .
- docker tag $DJANGO_RELEASE_IMAGE "$CI_REGISTRY_IMAGE/django:develop"
- docker push "$CI_REGISTRY_IMAGE/django:develop"
- echo ${kube_config} | base64 -d > ${KUBECONFIG}
- kubectl -n ctb-escola-prod --record deployment.apps/django set image deployment.v1.apps/django django=$DJANGO_RELEASE_IMAGE nginx=$NGINX_RELEASE_IMAGE
only:
- /develop/
environment: development
- tags
environment: production
variables:
GIT_SUBMODULE_STRATEGY: recursive
GIT_STRATEGY: none
tags:
- docker
# test to develop:
# stage: test
# script:
# - docker run -d --env-file=./compose/test/test_env --name=postgres postgres:9.6
# - docker run --env-file=./compose/test/test_env --link=postgres:postgres "$CI_REGISTRY_IMAGE/django:develop" /test.sh
# only:
# - /develop/
# environment: development
# tags:
# - docker
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