College Event Registration Website. (used for Etamax-2022)
Folder | Description |
---|---|
backend | Django App (Rest API) |
client | Next App (with SSR and SSG) |
- Development
Running the Project Locally
1. clone the repository
git clone https://github.com/rgab1508/ETAMAX-22.git cd FACES-21/
- Setting up a Virtual Env
python -m virtualenv venv
- Activating Virtual Env
.\venv\Scripts\activate (windows) or source venv/bin/activate (Linux)
- Installing Dependency
cd backend/ pip intall -r requirements.txt
- Applying migrations in Database *This project uses Roll Number as the Primary key.
python manage.py makemigrations
- Creating a Django Super User
python manage.py createsuperuser
- Running the server
python manage.py runserver
- Production
Deploying in a Virtual Private Server
-
Setting up all the environment Variables required
export DJANGO_DEBUG=False export OTP_VERIFY_SECRET='<RANDOM_LONG_STRING>'
-
Adding domain or IP in
backend/backend/setting.py
ALLOWED_HOSTS = ['127.0.0.1', '<UR_DOMAIN_OR_PUBLIC_IP>']
-
Setting up Database Conntection You can set Environment Variables for Database Credentials in the production Server (recomended)
export DB_NAME='<DATABASE_NAME>' export DB_USERNAME='<DATABASE_USERNAME>' export DB_PASSWORD='<DATABASE_PASSWORD>'
or edit this file
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': os.getenv("DB_NAME"), 'USER': os.getenv("DB_USERNAME"), 'PASSWORD': os.getenv("DB_PASSWORD"), 'HOST': 'localhost', 'PORT': '', } }
-
Then you can perform Steps 1 to 6 from Running the Project Locally Section
-
Using Gunicorn to run server in Production you can follow this guide for setting up gunicorn and nginx
-
-
Development Running locally
cd client/ yarn yarn dev
-
Production Use production build to make website run faster
cd client/ yarn yarn build yarn start
sudo vim /etc/nginx/sites-availabe/website
server {
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name <DOMAIN_OR_PUBLIC_IP>;
location /static {
alias <PATH_TO_STATICFILES>
# eg: /home/<USERNAME>/ETAMAX-22/backend/staticfiles;
}
location /media {
alias <PATH_TO_MEDIA>
# eg: /home/<USERNAME>/ETAMAX-22/backend/media;
}
location /admin/ {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
location /api/ {
include proxy_params;
proxy_pass http://unix:/run/gunicorn.sock;
}
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}