项目作者: rgab1508

项目描述 :
Event Registration Website for Colleges
高级语言: JavaScript
项目地址: git://github.com/rgab1508/FACES-21.git
创建时间: 2021-08-03T17:27:24Z
项目社区:https://github.com/rgab1508/FACES-21

开源协议:MIT License

下载


FACES 2021

College Event Registration Website.
(used for Faces-2021)

Structure

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

Branches

Folder Description
master Main Branch which is deployed during registration
registrations-closed Deploy when registration Closed

Deploy

Backend

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

    1. Setting up all the environment Variables required

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

      1. 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)
      1. export DB_NAME='<DATABASE_NAME>'
      2. export DB_USERNAME='<DATABASE_USERNAME>'
      3. export DB_PASSWORD='<DATABASE_PASSWORD>'
      or edit this file
      1. DATABASES = {
      2. 'default': {
      3. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
      4. 'NAME': os.getenv("DB_NAME"),
      5. 'USER': os.getenv("DB_USERNAME"),
      6. 'PASSWORD': os.getenv("DB_PASSWORD"),
      7. 'HOST': 'localhost',
      8. 'PORT': '',
      9. }
      10. }
    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

    1. cd client/
    2. npm install
    3. npm run dev
  • Production
    Use production build to make website run faster
    1. cd client/
    2. npm install
    3. npm run build
    4. npm run start

Nginx Config for running both apps in a Single Server

sudo vim /etc/nginx/sites-availabe/website

  1. server {
  2. root /var/www/html;
  3. index index.html index.htm index.nginx-debian.html;
  4. server_name <DOMAIN_OR_PUBLIC_IP>;
  5. location /static {
  6. alias <PATH_TO_STATICFILES>
  7. # eg: /home/<USERNAME>/FACES-21/backend/staticfiles;
  8. }
  9. location /media {
  10. alias <PATH_TO_MEDIA>
  11. # eg: /home/<USERNAME>/FACES-21/backend/media;
  12. }
  13. location /admin/ {
  14. include proxy_params;
  15. proxy_pass http://unix:/run/gunicorn.sock;
  16. }
  17. location /api/ {
  18. include proxy_params;
  19. proxy_pass http://unix:/run/gunicorn.sock;
  20. }
  21. location / {
  22. proxy_pass http://localhost:3000;
  23. proxy_http_version 1.1;
  24. proxy_set_header Upgrade $http_upgrade;
  25. proxy_set_header Connection 'upgrade';
  26. proxy_set_header Host $host;
  27. proxy_cache_bypass $http_upgrade;
  28. }
  29. }