From 63cb04cd8d853eac434a076748986639f2b0d642 Mon Sep 17 00:00:00 2001 From: matheusbsilva Date: Tue, 11 Jun 2019 16:26:09 -0300 Subject: [PATCH] feat(#9): configure ci/cd pipeline --- .travis.yml | 33 +++++++++++++++++++++++++++++++++ deploy/deploy.sh | 22 ++++++++++++++++++++++ deploy/gcloud-key.json.enc | Bin 0 -> 2336 bytes docker-compose.yml | 2 +- manifest.yml | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 deploy/deploy.sh create mode 100644 deploy/gcloud-key.json.enc create mode 100644 manifest.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..09e11de3 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +sudo: required +services: +- docker +cache: + directories: + - "$HOME/google-cloud-sdk/" +env: + global: + - GOOGLE_APPLICATION_CREDENTIALS=$TRAVIS_BUILD_DIR/deploy/gcloud-key.json + - ORG_NAME=estudeplus + - IMAGE_NAME=interface + - DEPLOYMENT=interface-deploy + - CONTAINER=interface-container + - CLOUDSDK_CORE_DISABLE_PROMPTS=1 + - secure: fT7UXGY7ouBYlQismnu97CRzZt775MuARvSaUn90iHoaK5G65EFLdU4dPz4x6mthCoaPGIT0tTbfLpbV+3YIBbiTqe+Ice0JCL4RditqqCKv867+T4d6HETvz+R/0qLKQ9vGAgziwqh/GynojNRM4p38INEnixBBGYSYgD2rVot397dxF9tgctof5w7b2y0EoJKhyYyyUNAz6KuJjp7LOAJz3StGtycHiTMXsiZk+uaFhnkU+JN8Pzk1fYbeN0s5mhk6CJfTchk6ytAjKt1BQAn65sA92KUq2CTx+rzngnTK7oYXUV2B3YTVDXgbLoSAPD5gPyM3OKF4+uxGEsomrlB50MflXp0dyC1WhlbLdki7I88yY/cGg4BD+Ay/eBfVtWYt1wNOhFkp9sEwuN2EAk28PXv8bk+ATM0qNSXhV2FleN5K1Q50eyRRM94BgavGXFYAwuBI8iS/JNPdSJzf1w+iARNZLv0oZskmVxuLE/T7zj9a+XIXfPKS8j5fInY9RNoZ+194lAoSfDTD8deaUiXfITcj4l7ChaG9KDSVnKm1aVZpCDVFrs7Dh6UpP43jNVKyVqNh5pFoOAR62AkJGSDZhoyj1LCY0JTRkjZJ2gOuhwuOrjNGbdKg/nKHD60n0CgU/8RTOuy7rckUVdjvQRiGX1Ms4zB7BmfXkha0Yfs= +script: +- docker build -t ${ORG_NAME}/${IMAGE_NAME}:$TRAVIS_COMMIT . +before_deploy: +- if [ ! -d "$HOME/google-cloud-sdk/bin" ]; then rm -rf $HOME/google-cloud-sdk; curl + https://sdk.cloud.google.com | bash > /dev/null; fi +- source $HOME/google-cloud-sdk/path.bash.inc +- gcloud --quiet components update kubectl +deploy: +- provider: script + script: chmod +x deploy/deploy.sh && bash deploy/deploy.sh + skip_cleanup: true + on: + branch: feat#9/deploy-cicd +notifications: + email: false +before_install: +- openssl aes-256-cbc -K $encrypted_616071dd0d17_key -iv $encrypted_616071dd0d17_iv + -in $TRAVIS_BUILD_DIR/deploy/gcloud-key.json.enc -out $TRAVIS_BUILD_DIR/deploy/gcloud-key.json -d diff --git a/deploy/deploy.sh b/deploy/deploy.sh new file mode 100644 index 00000000..279e1aed --- /dev/null +++ b/deploy/deploy.sh @@ -0,0 +1,22 @@ + +#!/bin/bash + +echo "Setting up GCLOUD auth" +gcloud auth activate-service-account --key-file ${TRAVIS_BUILD_DIR}/deploy/gcloud-key.json + +gcloud --quiet config set project $PROJECT_ID +gcloud --quiet config set container/cluster $CLUSTER +gcloud --quiet config set compute/zone $ZONE + +echo "Getting cluster credentials" +gcloud --quiet container clusters get-credentials $CLUSTER + +echo "Authenticating on DockerHub" +echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + + +echo "Pushing new image" +docker push ${ORG_NAME}/${IMAGE_NAME}:$TRAVIS_COMMIT + +echo "Setting new image on deployment" +kubectl set image deployment/${DEPLOYMENT} ${CONTAINER}=${ORG_NAME}/${IMAGE_NAME}:$TRAVIS_COMMIT diff --git a/deploy/gcloud-key.json.enc b/deploy/gcloud-key.json.enc new file mode 100644 index 0000000000000000000000000000000000000000..a14983da8c21fa8e5537a33164912bfff0f957f6 GIT binary patch literal 2336 zcmV+*3E%bx9T@un=9BnPg7%SPNcR^+w|yfF_kcs!CR0=lpb?ym(6z$@h?~03B3G?l zNrn#jb&3SltE}l9Jd}@top9_UA-TJvg5bQoB{l|W%0d3ymgGj3HQLA$r%oXP1Dh_8 zl`j_&EB_?XD%t3(dNS3!fP56W$-o*@Z@-6gN0x4NrIThi)gNdw~+;HH(=8sg;tg?(>&UM4(+!`IEKqV zbXA|shLM%8I#L6X?lpJB=_g zxtlUlWEcdlc9@E@;r1ne&~JSQ>D7IPdi>rfcizxQ<|WHG9|AQ}nvtY%z}m>*dcS;{ zzCw}<<7+ZCnA+s?Oqu%QxeW^eQ1az^+_bfoe=xDO`I2r@-xA63_iD)O9evcUr$2=X>?`d&TuAv>5@Xnixw@CO4QJisFmL+CbiVFlLP~v0yh=v-7x!rQytb3H*4FSUt@?+H!-# zzwmvD_2aPf5xa{jg_+v|cNe9Yk^v`e@VeL?75Orz{>AQ?Igt|S>rKU>O3fl~@Sm0$@U83=w|H4h z?}ZgN(UTZOAkwNb|M=)N&@ATZg<{ij9*#cl(_ZD(a4{fDI;_K&-kUDkhuYDWgo}Y) zS$GVjs3WC^5odLfo6XWmoFjmBqzRCPW*W8D3Qf|@{ajWTej`ndhdxdo&B-$>=@|oE zHw?0G&VwKBp1GZHZ(F zE%6EHVSwvup+az>E}K6=-;B!Z$3hC5li*)n+uCtM=(J8!CCfZI%d?u z9}``YaZD{3Q81)e6(!dta^8|BPJ!1CtpoDt+Ojck3 z+cvlCj*FYlys{v6>02rSvWt%foe(}zOv$!R_KTbNG7D0%{k(%PWaZO!#b9m!}D^h0GcHg)%o>Hpu3@>v7P-HdMe_?Dxx? ziym-G>E_q?9w;vM3CUi!)c}lE7HOMNpo)XTv+e+>5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