- create a folder, let's say myproject
- cd myproject
- create a virtualenv
virtualenv -p python3 venv
- move into virtual environment and activate it
cd venv
source bin/activate
- clone this repo
git clone https://github.com/tsadimas/django-posts
- install the dependencies
pip install -r requirements.txt
- create a file db.json in git root directory, with the following
{
"NAME": "dbname",
"USER": "user",
"PASSWORD": "pass",
"HOST": "localhost",
"PORT": "3306"
}
pip install gunicorn
install google cloud sdk
- set up STATIC_ROOT, ALLOWED_HOSTS in settings.py
ALLOWED_HOSTS = [
os.environ['DEPLOY_HOST'],
'127.0.0.1',
]
STATIC_ROOT = os.path.join(BASE_DIR, "static/")
- create a file named app.yaml in project root directory
sample file:
entrypoint: gunicorn -b :$PORT postsproject.wsgi
env: flex
runtime: python
env_variables:
DEBUG: 'False'
DEPLOY_HOST: "XXXXXXXXX.appspot.com"
handlers:
- url: /static
static_dir: static
- run
python manage.py collectstatic
Run
gcloud init
select your gcloud account and your project Run
gcloud app deploy
see your app with
gcloud app browse
Links: