Created
November 6, 2018 07:26
-
-
Save Thakurvaibhav/5a676f7138b20b4d8ecef5fc588a62eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#All the environment variables are defined under Settings > CI/CD > Secret Variables section | |
image: docker:latest | |
variables: | |
DOCKER_DRIVER: overlay2 | |
services: | |
- docker:dind | |
stages: | |
- build_dev | |
- build_prod | |
- deploy_dev | |
- deploy_prod | |
before_script: | |
- docker login $REGISTRY -u $REGISTRY_USER -p $REGISTRY_USER_PASSWORD | |
build_dev: | |
stage: build_dev | |
only: | |
- /^dev-.*$/ | |
except: | |
- branches | |
script: | |
- docker build --no-cache -t "$REGISTRY/$REPO_DEV:$CI_BUILD_REF_NAME" . | |
- docker push $REGISTRY/$REPO_DEV:$CI_BUILD_REF_NAME | |
build_prod: | |
stage: build_prod | |
only: | |
- /^prod-.*$/ | |
except: | |
- branches | |
script: | |
- docker build --no-cache -t "$REGISTRY/$REPO_DEV:$CI_BUILD_REF_NAME" . | |
- docker push $REGISTRY/$REPO_DEV:$CI_BUILD_REF_NAME | |
deploy_dev: | |
stage: deploy_dev | |
script: | |
# Install python requirements | |
- apk update | |
- apk upgrade | |
- apk add util-linux pciutils usbutils coreutils binutils findutils grep | |
- apk add python python-dev py-pip | |
# AWS configs | |
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY | |
- export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KEY | |
# Install awscli | |
- pip install awscli | |
# Configure deploy.json | |
- cd deployment | |
- sed -i -e "s/N_ENV/$NODE_ENV_DEVELOPMENT/g" deploy.json | |
- sed -i -e "s/REPO/$REPO_DEV/g" deploy.json | |
- sed -i -e "s/TAG/$CI_BUILD_REF_NAME/g" deploy.json | |
# Update task and service | |
- aws ecs register-task-definition --region <your-ecs-region> --cli-input-json file://deploy.json >> temp.json | |
- REV=`grep '"revision"' temp.json | awk '{print $2}'` | |
- echo $REV | |
- aws ecs update-service --cluster <ecs-cluster-name> --service <ecs-service-name> --task-definition <your-ecs-task-name>:${REV} --region <your-ecs-region> | |
when: manual | |
deploy_prod: | |
stage: deploy_prod | |
script: | |
# Install python requirements | |
- apk update | |
- apk upgrade | |
- apk add util-linux pciutils usbutils coreutils binutils findutils grep | |
- apk add python python-dev py-pip | |
# AWS configs | |
- export AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY | |
- export AWS_SECRET_ACCESS_KEY=$AWS_SECRET_KEY | |
# Install awscli | |
- pip install awscli | |
# Configure deploy.json | |
- cd deployment | |
- sed -i -e "s/N_ENV/$NODE_ENV_PRODUCTION/g" deploy.json | |
- sed -i -e "s/REPO/$REPO_PROD/g" deploy.json | |
- sed -i -e "s/TAG/$CI_BUILD_REF_NAME/g" deploy.json | |
# Update task and service | |
- aws ecs register-task-definition --region <your-ecs-region> --cli-input-json file://deploy.json >> temp.json | |
- REV=`grep '"revision"' temp.json | awk '{print $2}'` | |
- echo $REV | |
- aws ecs update-service --cluster <ecs-cluster-name> --service <ecs-service-name> --task-definition <your-ecs-task-name>:${REV} --region <your-ecs-region> | |
when: manual |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Vibhav it is possible to make .gitlab-ci.yml pipeline for azure with docker containerization , actually i am struggling with this .
thanks and regards,
siva
[email protected]