Skip to content

mmmohajer/dockerizednextdjango

Repository files navigation

Setup:

  1. Setup Development environment:

    • Clone the repository

    • SETUP ON MAC/Linux:

    1. Got to root folder and run ./automation.sh in terminal
    2. Choose Option 1 --> Make initial setup on Mac/Linux
    3. Go to nginx folder and run --> htpasswd -c htpasswd user
      Choose password as the password of this user
    • SETUP ON WINDOWS:
    1. Create a python virtual env: python -m venv venv
    2. Activate virtual environment --> venv\Scripts\activate
    • pip install --upgrade pip
    • pip install -r api/requirements-windows-local.txt
    • Go to api folder and run python manage.py collectstatic
    • Go to client folder and run npm install
    • Go to root folder and run ./automation.sh in terminal
    • Choose Option 2 --> Make initial setup on Windows
    • If usig docker, go to nginx folder and run --> htpasswd -c htpasswd user
      Choose password as the password of this user

    Then, Do the following part, in ordet to be able to use docker in your development environment:

    1. Go to the root folder and run docker-compose -f docker-compose-dev.yml up --build -d

Note:
You might need to change the database name and database password in /api/config folder and env variables inside /config folder.

Note: In order to use celery with your application put USE_CELERY=1 in the environment variables.

Note: In order to send activation email after registration, put SEND_ACTIVATION_EMAIL=1 in the environment variables.

Note: In order to run the application, without the docker, you need to take the following steps:

  1. Go to client folder and change the value of WITHOUT_DOCKER to 1
  2. Active the python virtual env and install the following package:
    pip install python-dotenv

Note: Remember for deployment, you need to change the value of PRODUCTION to true in next.config.js file


  1. Test production environment on your local PC:
    • Run docker-compose -f docker-compose-prod.yml up -build -d

  1. Test performance of production environment on your local PC:
    • Run following commands:
      docker-compose -f docker-compose-prod.yml up -build -d
      cd api
      locust -f locustfiles/browse_api.py

  1. Setup Production environment:

    • Create the following subfolders:
      ./api/vol/static/
      ./api/vol/media/
      ./api/vol/static/app_static_files
      ./api/vol/media/pdfs
    • Go to root folder and run ./automation.sh in terminal
    • Choose Option 7 --> Copy environment variables in server
    • Then you need to add ssl config to your domain, so take the following steps:
    1. Create following subfolders:
    • ./nginx/certbot/conf/

    • ./nginx/certbot/www/
      2.docker-compose -f docker-compose-createSSL.yml up --build -d
      3.And then change domains and email in init-letsencrypt.sh
      4.Then run ./init-letsencrypt.sh

    • Now your app is ready to be run on server: To do so, first clear all volumes, images, and containersof docker, useing the following 3 commands:

    1. Run docker container rm -f $(docker container ls -a -q)
    2. Run docker image rm -f $(docker image ls -a -q)
    3. Run docker volume prune
    • Now everything is ready for your app to be served:
      Run docker-compose -f docker-compose-prod-ssl.yml up --build -d

To create a backup of the db
Go to the file utils/shellScripting/funcs/db_backup_local.sh
Change the docker container name, db name and db user based on the current project, then run:
./automation.sh
Select number 9

In order to restore db from a backedup file,
./automation.sh
Then select number 10

Run ngrok:
ngrok http -hostname=makeclient.ngrok.io 80
OR
ngrok http -host-header=makeclient.ngrok.io 80

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published