From a0bf6dc7b5eb6da6101de4974287358a8ff4ef8c Mon Sep 17 00:00:00 2001 From: Raphael Flechtner Date: Thu, 11 Jun 2020 10:47:25 +0200 Subject: [PATCH 1/4] feat: pushing develop images to dockerhub --- .github/workflows/aws-dev.yml | 46 +++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/.github/workflows/aws-dev.yml b/.github/workflows/aws-dev.yml index 419e02be..4ccffae9 100644 --- a/.github/workflows/aws-dev.yml +++ b/.github/workflows/aws-dev.yml @@ -31,6 +31,10 @@ on: name: Deploy to Amazon ECS +env: + ECR_REPOSITORY: kilt/demo-client + ECR_IMAGE_TAG: latest-develop + jobs: deploy: name: Deploy @@ -55,15 +59,13 @@ jobs: id: build-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - ECR_REPOSITORY: kilt/demo-client - IMAGE_TAG: latest-develop run: | # Build a docker container and # push it to ECR so that it can # be deployed to ECS. - docker build -f Dockerfile.devnet -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" + docker build -f Dockerfile.devnet -t $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG" - name: Fill in the new image ID in the Amazon ECS task definition id: task-def @@ -80,3 +82,37 @@ jobs: service: demo-client cluster: kilt-devnet wait-for-service-stability: true + + publish_to_docker: + name: Publish develop image to docker + needs: deploy + runs-on: ubuntu-latest + + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-central-1 + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Login to Docker Hub + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_PASS: ${{ secrets.DOCKER_PASS }} + run: | + echo $DOCKER_PASS | docker login --username=$DOCKER_USER --password-stdin + - name: Tag and push dev image to Docker Hub + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + DOCKER_REPOSITORY: kiltprotocol/demo-client + DOCKER_IMAGE_TAG: develop + run: | + SOURCE_IMAGE=$ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG + docker pull $SOURCE_IMAGE + docker tag $SOURCE_IMAGE $DOCKER_REPOSITORY:$DOCKER_IMAGE_TAG + docker push $DOCKER_REPOSITORY:$DOCKER_IMAGE_TAG From 89307a18e44a9f5c0518149f14fcf058c36f7933 Mon Sep 17 00:00:00 2001 From: Raphael Flechtner Date: Thu, 11 Jun 2020 10:51:42 +0200 Subject: [PATCH 2/4] test: test run --- .github/workflows/aws-dev.yml | 83 ++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/.github/workflows/aws-dev.yml b/.github/workflows/aws-dev.yml index 4ccffae9..c57c4285 100644 --- a/.github/workflows/aws-dev.yml +++ b/.github/workflows/aws-dev.yml @@ -28,6 +28,7 @@ on: push: branches: - develop + - docker-dev name: Deploy to Amazon ECS @@ -36,56 +37,56 @@ env: ECR_IMAGE_TAG: latest-develop jobs: - deploy: - name: Deploy - runs-on: ubuntu-latest + # deploy: + # name: Deploy + # runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v1 + # steps: + # - name: Checkout + # uses: actions/checkout@v1 - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: eu-central-1 + # - name: Configure AWS credentials + # uses: aws-actions/configure-aws-credentials@v1 + # with: + # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + # aws-region: eu-central-1 - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 + # - name: Login to Amazon ECR + # id: login-ecr + # uses: aws-actions/amazon-ecr-login@v1 - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - run: | - # Build a docker container and - # push it to ECR so that it can - # be deployed to ECS. - docker build -f Dockerfile.devnet -t $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG - echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG" + # - name: Build, tag, and push image to Amazon ECR + # id: build-image + # env: + # ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + # run: | + # # Build a docker container and + # # push it to ECR so that it can + # # be deployed to ECS. + # docker build -f Dockerfile.devnet -t $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG . + # docker push $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG + # echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG" - - name: Fill in the new image ID in the Amazon ECS task definition - id: task-def - uses: aws-actions/amazon-ecs-render-task-definition@v1 - with: - task-definition: task-definition.json - container-name: prototype-client - image: ${{ steps.build-image.outputs.image }} + # - name: Fill in the new image ID in the Amazon ECS task definition + # id: task-def + # uses: aws-actions/amazon-ecs-render-task-definition@v1 + # with: + # task-definition: task-definition.json + # container-name: prototype-client + # image: ${{ steps.build-image.outputs.image }} - - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 - with: - task-definition: ${{ steps.task-def.outputs.task-definition }} - service: demo-client - cluster: kilt-devnet - wait-for-service-stability: true + # - name: Deploy Amazon ECS task definition + # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + # with: + # task-definition: ${{ steps.task-def.outputs.task-definition }} + # service: demo-client + # cluster: kilt-devnet + # wait-for-service-stability: true publish_to_docker: name: Publish develop image to docker - needs: deploy + # needs: deploy runs-on: ubuntu-latest steps: From 9a638123f540405baed7ccf94ad50ca71180090a Mon Sep 17 00:00:00 2001 From: Raphael Flechtner Date: Thu, 11 Jun 2020 12:49:21 +0200 Subject: [PATCH 3/4] fix: simplified endpoint config did not work when running demo client images locally --- .env | 6 ++---- .env.devnet | 6 ++---- .env.production | 6 ++---- docker-compose.yml | 10 ++++------ src/services/BlockchainService.ts | 3 +-- src/services/ContactRepository.ts | 2 +- src/services/CtypeRepository.ts | 2 +- src/services/DidService.ts | 2 +- src/services/MessageRepository.tsx | 2 +- 9 files changed, 15 insertions(+), 24 deletions(-) diff --git a/.env b/.env index fa295503..20e998a3 100644 --- a/.env +++ b/.env @@ -1,8 +1,6 @@ -REACT_APP_SERVICE_HOST=//127.0.0.1 -REACT_APP_SERVICE_PORT=3000 +REACT_APP_SERVICE_HOST=//127.0.0.1:3000 -REACT_APP_NODE_HOST=127.0.0.1 -REACT_APP_NODE_WS_PORT=9944 +REACT_APP_NODE_HOST=ws://127.0.0.1:9944 REACT_APP_FAUCET_URL=https://faucet.kilt.io diff --git a/.env.devnet b/.env.devnet index 318cd5aa..ba2df02a 100644 --- a/.env.devnet +++ b/.env.devnet @@ -1,8 +1,6 @@ -REACT_APP_SERVICE_HOST=https://services.devnet.kilt.io -REACT_APP_SERVICE_PORT=443 +REACT_APP_SERVICE_HOST=https://services.devnet.kilt.io:443 -REACT_APP_NODE_HOST=full-nodes-lb.devnet.kilt.io -REACT_APP_NODE_WS_PORT=443 +REACT_APP_NODE_HOST=wss://full-nodes-lb.devnet.kilt.io:443 REACT_APP_FAUCET_URL=https://faucet-devnet.kilt.io diff --git a/.env.production b/.env.production index 8747d47a..1a736e77 100644 --- a/.env.production +++ b/.env.production @@ -1,8 +1,6 @@ -REACT_APP_SERVICE_HOST=https://services.kilt.io -REACT_APP_SERVICE_PORT=443 +REACT_APP_SERVICE_HOST=https://services.kilt.io:443 -REACT_APP_NODE_HOST=full-nodes.kilt.io -REACT_APP_NODE_WS_PORT=443 +REACT_APP_NODE_HOST=wss://full-nodes.kilt.io:443 REACT_APP_FAUCET_URL=https://faucet.kilt.io diff --git a/docker-compose.yml b/docker-compose.yml index d36a82f2..d0c15ca0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,15 +59,13 @@ services: volumes: - ./src:/app/src environment: - - REACT_APP_SERVICE_HOST=//127.0.0.1 - - REACT_APP_SERVICE_PORT=3000 - - REACT_APP_NODE_HOST=127.0.0.1 - - REACT_APP_NODE_WS_PORT=9944 + - REACT_APP_SERVICE_HOST=//127.0.0.1:3000 + - REACT_APP_NODE_HOST=ws://127.0.0.1:9944 - REACT_APP_FAUCET_URL=http://127.0.0.1:3002 - PUBLIC_URL=. - # if you experience issues where the watcher does not trigger rebuilds + # if you experience issues where the watcher does not trigger rebuilds # when changing files in src/ the following option may help - #- CHOKIDAR_USEPOLLING=true + #- CHOKIDAR_USEPOLLING=true ports: - 3001:3001 diff --git a/src/services/BlockchainService.ts b/src/services/BlockchainService.ts index dc35b048..a54ac325 100644 --- a/src/services/BlockchainService.ts +++ b/src/services/BlockchainService.ts @@ -10,8 +10,7 @@ class BlockchainService { } public static getNodeWebsocketUrl(): string { - const protocol = window.location.protocol === 'https:' ? 'wss' : 'ws' - return `${protocol}://${process.env.REACT_APP_NODE_HOST}:${process.env.REACT_APP_NODE_WS_PORT}` + return `${process.env.REACT_APP_NODE_HOST}` } } diff --git a/src/services/ContactRepository.ts b/src/services/ContactRepository.ts index 11ca0557..362533cf 100644 --- a/src/services/ContactRepository.ts +++ b/src/services/ContactRepository.ts @@ -12,7 +12,7 @@ import { notifyFailure } from './FeedbackService' // (for other tests) class ContactRepository { - public static readonly URL = `${process.env.REACT_APP_SERVICE_HOST}:${process.env.REACT_APP_SERVICE_PORT}/contacts` + public static readonly URL = `${process.env.REACT_APP_SERVICE_HOST}/contacts` public static async findAll(): Promise { return fetch(`${ContactRepository.URL}`) diff --git a/src/services/CtypeRepository.ts b/src/services/CtypeRepository.ts index fb1df238..8e1dbbe3 100644 --- a/src/services/CtypeRepository.ts +++ b/src/services/CtypeRepository.ts @@ -52,7 +52,7 @@ class CTypeRepository { }) } - private static readonly URL = `${process.env.REACT_APP_SERVICE_HOST}:${process.env.REACT_APP_SERVICE_PORT}/ctype` + private static readonly URL = `${process.env.REACT_APP_SERVICE_HOST}/ctype` } export default CTypeRepository diff --git a/src/services/DidService.ts b/src/services/DidService.ts index 086ec465..9a2bbed6 100644 --- a/src/services/DidService.ts +++ b/src/services/DidService.ts @@ -6,7 +6,7 @@ import ContactRepository from './ContactRepository' import MessageRepository from './MessageRepository' class DidService { - public static readonly URL = `${process.env.REACT_APP_SERVICE_HOST}:${process.env.REACT_APP_SERVICE_PORT}/contacts/did` + public static readonly URL = `${process.env.REACT_APP_SERVICE_HOST}/contacts/did` public static async resolveDid( identifier: string diff --git a/src/services/MessageRepository.tsx b/src/services/MessageRepository.tsx index a4814ffa..1c54a911 100644 --- a/src/services/MessageRepository.tsx +++ b/src/services/MessageRepository.tsx @@ -28,7 +28,7 @@ export interface IMessageOutput extends sdk.IMessage { // (for other tests) class MessageRepository { - public static readonly URL = `${process.env.REACT_APP_SERVICE_HOST}:${process.env.REACT_APP_SERVICE_PORT}/messaging` + public static readonly URL = `${process.env.REACT_APP_SERVICE_HOST}/messaging` /** * takes contact or list of contacts From 9b12781fdba9d37f125b01b8ba74501ae40a99b7 Mon Sep 17 00:00:00 2001 From: Raphael Flechtner Date: Thu, 11 Jun 2020 13:21:14 +0200 Subject: [PATCH 4/4] Revert "test: test run" This reverts commit 89307a18e44a9f5c0518149f14fcf058c36f7933. --- .github/workflows/aws-dev.yml | 83 +++++++++++++++++------------------ 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/.github/workflows/aws-dev.yml b/.github/workflows/aws-dev.yml index c57c4285..4ccffae9 100644 --- a/.github/workflows/aws-dev.yml +++ b/.github/workflows/aws-dev.yml @@ -28,7 +28,6 @@ on: push: branches: - develop - - docker-dev name: Deploy to Amazon ECS @@ -37,56 +36,56 @@ env: ECR_IMAGE_TAG: latest-develop jobs: - # deploy: - # name: Deploy - # runs-on: ubuntu-latest + deploy: + name: Deploy + runs-on: ubuntu-latest - # steps: - # - name: Checkout - # uses: actions/checkout@v1 + steps: + - name: Checkout + uses: actions/checkout@v1 - # - name: Configure AWS credentials - # uses: aws-actions/configure-aws-credentials@v1 - # with: - # aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - # aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - # aws-region: eu-central-1 + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: eu-central-1 - # - name: Login to Amazon ECR - # id: login-ecr - # uses: aws-actions/amazon-ecr-login@v1 + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 - # - name: Build, tag, and push image to Amazon ECR - # id: build-image - # env: - # ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - # run: | - # # Build a docker container and - # # push it to ECR so that it can - # # be deployed to ECS. - # docker build -f Dockerfile.devnet -t $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG . - # docker push $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG - # echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG" + - name: Build, tag, and push image to Amazon ECR + id: build-image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + run: | + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -f Dockerfile.devnet -t $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG . + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$ECR_IMAGE_TAG" - # - name: Fill in the new image ID in the Amazon ECS task definition - # id: task-def - # uses: aws-actions/amazon-ecs-render-task-definition@v1 - # with: - # task-definition: task-definition.json - # container-name: prototype-client - # image: ${{ steps.build-image.outputs.image }} + - name: Fill in the new image ID in the Amazon ECS task definition + id: task-def + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: prototype-client + image: ${{ steps.build-image.outputs.image }} - # - name: Deploy Amazon ECS task definition - # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 - # with: - # task-definition: ${{ steps.task-def.outputs.task-definition }} - # service: demo-client - # cluster: kilt-devnet - # wait-for-service-stability: true + - name: Deploy Amazon ECS task definition + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.task-def.outputs.task-definition }} + service: demo-client + cluster: kilt-devnet + wait-for-service-stability: true publish_to_docker: name: Publish develop image to docker - # needs: deploy + needs: deploy runs-on: ubuntu-latest steps: