Skip to content

Latest commit

 

History

History
210 lines (118 loc) · 6.73 KB

2. Installation and Settings.md

File metadata and controls

210 lines (118 loc) · 6.73 KB

Installation and Settings

Installation

1. Python Installation

You need to install Python 3.5+ !

Windows / Mac OS X

Go to install

Ubuntu

$ sudo apt-get install python3.5

$ sudo apt-get install python3-pip

###2. Python Package Installation

$ sudo pip install -r requirements.txt or $ sudo pip3 install -r requirements.txt

Settings

1. SECRET_KEY Setting

You have to create your own secret key for security reasons. Run the script below to generate your secret key.

$ python secret_key_gen.py or $ python3 secret_key_gen.py

2. Project Migration

$ python manage.py migrate or $ python3 manage.py migrate

3. Static files generation

$ python manage.py collectstatic --noinput or $ python3 manage.py collectstatic --noinput

4. Create Superuser

$ python manage.py createsuperuser or $ python3 manage.py createsuperuser

  • Superuser's email address has to be different from other users' email addresses.
  • If you try to log-in with superuser's email, login system will malfunction.

5. Starting redis server

$ redis-server

default port : 6379

6. Starting django server

$ python manage.py runserver or $ python3 manage.py runserver

7. Create OAuth 2.0 Client ID in Google API Console

  • Navigate to Credentials under the API Manager tab on the left side.

  • In the tab bar on top, go to Project > Create project to create a project.

  • Provide a project name and click on Create. When the process completes, Google will prompt you to create the credentials you need.

  • Click on Create credentials, and select the OAuth client ID option.

  • Click on Configure consent screen to set the product name.

  • Provide a product name under Product name shown to users. It will be shown to the users when they log-in through Google. Click Save.

  • Application type is Web Application. Choose Web application, and provide a name for your app under Name.

  • Under Restrictions, enter the following information:

  • Authorized JavaScript origins: http://{ Your_Domain }

Ex) http://localhost:8000

  • Authorized redirect URIs: http://{ Your_Domain }/accounts/google/login/callback/

Ex) http://localhost:8000/accounts/google/login/callback/

  • Click Create to create your project.

8. Application Setting

  • Go to /admin and log-in with the superuser id.

Ex) http://localhost:8000/admin

  • Under the SITES tab, click Sites and edit example.com to { Your_Domain }.

  • Make sure that { Your_Domain } doesn't contain http:// or https://.

  • Also Make sure not to delete the default domain. Any operation other than editing will cause the program to malfunction.

Ex) example.com to localhost:8000

  • Under SOCIAL ACCOUNTS, go to Social applications and click ADD SOCIAL APPLICATION on the top right.

  • Refer to Google API Console - OAuth Client ID. Click on name for credentials, and enter the following information :

  • Provider : Google

  • Name : name

  • Client id : Client ID

  • Secret Key : Client Secret

  • Chosen Sites : { Your_Domain }

Additional setting for cloud services

1. Starting redis server

$ sudo redis-server

default port : 6379

2. Starting django server

$ sudo python manage.py runserver 0.0.0.0:80 or $ sudo python3 manage.py runserver 0.0.0.0:80

3. Edit coding_night_live/settings.py

ALLOWED_HOSTS = [{ Your_Domain }] TIME_ZONE = { Your_Timezone }

Ex) Domain : www.codingnightlive.com

ALLOWED_HOSTS = ['.codingnightlive.com']

Ex) Time zone : Korea, Seoul (You can find your timezone here)

TIME_ZONE = 'Asia/Seoul'

Docker usage guide

Using Docker makes deployment easier! (recommended)

1. Docker Installation

2. Executing coding-night-live using docker

$ sudo docker-compose up -d

3. View the log for coding-night-live using docker

$ sudo docker-compose logs -f

4. Configuration

$ make docker_prepare

And you can also check newly generated root password.

Refer to the Generated root password: in logs.

5. Enjoy!

  • http://Domain/
  • http://Domain/admin (id: root)
  • SANDBOX:
    • localhost:5432 for PostgreSQL
    • localhost:6379 for Redis
    • localhost:8000 for Daphne

6. Shutdown and delete coding-night-live using docker

$ sudo docker-compose down --rmi local

+ Reset the postgres database

$ sudo docker-compose scale postgres=0 $ rm -rf postgres_db/ $ sudo docker-compose scale postgres=1

+ Rebuild and Relaunch for docker container

$ sudo docker-compose build daphne worker $ sudo docker-compose scale daphne=0 worker=0 $ sudo docker-compose up -d daphne worker

+ Production way:

Docker is also good for production.

If you want to run it as production mode,

  1. should look at docker-compose.yaml here and find for SANDBOX keyword.
    • Commenting out SANDBOX ports, currently postgres, daphne, and redis, is highly recommended, as internal ports should remain closed in production.
  2. copy-paste docker-compose.yaml to elsewhere and use it as docker-compose -f elsewhere.yaml ....
    • For automating the configuration steps, OAUTH_CLIENT_ID, OAUTH_SECRET and DOMAIN environment variables can be added to daphne service. (It doesn't mean that $ make docker_prepare can be skippable.)

+ Rebuild and Relaunch for docker container

$ sudo docker-compose build daphne worker $ sudo docker-compose scale daphne=0 worker=0 $ sudo docker-compose up -d daphne worker

Error logging with Sentry

We're using error logging system with sentry.

If you do not want us to be notified about errors of your deployed server, or if you want to attach your own sentry account, change or delete options of RAVEN_CONFIG here.