42 lines
1.2 KiB
YAML
42 lines
1.2 KiB
YAML
variables:
|
|
CI_PROJECT_DIR: "."
|
|
CI_REGISTRY_IMAGE: hub.ducoterra.net/ducoterra/django
|
|
CI_COMMIT_TAG: 3.8.2_9
|
|
DEPLOY: test
|
|
|
|
stages:
|
|
- build
|
|
- test
|
|
- deploy
|
|
|
|
build:
|
|
stage: build
|
|
image:
|
|
name: gcr.io/kaniko-project/executor:debug
|
|
entrypoint: [""]
|
|
script:
|
|
- /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
|
|
|
test:
|
|
stage: test
|
|
image:
|
|
name: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
|
|
entrypoint: [""]
|
|
script:
|
|
- python manage.py test
|
|
|
|
deploy:
|
|
stage: deploy
|
|
image:
|
|
name: debian:latest
|
|
entrypoint: [""]
|
|
script:
|
|
- echo $CI_REGISTRY_IMAGE
|
|
- apt -qq update >> /dev/null && apt -qq install -y curl gettext >> /dev/null
|
|
- curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
|
|
- chmod +x ./kubectl
|
|
- envsubst < k8s/deploy.yaml > out.yaml
|
|
- mv out.yaml k8s/deploy.yaml
|
|
- ./kubectl apply -f k8s
|
|
- ./kubectl rollout status deploy $DEPLOY
|
|
- ./kubectl exec $(./kubectl get pods --selector=app=$DEPLOY --output=jsonpath='{.items[*].metadata.name}') -- python manage.py migrate |