Skip to content

Commit

Permalink
Merge pull request #4 from MdSamsuzzohaShayon/development
Browse files Browse the repository at this point in the history
Auto deploy with linux bash
  • Loading branch information
MdSamsuzzohaShayon authored Jan 30, 2024
2 parents a6c4adb + 113a486 commit cb23c05
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 3 deletions.
49 changes: 49 additions & 0 deletions auto_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/bin/bash

echo "======================================================================================================"
echo "================================ Stop previous projects and delete it ================================"
echo "======================================================================================================"
cd
sudo systemctl stop gunicorn
rm -rf webdevlab
ls -la

echo "======================================================================================================"
echo "================================ Clone repository from github ========================================"
echo "======================================================================================================"
git clone git@github.com:MdSamsuzzohaShayon/webdevlab.git
ls -la


echo "======================================================================================================"
echo "================================ Deploy Django ======================================================="
echo "======================================================================================================"
cd /home/shayon/webdevlab/server
python3 -m venv .venv
source .venv/bin/activate
echo "# Django Dot Environment" > .env
nano .env
nano core/settings.py
pip install -r requirements.txt
./manage.py makemigrations
./manage.py migrate
sudo systemctl daemon-reload
sudo systemctl restart gunicorn
# gunicorn core:application --check-config
deactivate
cd

echo "======================================================================================================"
echo "================================ Deploy Nuxt.js ======================================================"
echo "======================================================================================================"
cd /home/shayon/webdevlab/client
echo "# Nuxt.js Dot Environment" > .env
nano .env
nano utils/keys.ts
npm install
npm run build
npm run generate
sudo rm -rf /var/www/html
sudo cp -r .output/public /var/www/html
cd
ls -la
3 changes: 2 additions & 1 deletion client/utils/keys.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export const FRONTEND_URL: string = 'http://localhost:3000'
export const FRONTEND_URL: string = 'http://localhost:3000';
// export const FRONTEND_URL: string = 'https://webdevlab.org';
1 change: 0 additions & 1 deletion deploy.sh

This file was deleted.

3 changes: 2 additions & 1 deletion server/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
DEBUG = False

ALLOWED_HOSTS = [
# 'http://localhost:3000',
'localhost',
]


Expand Down Expand Up @@ -99,6 +99,7 @@

CORS_ALLOWED_ORIGINS = [
'http://localhost:3000',
os.environ["FRONTEND_URL"]
]

WSGI_APPLICATION = 'core.wsgi.application'
Expand Down
14 changes: 14 additions & 0 deletions server/gunicorn.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# /etc/systemd/system/gunicorn.service
[Unit]
Description=gunicorn daemon for webdevlab
After=network.target

[Service]
User=shayon
Group=shayon
WorkingDirectory=/home/shayon/webdevlab/server
ExecStart=/home/shayon/webdevlab/server/.venv/bin/gunicorn core.wsgi:application


[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions server/gunicorn_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bind = "0.0.0.0:8000"
workers = 3
1 change: 1 addition & 0 deletions server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ sqlparse==0.4.4
text-unidecode==1.3
typing_extensions==4.9.0
urllib3==2.1.0
gunicorn==21.2.0

0 comments on commit cb23c05

Please sign in to comment.