From 3a215ff79a7e3fa771ba76ff1bbd3208a29b07b5 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Nov 2023 14:45:33 +0530 Subject: [PATCH 1/8] Debug --- .github/workflows/pipeline.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 07f661d..8383743 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -50,7 +50,7 @@ jobs: run: shell: bash needs: [docker_build_push] - if: github.ref_name == 'main' + if: github.ref_name == 'main' || github.ref_name == 'fix-backend-deploy' container: image: python:3.7-stretch env: @@ -63,7 +63,6 @@ jobs: - run: chown -R $(id -u):$(id -g) $PWD - run: echo "TAG=latest" >> $GITHUB_ENV # - run: if [[ $GITHUB_REF_NAME == "main" ]]; then printenv PROD_CONFIG > "$(pwd)/.env" ; else printenv STAGING_CONFIG > "$(pwd)/.env" ; fi; - - run: sed 's/\"//g' .env >> $GITHUB_ENV - run: echo "PATH=$PATH:/github/home/.local/bin" >> $GITHUB_ENV - run: 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )' - run: eval $(ssh-agent -s) From 885c55a7adf6d03a42897ce517658d51cc95277a Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Nov 2023 14:49:00 +0530 Subject: [PATCH 2/8] Fix domain var name issue --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 8383743..aaa6bf2 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -68,7 +68,7 @@ jobs: - run: eval $(ssh-agent -s) - run: mkdir -p ~/.ssh - run: chmod 700 ~/.ssh - - run: ssh-keyscan "$DOMAIN" >> ~/.ssh/known_hosts + - run: ssh-keyscan "$BACKEND_DOMAIN" >> ~/.ssh/known_hosts - run: chmod 644 ~/.ssh/known_hosts - run: echo "$SSH_KEY" | base64 --decode > key.pem - run: chmod 600 key.pem From 0e7c00d783b1db61bfbc6c2dfa47ea3c11fc89c7 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Nov 2023 14:57:12 +0530 Subject: [PATCH 3/8] Fix key bug --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index aaa6bf2..838fbd9 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -56,7 +56,7 @@ jobs: env: GITHUB_USERNAME: ${{ github.actor }} GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - PROD_SSH_KEY: ${{ secrets.PROD_SSH_KEY }} + SSH_KEY: ${{ secrets.SSH_KEY }} steps: - uses: actions/checkout@v3 # This is to fix GIT not liking owner of the checkout dir - https://github.com/actions/runner/issues/2033#issuecomment-1204205989 From d3d01656e384a0f79396773142e6fc7b23e360b1 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Nov 2023 15:04:09 +0530 Subject: [PATCH 4/8] Update docker run command --- scripts/deploy_backend.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy_backend.sh b/scripts/deploy_backend.sh index cbd9bb7..bfd31d8 100755 --- a/scripts/deploy_backend.sh +++ b/scripts/deploy_backend.sh @@ -69,4 +69,4 @@ echo "Deleting old image" ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker system prune -f || echo 'No images to delete'" echo "INFO: starting docker container" -ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker run --rm --name wasp-backend -e PORT -e DATABASE_URL -e WASP_WEB_CLIENT_URL -e JWT_SECRET ghcr.io/$GITHUB_REPOSITORY:$TAG -d" +ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker run --name wasp-backend -e PORT=$PORT -e DATABASE_URL=$DATABASE_URL -e WASP_WEB_CLIENT_URL=$WASP_WEB_CLIENT_URL -e JWT_SECRET=$JWT_SECRET ghcr.io/$GITHUB_REPOSITORY:$TAG -d" From d1e7d911a2176be8e5e943c2326f8b0c89794382 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Nov 2023 15:09:04 +0530 Subject: [PATCH 5/8] Try with single quotes --- scripts/deploy_backend.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy_backend.sh b/scripts/deploy_backend.sh index bfd31d8..7c4244c 100755 --- a/scripts/deploy_backend.sh +++ b/scripts/deploy_backend.sh @@ -69,4 +69,4 @@ echo "Deleting old image" ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker system prune -f || echo 'No images to delete'" echo "INFO: starting docker container" -ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker run --name wasp-backend -e PORT=$PORT -e DATABASE_URL=$DATABASE_URL -e WASP_WEB_CLIENT_URL=$WASP_WEB_CLIENT_URL -e JWT_SECRET=$JWT_SECRET ghcr.io/$GITHUB_REPOSITORY:$TAG -d" +ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker run --name wasp-backend -e PORT='$PORT' -e DATABASE_URL='$DATABASE_URL' -e WASP_WEB_CLIENT_URL='$WASP_WEB_CLIENT_URL' -e JWT_SECRET='$JWT_SECRET' ghcr.io/$GITHUB_REPOSITORY:$TAG -d" From 5108d6e9006741b268457efaa6423b2be4f17d83 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Nov 2023 16:18:09 +0530 Subject: [PATCH 6/8] Add google client id and secret --- .github/workflows/pipeline.yml | 2 ++ scripts/deploy_backend.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 838fbd9..785e9f5 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -56,7 +56,9 @@ jobs: env: GITHUB_USERNAME: ${{ github.actor }} GITHUB_PASSWORD: ${{ secrets.GITHUB_TOKEN }} + GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} SSH_KEY: ${{ secrets.SSH_KEY }} + GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} steps: - uses: actions/checkout@v3 # This is to fix GIT not liking owner of the checkout dir - https://github.com/actions/runner/issues/2033#issuecomment-1204205989 diff --git a/scripts/deploy_backend.sh b/scripts/deploy_backend.sh index 7c4244c..86c4d99 100755 --- a/scripts/deploy_backend.sh +++ b/scripts/deploy_backend.sh @@ -69,4 +69,4 @@ echo "Deleting old image" ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker system prune -f || echo 'No images to delete'" echo "INFO: starting docker container" -ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker run --name wasp-backend -e PORT='$PORT' -e DATABASE_URL='$DATABASE_URL' -e WASP_WEB_CLIENT_URL='$WASP_WEB_CLIENT_URL' -e JWT_SECRET='$JWT_SECRET' ghcr.io/$GITHUB_REPOSITORY:$TAG -d" +ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker run --name wasp-backend -e PORT='$PORT' -e DATABASE_URL='$DATABASE_URL' -e WASP_WEB_CLIENT_URL='$WASP_WEB_CLIENT_URL' -e JWT_SECRET='$JWT_SECRET' -e GOOGLE_CLIENT_ID='$GOOGLE_CLIENT_ID' -e GOOGLE_CLIENT_SECRET='$GOOGLE_CLIENT_SECRET' ghcr.io/$GITHUB_REPOSITORY:$TAG -d" From 48a7e4343550423e2dc7076547751423e40cc880 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Nov 2023 16:53:51 +0530 Subject: [PATCH 7/8] Run in detached mode and export port --- scripts/deploy_backend.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/deploy_backend.sh b/scripts/deploy_backend.sh index 86c4d99..caef000 100755 --- a/scripts/deploy_backend.sh +++ b/scripts/deploy_backend.sh @@ -69,4 +69,4 @@ echo "Deleting old image" ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker system prune -f || echo 'No images to delete'" echo "INFO: starting docker container" -ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker run --name wasp-backend -e PORT='$PORT' -e DATABASE_URL='$DATABASE_URL' -e WASP_WEB_CLIENT_URL='$WASP_WEB_CLIENT_URL' -e JWT_SECRET='$JWT_SECRET' -e GOOGLE_CLIENT_ID='$GOOGLE_CLIENT_ID' -e GOOGLE_CLIENT_SECRET='$GOOGLE_CLIENT_SECRET' ghcr.io/$GITHUB_REPOSITORY:$TAG -d" +ssh -o StrictHostKeyChecking=no -i key.pem azureuser@"$BACKEND_DOMAIN" "docker run --name wasp-backend -p 80:80 -e PORT='$PORT' -e DATABASE_URL='$DATABASE_URL' -e WASP_WEB_CLIENT_URL='$WASP_WEB_CLIENT_URL' -e JWT_SECRET='$JWT_SECRET' -e GOOGLE_CLIENT_ID='$GOOGLE_CLIENT_ID' -e GOOGLE_CLIENT_SECRET='$GOOGLE_CLIENT_SECRET' -d ghcr.io/$GITHUB_REPOSITORY:$TAG" From 7d6a54bdca266130c50644c8b7776cac8ffcd233 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 3 Nov 2023 16:58:26 +0530 Subject: [PATCH 8/8] Remove debug stuff --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 785e9f5..ad4dcce 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -50,7 +50,7 @@ jobs: run: shell: bash needs: [docker_build_push] - if: github.ref_name == 'main' || github.ref_name == 'fix-backend-deploy' + if: github.ref_name == 'main' container: image: python:3.7-stretch env: