Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1551 from afshinpaydar-binary/Add_Blue_Green
Browse files Browse the repository at this point in the history
Remove old release and use Blue/Green as default
  • Loading branch information
mustofa-binary authored Jun 24, 2021
2 parents 37adaf4 + 44d97fe commit 6e137bc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 40 deletions.
58 changes: 21 additions & 37 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,18 @@ commands:
docker_build_push:
description: "Build and Push image to docker hub"
parameters:
docker_tag:
docker_image_latest_tag:
type: string
default: "beta-${CIRCLE_SHA1}"
docker_latest_tag:
default: "latest-staging"
docker_image_tag:
type: string
default: "beta-latest"
nginx_location:
type: string
default: "/usr/share/nginx/html/beta"
default: ${CIRCLE_SHA1}
steps:
- setup_remote_docker
- run:
name: Building docker image
command: |
docker build --build-arg NGINX_LOCATION=<< parameters.nginx_location >> -t ${DOCKHUB_ORGANISATION}/binary-static-webtrader:<< parameters.docker_tag >> -t ${DOCKHUB_ORGANISATION}/binary-static-webtrader:<< parameters.docker_latest_tag >> .
docker build -t ${DOCKHUB_ORGANISATION}/binary-static-webtrader:<< parameters.docker_image_tag >> -t ${DOCKHUB_ORGANISATION}/binary-static-webtrader:<< parameters.docker_image_latest_tag >> .
- run:
name: Pushing Image to docker hub
command: |
Expand All @@ -103,35 +100,22 @@ commands:
k8s_deploy:
description: "Deploy to k8s cluster"
parameters:
k8s_svc_name:
type: string
default: "webtrader-beta-binary-com"
docker_tag:
k8s_version:
type: string
default: "beta-${CIRCLE_SHA1}"
k8s-deployment:
default: ${CIRCLE_SHA1}
k8s_namespace:
type: string
default: "webtrader-beta-binary-com"
default: "webtrader-binary-com-staging"
steps:
- k8s/install-kubectl
- run:
name: Deploying to k8s cluster for service << parameters.k8s_svc_name >>
name: Deploying to k8s cluster for service << parameters.k8s_namespace >>
command: |
for SERVER_ID in {1..5}
do
KUBE_SERVER_REF="KUBE_SERVER_$SERVER_ID"
SERVICEACCOUNT_TOKEN_REF="SERVICEACCOUNT_TOKEN_$SERVER_ID"
CA_CRT_REF="CA_CRT_$SERVER_ID"
if [ ! -z "${!KUBE_SERVER_REF}" ]
then
echo "Deploying to cluster $SERVER_ID"
CA_CRT="${!CA_CRT_REF}"
KUBE_SERVER="${!KUBE_SERVER_REF}"
SERVICEACCOUNT_TOKEN="${!SERVICEACCOUNT_TOKEN_REF}"
echo $CA_CRT | base64 --decode > ca.crt
kubectl --server=${KUBE_SERVER} --certificate-authority=ca.crt --token=$SERVICEACCOUNT_TOKEN set image deployment/<< parameters.k8s-deployment >> << parameters.k8s-deployment >>=${DOCKHUB_ORGANISATION}/binary-static-webtrader:<< parameters.docker_tag >>
fi
done
export NAMESPACE=<< parameters.k8s_namespace >>
git clone https://github.com/binary-com/devops-ci-scripts
cd devops-ci-scripts/k8s-build_tools
echo $CA_CRT | base64 --decode > ca.crt
./release.sh binary-static-webtrader << parameters.k8s_version >>
notify_slack:
description: "Notify slack"
steps:
Expand All @@ -157,6 +141,8 @@ jobs:
- build
- deploy:
target_branch: "staging"
- docker_build_push
- k8s_deploy
- notify_slack
release_production:
docker:
Expand All @@ -176,13 +162,11 @@ jobs:
- npm_install
- build
- docker_build_push:
docker_latest_tag: "latest"
docker_tag: "${CIRCLE_SHA1}"
nginx_location: "/usr/share/nginx/html"
docker_image_latest_tag: "latest"
docker_image_tag: ${CIRCLE_TAG}
- k8s_deploy:
k8s_svc_name: "webtrader-binary-com"
docker_tag: "${CIRCLE_SHA1}"
k8s-deployment: "webtrader-binary-com"
k8s_namespace: "webtrader-binary-com-production"
k8s_version: ${CIRCLE_TAG}

workflows:
build:
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ARG NGINX_LOCATION=/usr/share/nginx/html/beta
FROM nginx:alpine
ARG NGINX_LOCATION
COPY ./dist/compressed $NGINX_LOCATION
COPY ./dist/compressed /usr/share/nginx/html
COPY ./default.conf /etc/nginx/conf.d/default.conf
RUN chown -R nginx:nginx /usr/share/nginx/html

0 comments on commit 6e137bc

Please sign in to comment.