diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 07874862..baf82a7d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -44,7 +44,7 @@ build_review_deployment: - docker:dind stage: build script: - - docker run -v "${PWD}"/k8s:/src sparkprime/jsonnet /src/deployment_template.jsonnet --tla-str slug="${CI_COMMIT_REF_SLUG}" -m /src + - docker run -v "${PWD}"/k8s:/src sparkprime/jsonnet /src/deployment_template.jsonnet --tla-str slug="${CI_COMMIT_REF_SLUG}" --tla-str sha="${CI_COMMIT_SHA}" -m /src artifacts: paths: - k8s/deployment.json @@ -63,10 +63,8 @@ build_2019_dev_image: - docker build --build-arg CI_COMMIT_SHA=$CI_COMMIT_SHA -f docker/Dockerfile.dev -t "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_SHA . - docker push "${CONTAINER_IMAGE_2019}":$CI_COMMIT_SHA - docker push "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_SHA - - docker tag "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_SHA "${CONTAINER_IMAGE_2019}"_dev:latest - docker tag "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_SHA "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_REF_SLUG - - docker push "${CONTAINER_IMAGE_2019}"_dev:latest - - docker push "${CONTAINER_IMAGE_2019}"_dev:${CI_COMMIT_REF_SLUG} + - docker push "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_REF_SLUG except: - master diff --git a/k8s/deployment_template.jsonnet b/k8s/deployment_template.jsonnet index d296b6f4..a66ab78a 100644 --- a/k8s/deployment_template.jsonnet +++ b/k8s/deployment_template.jsonnet @@ -1,4 +1,4 @@ -function (slug) { +function (slug, sha) { local app = "symposion-app-" + slug, local namespace = "rego-review", @@ -61,7 +61,8 @@ function (slug) { "template": { "metadata": { "labels": { - "app": "symposion-app" + "app": "symposion-app", + "slug": slug } }, "spec": { @@ -101,7 +102,7 @@ function (slug) { "value": "LAPTOP" }, ], - "image": "asia.gcr.io/linuxconfsydney/symposion_app_2019_dev:" + slug, + "image": "asia.gcr.io/linuxconfsydney/symposion_app_2019_dev:" + sha, "imagePullPolicy": "Always", "livenessProbe": { "failureThreshold": 3,