From 5821d593bc162a87c1c8febd760652b1e5663fca Mon Sep 17 00:00:00 2001 From: VanshikaSabharwal Date: Fri, 8 Nov 2024 15:26:00 +0530 Subject: [PATCH 1/9] added docker check to workflow --- .github/workflows/pull-request.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 75588cc4df..9d91c367b6 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -241,6 +241,35 @@ jobs: - name: Validate Documents run: graphql-inspector validate './src/GraphQl/**/*.ts' './talawa-api/schema.graphql' + Docker-Start-Check: + name: Check if Talawa Admin app starts in Docker + runs-on: ubuntu-latest + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 + + - name: Set up Docker + run: | + sudo apt-get update + sudo apt-get install -y docker.io + + - name: Run Docker Container + run: | + docker run -d --name talawa-admin-container -p 8080:8080 talawa-admin-app + + - name: Check if Talawa Admin App is running + run: | + nc -z localhost 8080 + + curl --fail --silent http://localhost:8080/index.html || exit 1 + + - name: Stop Docker Container + if: always() + run: | + docker stop talawa-admin-app-container + docker rm talawa-admin-app-container + + Check-Target-Branch: if: ${{ github.actor != 'dependabot[bot]' }} name: Check Target Branch From 81bbb3e9cf976e37352ae524f886a5ff3f5027f9 Mon Sep 17 00:00:00 2001 From: VanshikaSabharwal Date: Fri, 8 Nov 2024 16:52:39 +0530 Subject: [PATCH 2/9] made recommended changes to docker check in workflow --- .github/workflows/pull-request.yml | 43 +++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9d91c367b6..099440bfb1 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -244,27 +244,46 @@ jobs: Docker-Start-Check: name: Check if Talawa Admin app starts in Docker runs-on: ubuntu-latest + needs: [Code-Quality-Checks] steps: - name: Checkout the Repository uses: actions/checkout@v4 - name: Set up Docker - run: | - sudo apt-get update - sudo apt-get install -y docker.io + uses: docker/setup-buildx-action@v3 + + - name: Build Docker image + run: | + docker build -t talawa-admin-app . - - name: Run Docker Container + - name: Run Docker Container run: | - docker run -d --name talawa-admin-container -p 8080:8080 talawa-admin-app - - - name: Check if Talawa Admin App is running + docker run -d --name talawa-admin-app-container -p 8080:8080 talawa-admin-app + + - name: Check if Talawa Admin App is running run: | - nc -z localhost 8080 - - curl --fail --silent http://localhost:8080/index.html || exit 1 + timeout=60 + while ! nc -z localhost 8080 && [ $timeout -gt 0 ]; do + sleep 1 + timeout=$((timeout-1)) + done + + if [ $timeout -eq 0 ]; then + echo "Timeout waiting for application to start" + exit 1 + fi + + # Retry curl up to 3 times with 5s delay + for i in {1..3}; do + if curl --fail --silent http://localhost:8080/index.html; then + exit 0 + fi + sleep 5 + done + exit 1 - - name: Stop Docker Container - if: always() + - name: Stop Docker Container + if: always() run: | docker stop talawa-admin-app-container docker rm talawa-admin-app-container From f8389f61abefdb2edb6c43f9b32759b07ff70283 Mon Sep 17 00:00:00 2001 From: VanshikaSabharwal Date: Fri, 8 Nov 2024 17:31:39 +0530 Subject: [PATCH 3/9] added changes to docker check inn workflow as recommended --- .github/workflows/pull-request.yml | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index df6fda018c..5ce2e16899 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -272,27 +272,12 @@ jobs: run: | docker run -d --name talawa-admin-app-container -p 8080:8080 talawa-admin-app - - name: Check if Talawa Admin App is running - run: | - timeout=60 - while ! nc -z localhost 8080 && [ $timeout -gt 0 ]; do - sleep 1 - timeout=$((timeout-1)) - done - - if [ $timeout -eq 0 ]; then - echo "Timeout waiting for application to start" - exit 1 - fi - - # Retry curl up to 3 times with 5s delay - for i in {1..3}; do - if curl --fail --silent http://localhost:8080/index.html; then - exit 0 - fi - sleep 5 - done - exit 1 + - name: Check if Talawa Admin app starts in Docker + runs-on: ubuntu-latest + needs: [Code-Quality-Checks] + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 - name: Stop Docker Container if: always() From f54dcf2a6e7c520ca91b7870d6309702689818a1 Mon Sep 17 00:00:00 2001 From: VanshikaSabharwal Date: Fri, 8 Nov 2024 17:52:51 +0530 Subject: [PATCH 4/9] added changes --- .github/workflows/pull-request.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 5ce2e16899..738e47ad53 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -272,12 +272,18 @@ jobs: run: | docker run -d --name talawa-admin-app-container -p 8080:8080 talawa-admin-app - - name: Check if Talawa Admin app starts in Docker - runs-on: ubuntu-latest - needs: [Code-Quality-Checks] - steps: - - name: Checkout the Repository - uses: actions/checkout@v4 + - name: Check if Talawa Admin App is running + run: | + timeout=60 + while ! nc -z localhost 8080 && [ $timeout -gt 0 ]; do + sleep 1 + timeout=$((timeout-1)) + done + if [ $timeout -eq 0 ]; then + echo "Timeout waiting for application to start" + exit 1 + fi + curl --fail --silent http://localhost:8080/index.html || exit 1 - name: Stop Docker Container if: always() From b93aed69118b9c246aaa5cf2c0ce1333e55fd6ce Mon Sep 17 00:00:00 2001 From: VanshikaSabharwal Date: Fri, 8 Nov 2024 22:14:02 +0530 Subject: [PATCH 5/9] updated indentation in pull-request.yml file --- .github/workflows/pull-request.yml | 74 +++++++++++++++--------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 738e47ad53..f89fb61dc3 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -254,43 +254,43 @@ jobs: run: graphql-inspector validate './src/GraphQl/**/*.ts' './talawa-api/schema.graphql' Docker-Start-Check: - name: Check if Talawa Admin app starts in Docker - runs-on: ubuntu-latest - needs: [Code-Quality-Checks] - steps: - - name: Checkout the Repository - uses: actions/checkout@v4 - - - name: Set up Docker - uses: docker/setup-buildx-action@v3 - - - name: Build Docker image - run: | - docker build -t talawa-admin-app . - - - name: Run Docker Container - run: | - docker run -d --name talawa-admin-app-container -p 8080:8080 talawa-admin-app - - - name: Check if Talawa Admin App is running - run: | - timeout=60 - while ! nc -z localhost 8080 && [ $timeout -gt 0 ]; do - sleep 1 - timeout=$((timeout-1)) - done - if [ $timeout -eq 0 ]; then - echo "Timeout waiting for application to start" - exit 1 - fi - curl --fail --silent http://localhost:8080/index.html || exit 1 - - - name: Stop Docker Container - if: always() - run: | - docker stop talawa-admin-app-container - docker rm talawa-admin-app-container + name: Check if Talawa Admin app starts in Docker + runs-on: ubuntu-latest + needs: [Code-Quality-Checks] + steps: + - name: Checkout the Repository + uses: actions/checkout@v4 + + - name: Set up Docker + uses: docker/setup-buildx-action@v3 + - name: Build Docker image + run: | + docker build -t talawa-admin-app . + + - name: Run Docker Container + run: | + docker run -d --name talawa-admin-app-container -p 8080:8080 talawa-admin-app + + - name: Check if Talawa Admin App is running + run: | + timeout=60 + while ! nc -z localhost 8080 && [ $timeout -gt 0 ]; do + sleep 1 + timeout=$((timeout-1)) + done + if [ $timeout -eq 0 ]; then + echo "Timeout waiting for application to start" + exit 1 + fi + curl --fail --silent http://localhost:8080/index.html || exit 1 + + - name: Stop Docker Container + if: always() + run: | + docker stop talawa-admin-app-container + docker rm talawa-admin-app-container + Check-Target-Branch: if: ${{ github.actor != 'dependabot[bot]' }} @@ -301,4 +301,4 @@ jobs: if: github.event.pull_request.base.ref != 'develop' run: | echo "Error: Pull request target branch must be 'develop'. Please refer PR_GUIDELINES.md" - exit 1 + exit 1 \ No newline at end of file From a0ee51150aa3ab8f4f8b2ec7de9e110d0bb07b4d Mon Sep 17 00:00:00 2001 From: VanshikaSabharwal Date: Fri, 8 Nov 2024 22:21:58 +0530 Subject: [PATCH 6/9] updated indentation in pull-request.yml file --- .github/workflows/pull-request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index f89fb61dc3..e7e1dda87c 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -256,7 +256,7 @@ jobs: Docker-Start-Check: name: Check if Talawa Admin app starts in Docker runs-on: ubuntu-latest - needs: [Code-Quality-Checks] + needs: [Code-Quality-Checks, Test-Application] steps: - name: Checkout the Repository uses: actions/checkout@v4 From 235d1631b475af29f9f6c7d3c33bac47fa2a5247 Mon Sep 17 00:00:00 2001 From: VanshikaSabharwal Date: Sun, 10 Nov 2024 19:29:42 +0530 Subject: [PATCH 7/9] added Dockerfile and Docker-compose.yml file --- .dockerignore | 9 +++++++++ Dockerfile | 15 +++++++++++++++ config/vite.config.ts | 5 +++-- docker-compose.yaml | 11 +++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 docker-compose.yaml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..d0adaf2671 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,9 @@ +node_modules +videos +images +data +.env +.git +.gitignore +.github +.dockerignore \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..fef086f72d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:20.10.0 AS build + +WORKDIR /usr/src/app + +COPY . . + +RUN npm install -g typescript + +RUN npm install + +RUN npm run build + +EXPOSE 4321 + +CMD ["npm", "run", "serve"] \ No newline at end of file diff --git a/config/vite.config.ts b/config/vite.config.ts index 71ce6c6f47..28cd47ae5a 100644 --- a/config/vite.config.ts +++ b/config/vite.config.ts @@ -23,8 +23,9 @@ export default defineConfig({ ], server: { // this ensures that the browser opens upon server start - open: true, - // this sets a default port to 3000 + open: false, + host: '0.0.0.0', + // this sets a default port to 4321 port: 4321, }, }); diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000000..5936109b22 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,11 @@ +services: + app: + build: + context: . + dockerfile: Dockerfile + environment: + - REACT_APP_TALAWA_URL=${REACT_APP_TALAWA_URL} + # volumes: + # - .:/usr/src/app + ports: + - 4321:4321 From 66f48432ee30c0db8ca5941271df5bdd4b4c6bfa Mon Sep 17 00:00:00 2001 From: VanshikaSabharwal Date: Sun, 10 Nov 2024 20:54:14 +0530 Subject: [PATCH 8/9] added Dockerfile and Docker-compose.yml file --- .github/workflows/pull-request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index e7e1dda87c..0950c572c9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -270,12 +270,12 @@ jobs: - name: Run Docker Container run: | - docker run -d --name talawa-admin-app-container -p 8080:8080 talawa-admin-app + docker run -d --name talawa-admin-app-container -p 4321:4321 talawa-admin-app - name: Check if Talawa Admin App is running run: | timeout=60 - while ! nc -z localhost 8080 && [ $timeout -gt 0 ]; do + while ! nc -z localhost 4321 && [ $timeout -gt 0 ]; do sleep 1 timeout=$((timeout-1)) done @@ -283,7 +283,7 @@ jobs: echo "Timeout waiting for application to start" exit 1 fi - curl --fail --silent http://localhost:8080/index.html || exit 1 + curl --fail --silent http://localhost:4321/ || exit 1 - name: Stop Docker Container if: always() From 0fa9fe5f66b2d4c2a47e35b6962b33537783c812 Mon Sep 17 00:00:00 2001 From: VanshikaSabharwal Date: Sun, 10 Nov 2024 21:15:05 +0530 Subject: [PATCH 9/9] updated .docker-ignore file --- .dockerignore | 19 ++++++++++++++----- .github/workflows/pull-request.yml | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.dockerignore b/.dockerignore index d0adaf2671..466682cc09 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,9 +1,18 @@ node_modules -videos -images -data -.env +npm-debug.log +Dockerfile +.dockerignore .git .gitignore +README.md +.env +.env.* +dist +coverage +.nyc_output +*.md .github -.dockerignore \ No newline at end of file +tests +__tests__ +*.test.* +*.spec.* \ No newline at end of file diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 0950c572c9..a3e478e5d4 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -274,7 +274,7 @@ jobs: - name: Check if Talawa Admin App is running run: | - timeout=60 + timeout=${HEALTH_CHECK_TIMEOUT:-60} while ! nc -z localhost 4321 && [ $timeout -gt 0 ]; do sleep 1 timeout=$((timeout-1)) @@ -283,7 +283,7 @@ jobs: echo "Timeout waiting for application to start" exit 1 fi - curl --fail --silent http://localhost:4321/ || exit 1 + curl --fail --silent http://localhost:4321/health || exit 1 - name: Stop Docker Container if: always()