Skip to content
Snippets Groups Projects
Commit 6721686d authored by Dobromir Palushev's avatar Dobromir Palushev
Browse files

Merge branch 'just-a-test' into 'staging'

updated logic of the test-job

See merge request !38
parents e76c1400 de52158b
No related branches found
No related tags found
14 merge requests!72Production update,!70Production update,!67Workflow updates,!66Css test change,!64Pipeline fix,!62Main update,!60Getting staging's latest state,!58Updating Main,!56Main updates,!52Staging->Main,!50Production updates,!47Deployment on main,!45Deployment from main,!38updated logic of the test-job
Pipeline #19156 failed
...@@ -15,7 +15,7 @@ variables: ...@@ -15,7 +15,7 @@ variables:
CONTAINER_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}-${CI_COMMIT_SHORT_SHA}' CONTAINER_TAG: '${CI_REGISTRY_IMAGE}:${CI_PIPELINE_IID}-${CI_COMMIT_SHORT_SHA}'
stages: stages:
# - test - test
- build - build
- release - release
- deploy - deploy
...@@ -28,26 +28,33 @@ stages: ...@@ -28,26 +28,33 @@ stages:
- gcloud config set compute/zone ${GCP_COMPUTE_REGION} - gcloud config set compute/zone ${GCP_COMPUTE_REGION}
- gcloud container clusters get-credentials ${GCP_PROJECT_ID}-gke - gcloud container clusters get-credentials ${GCP_PROJECT_ID}-gke
# run-tests: run-tests:
# stage: test stage: test
# tags: tags:
# - docker-privileged - docker-privileged
# image: docker:${DOCKER_VERSION} image: docker:${DOCKER_VERSION}
# services: services:
# - name: docker:${DOCKER_VERSION}-dind - name: docker:${DOCKER_VERSION}-dind
# alias: containerhost alias: localhost
# script: script:
# - docker run -p 27017:27017 -d --name mongo-container --rm mongo:${MONGO_VERSION} - docker run -p 27017:27017
# - docker build --detached
# --tag "${CONTAINER_TAG}-test" --name mongo-container
# --target=test --rm
# --build-arg MONGODB_URL_TEST=mongodb://containerhost:27017/todo-app --network=host
# --build-arg JWT_SECRET_TEST=my-very-secret-jwt mongo:${MONGO_VERSION}
# "./app" - docker build
# after_script: --tag "${CONTAINER_TAG}-test"
# - docker stop mongo-container --target=test
# - docker images -a | grep "mongo" | awk '{print $3}' | xargs docker rmi --force --network=host
# - docker image rm --force "${CONTAINER_TAG}-test" --build-arg MONGODB_URL_TEST=mongodb://localhost:27017/todo-app
--build-arg JWT_SECRET_TEST=my-very-secret-jwt
--add-host=host.docker.internal:localhost
"./app"
after_script:
- docker stop mongo-container
- docker images -a | grep "mongo" | awk '{print $3}' | xargs docker rmi --force
- docker image rm --force "${CONTAINER_TAG}-test"
build-image: build-image:
stage: build stage: build
...@@ -120,10 +127,12 @@ deploy-image: ...@@ -120,10 +127,12 @@ deploy-image:
when: 'always' when: 'always'
variables: variables:
ENVIRONMENT_NAME: 'staging' ENVIRONMENT_NAME: 'staging'
STATIC_IP: 'staging-todoapp-ip'
- if: $CI_COMMIT_REF_NAME !~ /main/ - if: $CI_COMMIT_REF_NAME !~ /main/
when: 'always' when: 'always'
variables: variables:
ENVIRONMENT_NAME: 'production' ENVIRONMENT_NAME: 'production'
STATIC_IP: 'todoapp-ip'
tags: tags:
- docker - docker
image: google/cloud-sdk:${GOOGLE_CLOUD_SDK_IMAGE_VERSION} image: google/cloud-sdk:${GOOGLE_CLOUD_SDK_IMAGE_VERSION}
...@@ -137,7 +146,8 @@ deploy-image: ...@@ -137,7 +146,8 @@ deploy-image:
- DEPLOYMENT_MANIFEST=$(sed -e "s,{{image}},${IMAGE},g" ./deployment.yaml.tmpl) - DEPLOYMENT_MANIFEST=$(sed -e "s,{{image}},${IMAGE},g" ./deployment.yaml.tmpl)
- echo "${DEPLOYMENT_MANIFEST}" | kubectl apply --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}" --filename - - echo "${DEPLOYMENT_MANIFEST}" | kubectl apply --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}" --filename -
- kubectl apply -f service.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}" - kubectl apply -f service.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}"
- kubectl apply -f ingress.yaml --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}" - INGRESS_MANIFEST=$(sed -e "s,{{static-ip-name}},${STATIC_IP},g" ./ingress.yaml.tmpl)
- echo "${INGRESS_MANIFEST}" | kubectl apply --namespace "${ENVIRONMENT_NAME}-${K8S_NAMESPACE}" --filename -
...@@ -5,7 +5,7 @@ metadata: ...@@ -5,7 +5,7 @@ metadata:
annotations: annotations:
kubernetes.io/ingress.class: "gce" # an external load-balancer kubernetes.io/ingress.class: "gce" # an external load-balancer
kubernetes.io/ingress.allow-http: "false" # disabling HTTP kubernetes.io/ingress.allow-http: "false" # disabling HTTP
kubernetes.io/ingress.global-static-ip-name: todoapp-ip # staging-todoapp-ip for staging kubernetes.io/ingress.global-static-ip-name: {{static-ip-name}} # staging-todoapp-ip for staging
networking.gke.io/managed-certificates: todoapp-managed-cert # defined in the infrastructure repository networking.gke.io/managed-certificates: todoapp-managed-cert # defined in the infrastructure repository
spec: spec:
# rules: # rules:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment