You need to install Python 3.5+ !
$ 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
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
$ python manage.py migrate
or $ python3 manage.py migrate
$ python manage.py collectstatic --noinput
or $ python3 manage.py collectstatic --noinput
$ 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.
$ redis-server
default port : 6379
$ 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 theOAuth 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. ClickSave
. -
Application type is
Web Application
. ChooseWeb application
, and provide a name for your app underName
. -
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.
- Go to
/admin
and log-in with thesuperuser id
.
Ex)
http://localhost:8000/admin
-
Under the
SITES
tab, clickSites
and editexample.com
to{ Your_Domain }
. -
Make sure that
{ Your_Domain }
doesn't containhttp://
orhttps://
. -
Also Make sure not to delete the default domain. Any operation other than editing will cause the program to malfunction.
Ex)
example.com
tolocalhost:8000
-
Under
SOCIAL ACCOUNTS
, go toSocial applications
and clickADD 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 }
$ sudo redis-server
default port : 6379
$ sudo python manage.py runserver 0.0.0.0:80
or $ sudo python3 manage.py runserver 0.0.0.0:80
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'
Using Docker
makes deployment easier! (recommended)
$ sudo docker-compose up -d
$ sudo docker-compose logs -f
$ make docker_prepare
- OAuth Client ID & Secret
- Domain
And you can also check newly generated root password.
Refer to the
Generated root password:
in logs.
- http://
Domain
/ - http://
Domain
/admin (id: root) - SANDBOX:
- localhost:5432 for PostgreSQL
- localhost:6379 for Redis
- localhost:8000 for Daphne
$ sudo docker-compose down --rmi local
$ sudo docker-compose scale postgres=0
$ rm -rf postgres_db/
$ sudo docker-compose scale postgres=1
$ sudo docker-compose build daphne worker
$ sudo docker-compose scale daphne=0 worker=0
$ sudo docker-compose up -d daphne worker
Docker is also good for production.
If you want to run it as production mode,
- should look at
docker-compose.yaml
here and findfor SANDBOX
keyword.- Commenting out SANDBOX ports, currently
postgres
,daphne
, andredis
, is highly recommended, as internal ports should remain closed in production.
- Commenting out SANDBOX ports, currently
- copy-paste
docker-compose.yaml
to elsewhere and use it asdocker-compose -f elsewhere.yaml ...
.- For automating the configuration steps,
OAUTH_CLIENT_ID
,OAUTH_SECRET
andDOMAIN
environment variables can be added todaphne
service. (It doesn't mean that$ make docker_prepare
can be skippable.)
- For automating the configuration steps,
$ 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.