-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: Only show assets which are not deleted * fix: Fix Pagination bug * build: Dockerize backend and frontend services * build: Add CORS settings to .env files * feat: Show IN SERVICE status in dashboard chart * fix: Remove duplicate toggleModel method * build: Update requirements.txt * fix: Change health check of celery from ping to celery health * build: Add services in docker compose to deploy in stage environment - Add redis service - Add script for running celery worker and beat scheduler in background - Use gunicorn for serving django backend * ci: Deploy frontend and backend along with dependent services * ci: Build frontend for production
- Loading branch information
1 parent
d8c08b5
commit 46d8db4
Showing
8 changed files
with
207 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
name: Deploy to production environment | ||
|
||
on: | ||
push: | ||
branches: | ||
- "prod" | ||
|
||
jobs: | ||
|
||
deploy-backend: | ||
runs-on: ubuntu-latest | ||
environment: prod | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Deploy on AWS EC2 | ||
uses: easingthemes/ssh-deploy@main | ||
with: | ||
SSH_PRIVATE_KEY: ${{ secrets.AWS_EC2_SSH_PRIVATE_KEY }} | ||
ARGS: "-rlgoDzvc -i" | ||
SOURCE: "./" | ||
REMOTE_HOST: ${{ secrets.AWS_EC2_HOSTNAME }} | ||
REMOTE_USER: ${{ secrets.AWS_EC2_USERNAME }} | ||
TARGET: "~/asset-management/" | ||
EXCLUDE: "/dist/, /node_modules/" | ||
SCRIPT_BEFORE: | | ||
ls -a | ||
echo "=================" | ||
echo "Update" | ||
echo "=================" | ||
sudo apt-get update -y | ||
echo "=================" | ||
echo "Upgrade" | ||
echo "=================" | ||
sudo apt-get upgrade -y | ||
echo "=================" | ||
echo "Install rsync" | ||
echo "=================" | ||
sudo apt-get install -y rsync | ||
echo "=================" | ||
echo "Create Directory" | ||
echo "=================" | ||
mkdir -p asset-management | ||
SCRIPT_AFTER: | | ||
ls -a | ||
echo "=================" | ||
echo "Change current directory to exam_django" | ||
echo "=================" | ||
cd asset-management/exam_django | ||
echo "=================" | ||
echo "Remove the current .prod.env file" | ||
echo "=================" | ||
rm -f .prod.env | ||
echo "=================" | ||
echo "Add environment variables to .prod.env file" | ||
echo "=================" | ||
echo "DJANGO_SECRET_KEY=${{ secrets.DJANGO_SECRET_KEY }}" >> .prod.env | ||
echo "DEBUG_STATUS=${{ secrets.DEBUG_STATUS }}" >> .prod.env | ||
echo "DB_NAME=${{ secrets.DB_NAME }}" >> .prod.env | ||
echo "DB_USER=${{ secrets.DB_USER }}" >> .prod.env | ||
echo "DB_PORT=${{ secrets.DB_PORT }}" >> .prod.env | ||
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> .prod.env | ||
echo "DB_HOST=${{ secrets.DB_HOST }}" >> .prod.env | ||
echo "ALLOWED_HOSTS=${{ secrets.ALLOWED_HOSTS }}" >> .prod.env | ||
echo "CORS_ORIGIN_WHITELIST=${{ secrets.CORS_ORIGIN_WHITELIST }}" >> .prod.env | ||
echo "CORS_ALLOWED_ORIGINS=${{ secrets.CORS_ALLOWED_ORIGINS }}" >> .prod.env | ||
echo "CELERY_BROKER_URL=${{ secrets.CELERY_BROKER_URL }}" >> .prod.env | ||
echo "CELERY_RESULT_BACKEND=${{ secrets.CELERY_RESULT_BACKEND }}" >> .prod.env | ||
echo "EMAIL_HOST_USER=${{ secrets.EMAIL_HOST_USER }}" >> .prod.env | ||
echo "EMAIL_HOST_PASSWORD=${{ secrets.EMAIL_HOST_PASSWORD }}" >> .prod.env | ||
echo "EMAIL_PORT=${{ secrets.EMAIL_PORT }}" >> .prod.env | ||
echo "EMAIL_USE_TLS=${{ secrets.EMAIL_USE_TLS }}" >> .prod.env | ||
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> .prod.env | ||
echo "HEALTH_CHECK_APP=${{ secrets.HEALTH_CHECK_APP }}" >> .prod.env | ||
echo "HEALTH_CHECK_EXTERNAL=${{ secrets.HEALTH_CHECK_EXTERNAL }}" >> .prod.env | ||
echo "BACKUP_PARENT_DIR=${{ secrets.BACKUP_PARENT_DIR }}" >> .prod.env | ||
echo "FULL_BACKUP_DIR=${{ secrets.FULL_BACKUP_DIR }}" >> .prod.env | ||
echo "GOOGLE_API_KEY=${{ secrets.GOOGLE_API_KEY }}" >> .prod.env | ||
echo "=================" | ||
echo "Change current directory to exam_frontend" | ||
echo "=================" | ||
cd ../exam_frontend | ||
echo "=================" | ||
echo "Remove the current .env file" | ||
echo "=================" | ||
rm -f .env | ||
echo "=================" | ||
echo "Add environment variables to .env file" | ||
echo "=================" | ||
echo "VITE_CONFIG_URL=${{ secrets.VITE_CONFIG_URL }}" >> .env | ||
echo "VITE_ADD_ASSET_URL=${{ secrets.VITE_ADD_ASSET_URL }}" >> .env | ||
echo "VITE_LOGIN_URL=${{ secrets.VITE_LOGIN_URL }}" >> .env | ||
echo "VITE_GET_ASSET_TYPE=${{ secrets.VITE_GET_ASSET_TYPE }}" >> .env | ||
echo "=================" | ||
echo "Change current directory to asset-management" | ||
echo "=================" | ||
cd .. | ||
echo "=================" | ||
echo "Start Production Deploy Script" | ||
echo "=================" | ||
sudo chmod +x ./stage-deploy.sh | ||
./stage-deploy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,7 @@ COPY . . | |
|
||
EXPOSE 5173 | ||
|
||
RUN chmod +x entrypoint-stage.sh | ||
EXPOSE 4173 | ||
|
||
CMD ["yarn", "dev"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
yarn build | ||
|
||
yarn preview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 24 additions & 22 deletions
46
exam_frontend/src/components/SideDrawerComponent/SideDrawerComponentHandler.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
import React, { useState } from "react"; | ||
import SideDrawerProps from "./types"; | ||
|
||
import React, { useState } from 'react'; | ||
import SideDrawerProps from './types'; | ||
import { Button, Drawer, Space } from "antd"; | ||
import type { DrawerProps } from "antd"; | ||
|
||
import { Button, Drawer, Space } from 'antd'; | ||
import type { DrawerProps } from 'antd'; | ||
const SideDrawerComponent: React.FC<SideDrawerProps> = ({ | ||
children, | ||
buttonTextLarge, | ||
}) => { | ||
const [open, setOpen] = useState(false); | ||
const [size, setSize] = useState<DrawerProps["size"]>(); | ||
|
||
const SideDrawerComponent: React.FC<SideDrawerProps> = ({children,buttonTextLarge}) => { | ||
const [open, setOpen] = useState(false); | ||
const [size, setSize] = useState<DrawerProps['size']>(); | ||
|
||
const showDefaultDrawer = () => { | ||
setSize('default'); | ||
setOpen(true); | ||
}; | ||
|
||
const showLargeDrawer = () => { | ||
setSize('large'); | ||
setOpen(true); | ||
}; | ||
|
||
const onClose = () => { | ||
setOpen(false); | ||
}; | ||
|
||
const showDefaultDrawer = () => { | ||
setSize("default"); | ||
setOpen(true); | ||
}; | ||
|
||
const showLargeDrawer = () => { | ||
setSize("large"); | ||
setOpen(true); | ||
}; | ||
|
||
const onClose = () => { | ||
setOpen(false); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
echo "=================" | ||
echo "Starting Stage Deploy Script" | ||
echo "=================" | ||
|
||
echo "=================" | ||
echo "Update" | ||
echo "=================" | ||
sudo apt-get update -y | ||
|
||
echo "=================" | ||
echo "Upgrade" | ||
echo "=================" | ||
sudo apt-get upgrade -y | ||
sudo apt-get install -y ca-certificates curl gnupg | ||
|
||
echo "=================" | ||
echo "Get docker compose version" | ||
echo "=================" | ||
docker compose version | ||
|
||
|
||
if [ $? -ne 0 ] | ||
then | ||
echo "Docker Compose does not exit" | ||
|
||
echo "=================" | ||
echo "Install docker and docker compose" | ||
echo "=================" | ||
sudo install -m 0755 -d /etc/apt/keyrings | ||
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | ||
sudo chmod a+r /etc/apt/keyrings/docker.gpg | ||
echo \ | ||
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \ | ||
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ | ||
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
sudo apt-get update -y | ||
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
fi | ||
|
||
echo "=================" | ||
echo "Docker compose up by building in detached mode" | ||
echo "=================" | ||
sudo docker compose --profile stage up --build --detach | ||
|
||
echo "=================" | ||
echo "Successfully executed Stage Deploy Script" | ||
echo "=================" |