Skip to content

rgab1508/ETAMAX-22

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

ETAMAX 2022

College Event Registration Website. (used for Etamax-2022)

Structure

Folder Description
backend Django App (Rest API)
client Next App (with SSR and SSG)

Deploy

Backend

  • Development Running the Project Locally 1. clone the repository
    git clone https://github.com/rgab1508/ETAMAX-22.git
    cd FACES-21/
    1. Setting up a Virtual Env
    python -m virtualenv venv
    1. Activating Virtual Env
    .\venv\Scripts\activate (windows)
    or
    source venv/bin/activate (Linux)
    1. Installing Dependency
    cd backend/
    pip intall -r requirements.txt
    1. Applying migrations in Database *This project uses Roll Number as the Primary key.
    python manage.py makemigrations
    1. Creating a Django Super User
    python manage.py createsuperuser
    1. Running the server
    python manage.py runserver
  • Production Deploying in a Virtual Private Server
    1. Setting up all the environment Variables required

        export DJANGO_DEBUG=False
        export OTP_VERIFY_SECRET='<RANDOM_LONG_STRING>'				
    2. Adding domain or IP in backend/backend/setting.py

        ALLOWED_HOSTS = ['127.0.0.1', '<UR_DOMAIN_OR_PUBLIC_IP>']
    3. 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': '',
        	}
        }
      
    4. Then you can perform Steps 1 to 6 from Running the Project Locally Section

    5. Using Gunicorn to run server in Production you can follow this guide for setting up gunicorn and nginx

Frontend

  • Development Running locally

    cd client/
    yarn
    yarn dev
  • Production Use production build to make website run faster

    cd client/
    yarn
    yarn build
    yarn start

Nginx Config for running both apps in a Single Server

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;
	}
}

About

Development Repository for Etamax 2021

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published