From db4a38907313ee4f3481db94fcc7d3810ed6ac28 Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 17:17:02 +0100 Subject: [PATCH 01/16] Upgrade to circleci v2 --- .circleci/config.yml | 58 ++++++++++++++++++++++++++++++++++++++++++++ circle.yml | 32 ------------------------ 2 files changed, 58 insertions(+), 32 deletions(-) create mode 100644 .circleci/config.yml delete mode 100644 circle.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..78776d9 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,58 @@ +version: 2 +defaults: + container_name: &container_name specs + image: &image circleci/node:6 + node_modules_cache_key: &node_modules_cache_key v1-{{ checksum "package-lock.json" }} + restore_node_modules: &restore_node_modules + restore_cache: + keys: + - *node_modules_cache_key +jobs: + build: + docker: + - image: *image + steps: + - checkout + - run: make node_modules + - save_cache: + key: *node_modules_cache_key + paths: + - node_modules + test: + docker: + - image: *image + steps: + - checkout + - *restore_node_modules + - run: echo todo + deploy: + docker: + - image: *image + environment: + CONTAINER_NAME: *container_name + steps: + - checkout + - *restore_node_modules + - setup_remote_docker + - run: pip install awscli + - run: eval $(aws ecr get-login --region us-east-1 --no-include-email) + - run: docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS + - run: docker build -t segment/$CONTAINER_NAME . + - run: docker push segment/$CONTAINER_NAME:latest + - run: docker tag segment/$CONTAINER_NAME:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest + - run: docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest +workflows: + version: 2 + build_test_deploy: + jobs: + - build + - test: + requires: + - build + - deploy: + requires: + - test + filters: + branches: + only: + - circleci \ No newline at end of file diff --git a/circle.yml b/circle.yml deleted file mode 100644 index 007118e..0000000 --- a/circle.yml +++ /dev/null @@ -1,32 +0,0 @@ - -machine: - node: - version: 6 - services: - - docker - -dependencies: - cache_directories: - - node_modules - override: - - make node_modules - -test: - override: - - echo todo - -deployment: - # deploy to dockerhub - dockerhub: - branch: master - commands: - # Authenticate to ECR - - pip install awscli - - $(aws ecr get-login --region $AWS_REGION) - - - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - - docker build -t segment/specs . - - docker push segment/specs:latest - - - docker tag segment/specs:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/specs:latest - - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/specs:latest From 71fe98e25fabc471faece45e95c1eaac8a94fcfc Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 17:18:56 +0100 Subject: [PATCH 02/16] Trigger build on circleci --- .circleci/config.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 78776d9..872f635 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,5 @@ version: 2 defaults: - container_name: &container_name specs image: &image circleci/node:6 node_modules_cache_key: &node_modules_cache_key v1-{{ checksum "package-lock.json" }} restore_node_modules: &restore_node_modules @@ -29,7 +28,7 @@ jobs: docker: - image: *image environment: - CONTAINER_NAME: *container_name + CONTAINER_NAME: specs steps: - checkout - *restore_node_modules From 2feef8130f2a9f9bf06a2b9d0417606014c7786d Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 17:20:52 +0100 Subject: [PATCH 03/16] change branch name --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 872f635..93dc3db 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,4 +54,4 @@ workflows: filters: branches: only: - - circleci \ No newline at end of file + - circleciv2 \ No newline at end of file From 83d0b77a5a9dccf7ef1db7b7a2edcd35ebec7b4a Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 17:27:06 +0100 Subject: [PATCH 04/16] Change image to python --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 93dc3db..82da1f8 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,7 +26,7 @@ jobs: - run: echo todo deploy: docker: - - image: *image + - image: circleci/python environment: CONTAINER_NAME: specs steps: From 81bd6217ed997f0929ecf331907737a3e11fe59b Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 17:30:45 +0100 Subject: [PATCH 05/16] Change image to python --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 82da1f8..ca6c0ad 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,7 +33,7 @@ jobs: - checkout - *restore_node_modules - setup_remote_docker - - run: pip install awscli + - run: pip install awscli --user - run: eval $(aws ecr get-login --region us-east-1 --no-include-email) - run: docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - run: docker build -t segment/$CONTAINER_NAME . From f1e62375788cbe90182dd69614ab63008933c683 Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 17:38:50 +0100 Subject: [PATCH 06/16] Cleanup --- .circleci/config.yml | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ca6c0ad..df9545d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -33,13 +33,27 @@ jobs: - checkout - *restore_node_modules - setup_remote_docker - - run: pip install awscli --user - - run: eval $(aws ecr get-login --region us-east-1 --no-include-email) - - run: docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS - - run: docker build -t segment/$CONTAINER_NAME . - - run: docker push segment/$CONTAINER_NAME:latest - - run: docker tag segment/$CONTAINER_NAME:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest - - run: docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest + - run: + name: Install AWS-CLI + command: pip install awscli --user + - run: + name: Login on ECR + command: eval $(aws ecr get-login --region us-east-1 --no-include-email) + - run: + name: Login on Docker Hub + command: docker login -u ${DOCKER_USER} -p ${DOCKER_PASS} + - run: + name: Build Image + command: docker build -t segment/$CONTAINER_NAME . + - run: + name: Push the image on Docker Hub + command: docker push segment/$CONTAINER_NAME:latest + - run: + name: Tag the image for ECR + command: docker tag segment/$CONTAINER_NAME:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest + - run: + name: Push the image on ECR + command: docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest workflows: version: 2 build_test_deploy: @@ -54,4 +68,4 @@ workflows: filters: branches: only: - - circleciv2 \ No newline at end of file + - master \ No newline at end of file From 9dbc7c65766560169d1d33f172cd2b594d4f1fed Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 17:42:29 +0100 Subject: [PATCH 07/16] last test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index df9545d..7eacb66 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,4 +68,4 @@ workflows: filters: branches: only: - - master \ No newline at end of file + - circleciv2 \ No newline at end of file From 163fbb7ea12f2b872844547527e7ec4c7ffdbb94 Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 17:42:43 +0100 Subject: [PATCH 08/16] remove last test --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7eacb66..df9545d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,4 +68,4 @@ workflows: filters: branches: only: - - circleciv2 \ No newline at end of file + - master \ No newline at end of file From a6ab74dfc8df901f18501d8462a6f71b1fda76a0 Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 22:13:37 +0100 Subject: [PATCH 09/16] Install awscli properly (hopefully) --- .circleci/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index df9545d..6e03402 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,7 +26,7 @@ jobs: - run: echo todo deploy: docker: - - image: circleci/python + - image: alpine environment: CONTAINER_NAME: specs steps: @@ -35,7 +35,7 @@ jobs: - setup_remote_docker - run: name: Install AWS-CLI - command: pip install awscli --user + command: apk -Uuv add groff less python py-pip && pip install awscli - run: name: Login on ECR command: eval $(aws ecr get-login --region us-east-1 --no-include-email) @@ -68,4 +68,4 @@ workflows: filters: branches: only: - - master \ No newline at end of file + - circleciv2 \ No newline at end of file From c8e2da2ec2feae52cf4bc68b997309ec17689559 Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 22:19:38 +0100 Subject: [PATCH 10/16] Install docker --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6e03402..d0f8d0a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -34,8 +34,8 @@ jobs: - *restore_node_modules - setup_remote_docker - run: - name: Install AWS-CLI - command: apk -Uuv add groff less python py-pip && pip install awscli + name: Install Docker & AWS-CLI + command: apk -Uuv add groff less python py-pip docker && pip install awscli - run: name: Login on ECR command: eval $(aws ecr get-login --region us-east-1 --no-include-email) From d63f9ff93b9ef5a6cf25f4228aec1c91c5909c9b Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Thu, 14 Mar 2019 22:25:22 +0100 Subject: [PATCH 11/16] Revert branch name --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d0f8d0a..ce4141e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -68,4 +68,4 @@ workflows: filters: branches: only: - - circleciv2 \ No newline at end of file + - master \ No newline at end of file From 0443516fa64d83dce8f1aed4000040b6c81df9ce Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Fri, 15 Mar 2019 10:45:25 +0100 Subject: [PATCH 12/16] Give circleci orbs a shot --- .circleci/config.yml | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ce4141e..77ba40f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,5 @@ -version: 2 +version: 2.1 + defaults: image: &image circleci/node:6 node_modules_cache_key: &node_modules_cache_key v1-{{ checksum "package-lock.json" }} @@ -6,6 +7,11 @@ defaults: restore_cache: keys: - *node_modules_cache_key + +orbs: + aws-cli: circleci/aws-cli@0.1.1 + aws-ecr: circleci/aws-ecr@3.0.0 + jobs: build: docker: @@ -26,34 +32,24 @@ jobs: - run: echo todo deploy: docker: - - image: alpine + - image: circleci/python environment: CONTAINER_NAME: specs + ECR_URL: $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com steps: - checkout - *restore_node_modules - setup_remote_docker + - aws-cli/install + - aws-cli/configure + - aws-ecr/ecr-login - run: - name: Install Docker & AWS-CLI - command: apk -Uuv add groff less python py-pip docker && pip install awscli - - run: - name: Login on ECR - command: eval $(aws ecr get-login --region us-east-1 --no-include-email) - - run: - name: Login on Docker Hub - command: docker login -u ${DOCKER_USER} -p ${DOCKER_PASS} - - run: - name: Build Image - command: docker build -t segment/$CONTAINER_NAME . - - run: - name: Push the image on Docker Hub - command: docker push segment/$CONTAINER_NAME:latest - - run: - name: Tag the image for ECR - command: docker tag segment/$CONTAINER_NAME:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest - - run: - name: Push the image on ECR - command: docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest + name: build, push on docker hub and ECR + command: | + echo ${DOCKER_PASS} | docker login -u ${DOCKER_USER} --password-stdin + docker build -t segment/${CONTAINER_NAME}:${CIRCLE_BUILD_NUM} -t segment/${CONTAINER_NAME}:latest -t ${ECR_URL}/${CONTAINER_NAME}:latest . + docker push segment/${CONTAINER_NAME}:latest + docker push ${ECR_URL}/${CONTAINER_NAME}:latest workflows: version: 2 build_test_deploy: @@ -68,4 +64,4 @@ workflows: filters: branches: only: - - master \ No newline at end of file + - cirleciv2 \ No newline at end of file From b22b836ade3924d00f729fba47f88fb71bf12d07 Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Fri, 15 Mar 2019 10:47:29 +0100 Subject: [PATCH 13/16] Wrong branch name --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 77ba40f..68afa27 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,4 +64,4 @@ workflows: filters: branches: only: - - cirleciv2 \ No newline at end of file + - circleciv2 \ No newline at end of file From abe2a85a2d4ea1f9f9707473fa257142054f9472 Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Fri, 15 Mar 2019 11:15:41 +0100 Subject: [PATCH 14/16] Debug env variable --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 68afa27..8d51f34 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -42,6 +42,7 @@ jobs: - setup_remote_docker - aws-cli/install - aws-cli/configure + - run: echo $ECR_URL - aws-ecr/ecr-login - run: name: build, push on docker hub and ECR From cae4539698c6d25eb92d98c11ac7d3a1268826ef Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Fri, 15 Mar 2019 11:15:52 +0100 Subject: [PATCH 15/16] Debug env variable --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8d51f34..7748945 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -41,8 +41,8 @@ jobs: - *restore_node_modules - setup_remote_docker - aws-cli/install - - aws-cli/configure - run: echo $ECR_URL + - aws-cli/configure - aws-ecr/ecr-login - run: name: build, push on docker hub and ECR From 5a867679057d1fd9d686a0d15906455ba7ea788e Mon Sep 17 00:00:00 2001 From: Nicolas Ritouet Date: Fri, 15 Mar 2019 11:24:38 +0100 Subject: [PATCH 16/16] Rollback orbs --- .circleci/config.yml | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7748945..c7dea32 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,11 +7,6 @@ defaults: restore_cache: keys: - *node_modules_cache_key - -orbs: - aws-cli: circleci/aws-cli@0.1.1 - aws-ecr: circleci/aws-ecr@3.0.0 - jobs: build: docker: @@ -32,25 +27,34 @@ jobs: - run: echo todo deploy: docker: - - image: circleci/python + - image: alpine environment: CONTAINER_NAME: specs - ECR_URL: $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com steps: - checkout - *restore_node_modules - setup_remote_docker - - aws-cli/install - - run: echo $ECR_URL - - aws-cli/configure - - aws-ecr/ecr-login - run: - name: build, push on docker hub and ECR - command: | - echo ${DOCKER_PASS} | docker login -u ${DOCKER_USER} --password-stdin - docker build -t segment/${CONTAINER_NAME}:${CIRCLE_BUILD_NUM} -t segment/${CONTAINER_NAME}:latest -t ${ECR_URL}/${CONTAINER_NAME}:latest . - docker push segment/${CONTAINER_NAME}:latest - docker push ${ECR_URL}/${CONTAINER_NAME}:latest + name: Install Docker & AWS-CLI + command: apk -Uuv add groff less python py-pip docker && pip install awscli + - run: + name: Login on ECR + command: eval $(aws ecr get-login --region us-east-1 --no-include-email) + - run: + name: Login on Docker Hub + command: docker login -u ${DOCKER_USER} -p ${DOCKER_PASS} + - run: + name: Build Image + command: docker build -t segment/$CONTAINER_NAME . + - run: + name: Push the image on Docker Hub + command: docker push segment/$CONTAINER_NAME:latest + - run: + name: Tag the image for ECR + command: docker tag segment/$CONTAINER_NAME:latest $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest + - run: + name: Push the image on ECR + command: docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$CONTAINER_NAME:latest workflows: version: 2 build_test_deploy: @@ -65,4 +69,4 @@ workflows: filters: branches: only: - - circleciv2 \ No newline at end of file + - master \ No newline at end of file