Abhishek Lokare
Abhishek Lokare

Reputation: 41

How can we deploy a django app onn google cloud?

I am having trouble deploying a developed django app on google console. Firstly it renames all the files of the app to some random name. Also when I try to hit the website .appspot.com I get an internal error.

Have created app.yaml file:

# [START runtime]
runtime: python27
entrypoint: gunicorn -b :$PORT mysite.wsgi
threadsafe: true
# [END runtime]

handlers:
- url: /static
  static_dir: website/static

- url: /.*
  script: main.application

libraries:

- name: django
  version: 1.11

Also have created appengine_cofig.py file:

# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# [START vendor]
from google.appengine.ext import vendor

vendor.add('lib')
# [END vendor]

Thanks for the help in advance....

Upvotes: 0

Views: 516

Answers (1)

Pauline Kanaiza
Pauline Kanaiza

Reputation: 11

As a complete beginner, I'll suggest following the google documentation here (https://cloud.google.com/python/django/appengine) step by step taking note that:

  1. Django default database is sqlite3, you will have to change it to mysql and it is recommended that you do this at the very beggining of creating your Django app. I recommend following instructions in this youtube video (https://www.youtube.com/watch?v=s16p32pndK0)
  2. Your app.yaml file should look as so;

runtime: python27
api_version: 1
threadsafe: yes

handlers:
- url: /static
  static_dir: static/
  application_readable: True
- url: .*
  script: yourapplication.wsgi.application

# Only pure Python libraries can be vendored
# Python libraries that use C extensions can
# only be included if they are part of the App Engine SDK 
# Using Third Party Libraries: https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27
libraries:
- name: MySQLdb
  version: 1.2.5
- name: django
  version: "1.11"
- name: ssl
  version: latest
# [END django_app]
 
# Google App Engine limits application deployments to 10,000 uploaded files per
# version. The skip_files section allows us to skip virtual environment files
# to meet this requirement. The first 5 are the default regular expressions to
# skip, while the last one is for all env/ files.
skip_files:
- ^(.*/)?#.*#$
- ^(.*/)?.*~$
- ^(.*/)?.*\.py[co]$
- ^(.*/)?.*/RCS/.*$
- ^(.*/)?\..*$
- ^env/.*$

I am also a beginner and I have just managed to deploy my app to GAE, all the best.

Upvotes: 1

Related Questions