Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added docker check to workflow #2414

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5821d59
added docker check to workflow
VanshikaSabharwal Nov 8, 2024
1519682
Merge branch 'develop' into docker-1
VanshikaSabharwal Nov 8, 2024
81bbb3e
made recommended changes to docker check in workflow
VanshikaSabharwal Nov 8, 2024
7d04c94
made recommended changes to docker check in workflow
VanshikaSabharwal Nov 8, 2024
f8389f6
added changes to docker check inn workflow as recommended
VanshikaSabharwal Nov 8, 2024
f54dcf2
added changes
VanshikaSabharwal Nov 8, 2024
b93aed6
updated indentation in pull-request.yml file
VanshikaSabharwal Nov 8, 2024
a0ee511
updated indentation in pull-request.yml file
VanshikaSabharwal Nov 8, 2024
235d163
added Dockerfile and Docker-compose.yml file
VanshikaSabharwal Nov 10, 2024
66f4843
added Dockerfile and Docker-compose.yml file
VanshikaSabharwal Nov 10, 2024
aef2485
Merge branch 'develop' into dockerfile-1
VanshikaSabharwal Nov 10, 2024
0fa9fe5
updated .docker-ignore file
VanshikaSabharwal Nov 10, 2024
88626b7
Merge branch 'dockerfile-1' of https://github.com/VanshikaSabharwal/t…
VanshikaSabharwal Nov 10, 2024
6fd1e01
Merge branch 'develop' into docker-1
VanshikaSabharwal Nov 11, 2024
e572cf4
Merge branch 'docker-1' of https://github.com/VanshikaSabharwal/talaw…
VanshikaSabharwal Nov 11, 2024
cfdeff5
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
e188853
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
9a2b428
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
12e5474
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
17a12f7
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
a44ecdb
added recommended changes by code rabbit
VanshikaSabharwal Nov 11, 2024
526a2cf
properly formatted code
VanshikaSabharwal Nov 11, 2024
d4fca6f
trying to make docker check pass
VanshikaSabharwal Nov 15, 2024
41bb9cf
Merge branch 'develop' into docker-1
VanshikaSabharwal Nov 15, 2024
7966dda
trying to make docker check pass
VanshikaSabharwal Nov 15, 2024
ec8ec5f
Merge branch 'docker-1' of https://github.com/VanshikaSabharwal/talaw…
VanshikaSabharwal Nov 15, 2024
96d5e9a
updated INSTALLATION.md
VanshikaSabharwal Nov 15, 2024
ef08944
updated INSTALLATION.md
VanshikaSabharwal Nov 15, 2024
8236c9a
added recommended changes to INSTALLATION.md
VanshikaSabharwal Nov 15, 2024
b09c696
added recommended changes to INSTALLATION.md
VanshikaSabharwal Nov 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
node_modules
npm-debug.log
Dockerfile
.git
.gitignore
.env
.env.*
dist
coverage
.nyc_output
*.md
.github
tests
__tests__
*.test.*
*.spec.*
# Development files
*.log
*.lock
.DS_Store
.idea
.vscode
# Build artifacts
build
out
91 changes: 74 additions & 17 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
- name: Check formatting
if: steps.changed-files.outputs.only_changed != 'true'
run: npm run format:check

- name: Run formatting if check fails
if: failure()
run: npm run format
Expand All @@ -57,10 +57,10 @@ jobs:

- name: Check for linting errors in modified files
if: steps.changed-files.outputs.only_changed != 'true'
env:
env:
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
run: npx eslint ${CHANGED_FILES} && python .github/workflows/eslint_disable_check.py

VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
- name: Check for TSDoc comments
run: npm run check-tsdoc # Run the TSDoc check script

Expand Down Expand Up @@ -89,7 +89,7 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get Changed Unauthorized files
id: changed-unauth-files
uses: tj-actions/changed-files@v40
Expand Down Expand Up @@ -123,10 +123,10 @@ jobs:
ISSUE_GUIDELINES.md
PR_GUIDELINES.md
README.md

- name: List all changed unauthorized files
if: steps.changed-unauth-files.outputs.any_changed == 'true' || steps.changed-unauth-files.outputs.any_deleted == 'true'
env:
env:
CHANGED_UNAUTH_FILES: ${{ steps.changed-unauth-files.outputs.all_changed_files }}
run: |
for file in ${CHANGED_UNAUTH_FILES}; do
Expand All @@ -147,14 +147,14 @@ jobs:
uses: tj-actions/changed-files@v40

- name: Echo number of changed files
env:
env:
CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
run: |
echo "Number of files changed: $CHANGED_FILES_COUNT"

- name: Check if the number of changed files is less than 100
if: steps.changed-files.outputs.all_changed_files_count > 100
env:
env:
CHANGED_FILES_COUNT: ${{ steps.changed-files.outputs.all_changed_files_count }}
run: |
echo "Error: Too many files (greater than 100) changed in the pull request."
Expand Down Expand Up @@ -194,23 +194,23 @@ jobs:

- name: Install Dependencies
run: npm install

- name: Get changed TypeScript files
id: changed-files
uses: tj-actions/changed-files@v40

- name: Run tests
if: steps.changed-files.outputs.only_changed != 'true'
run: npm run test -- --watchAll=false --coverage
run: npm run test -- --watchAll=false --coverage

- name: TypeScript compilation for changed files
run: |
for file in ${{ steps.changed-files.outputs.all_files }}; do
if [[ "$file" == *.ts || "$file" == *.tsx ]]; then
npx tsc --noEmit "$file"
fi
done

- name: Present and Upload coverage to Codecov as ${{env.CODECOV_UNIQUE_NAME}}
uses: codecov/codecov-action@v4
with:
Expand All @@ -222,7 +222,7 @@ jobs:
- name: Test acceptable level of code coverage
uses: VeryGoodOpenSource/very_good_coverage@v2
with:
path: "./coverage/lcov.info"
path: './coverage/lcov.info'
min_coverage: 95.0

Graphql-Inspector:
Expand All @@ -240,19 +240,76 @@ jobs:

- name: resolve dependency
run: npm install -g @graphql-inspector/cli

- name: Clone API Repository
run: |
# Retrieve the complete branch name directly from the GitHub context
FULL_BRANCH_NAME=${{ github.base_ref }}
echo "FULL_Branch_NAME: $FULL_BRANCH_NAME"

# Clone the specified repository using the extracted branch name
git clone --branch $FULL_BRANCH_NAME https://github.com/PalisadoesFoundation/talawa-api && ls -a
git clone --branch $FULL_BRANCH_NAME https://github.com/PalisadoesFoundation/talawa-api && ls -a

- 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
needs: [Code-Quality-Checks, Test-Application]
steps:
- name: Checkout the Repository
uses: actions/checkout@v4

- name: Set up Docker
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
image=moby/buildkit:latest
cache-from: type=gha
cache-to: type=gha,mode=max

VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
- name: Build Docker image
run: |
set -e
echo "Building Docker image..."
docker build -t talawa-admin-app .
echo "Docker image built successfully"

- name: Run Docker Container
run: |
set -e
echo "Started Docker container..."
docker run -d --name talawa-admin-app-container -p 4321:4321 talawa-admin-app
echo "Docker container started successfully"

- name: Check if Talawa Admin App is running
run: |
timeout="${HEALTH_CHECK_TIMEOUT:-120}"
echo "Starting health check with ${timeout}s timeout"
while ! nc -z localhost 4321 && [ $timeout -gt 0 ]; do
sleep 1

timeout=$((timeout-1))
if [ $((timeout % 10)) -eq 0 ]; then
echo "Still waiting for app to start... ${timeout}s remaining"
fi
done

if [ $timeout -eq 0 ]; then
echo "Timeout waiting for application to start"
echo "Container logs:"
docker logs talawa-admin-app-container
exit 1
fi
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
echo "Port check passed, verifying health endpoint..."

- name: Stop Docker Container
if: always()
run: |
docker stop talawa-admin-app-container
docker rm talawa-admin-app-container

VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
Check-Target-Branch:
if: ${{ github.actor != 'dependabot[bot]' }}
name: Check Target Branch
Expand Down
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM node:20.10.0 AS build

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

EXPOSE 4321

CMD ["npm", "run", "serve"]
52 changes: 52 additions & 0 deletions INSTALLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ This document provides instructions on how to set up and start a running instanc
- [Install node.js](#install-nodejs)
- [Install TypeScript](#install-typescript)
- [Install Required Packages](#install-required-packages)
- [Installation using Docker](#installation-using-docker)
- [Prerequisites](#prerequisites-1)
- [Development Setup](#development-setup)
- [Production Setup](#production-setup)
- [Configuration](#configuration)
- [Creating .env file](#creating-env-file)
- [Setting up PORT in .env file](#setting-up-port-in-env-file)
Expand Down Expand Up @@ -145,6 +149,54 @@ npm install

The prerequisites are now installed. The next step will be to get the app up and running.

# Installation using Docker

## Prerequisites

1. Install Docker on your system:
- [Docker Desktop for Windows/Mac](https://www.docker.com/products/docker-desktop)
- [Docker Engine for Linux](https://docs.docker.com/engine/install/)

## Development Setup

If you prefer to use Docker, you can install the app using the following command:

1. Create a `.env` file as described in the Configuration section

2. Build the Docker Image:

Run the following command to build the Docker image:

```
docker build -t talawa-admin .
```

3. Run the Docker container:

After the build is complete, run the Docker container using this command:

```
docker run -p 4321:4321 talawa-admin
```

The application will be accessible at `http://localhost:4321`
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved

## Production Setup

1. Build the Docker image:

```bash
docker build -t talawa-admin .
```

2. Run the container:
```bash
docker run -p 4321:4321 \
-e REACT_APP_TALAWA_URL=http://your-api-url:4000/graphql/ \
-e REACT_APP_BACKEND_WEBSOCKET_URL=ws://your-api-url:4000/graphql/ \
talawa-admin
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
```

# Configuration

It's important to configure Talawa-Admin. Here's how to do it.
Expand Down
5 changes: 3 additions & 2 deletions config/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
VanshikaSabharwal marked this conversation as resolved.
Show resolved Hide resolved
port: 4321,
},
});
Loading