Skip to content

Commit

Permalink
updated the gae instructions and example
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Sep 8, 2024
1 parent 890cffb commit 89bc8dd
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
15 changes: 3 additions & 12 deletions deployment_tools/gae/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,9 @@ install-gcloud-linux:
upgrade-gcloud:
gcloud components update
setup:
mkdir -p lib
rm -rf lib/*
#
cat ../../requirements.txt \
| grep -v gevent \
| grep -v tornado \
| grep -v gunicorn \
| grep -v memcache > requirements.txt
echo mysqlclient >> requirements.txt
mkdir -p lib
# python3 -m pip install -U --no-deps py4web -t lib/
cp -r ../../py4web lib/
mkdir -p apps
echo "" > apps/__init__.py
echo "copy the apps you want to deploy under the new app"
deploy:
gcloud config set account ${email}
gcloud config set project ${project}
Expand Down
24 changes: 14 additions & 10 deletions deployment_tools/gae/README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
# To deploy code on Google App Engine:

## Setup your deployment folder

```
cd deployment_tools/gae
mkdir my-py4web-gae
cp -r /path/to/py4web/deployment_tools/gae/* my-py4web-gae
cd my-py4web-gae
make install-gcloud-linux
make upgrade-gcloud
make setup
mkdir apps
touch apps/__init__.py
# symlink the apps that you want to deploy to GAE, for example:
cd apps
ln -s ../../../apps/_default .
ln -s ../../../apps/.service .
cd ..
# copy the apps that you want to deploy to GAE, for example:
cp -r /path/to/py4web/apps/_default apps/_default
(cp -r /path/to/py4web/apps/myapp apps/myapp)
# you may need to to symlink or copy the service folder (optional)
cp -r /path/to/py4web/apps/.service apps/
```

Then, you can either do:
## Deploy from the deployment folder

```
make deploy email={your email} project={your project} version={vesion}
```

or if you have a gcloud configuration already configured,
If you have a gcloud configuration already set you can just do

```
gcloud app deploy
Expand Down
5 changes: 3 additions & 2 deletions deployment_tools/gae/main.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import os
import site
import uuid
site.addsitedir(os.path.join(os.path.dirname(__file__), 'lib'))
from py4web.core import Reloader, bottle, Session
os.environ['PY4WEB_DASHBOARD_MODE'] = 'none'
os.environ['PY4WEB_SERVICE_DB_URI'] = 'sqlite:memory'
os.environ['PY4WEB_APPS_FOLDER'] = os.path.join(os.path.dirname(__file__), 'apps')
os.environ['PY4WEB_SERVICE_FOLDER'] = os.path.join(os.path.dirname(__file__), '.service')
Session.SECRET = open(os.path.join(os.path.dirname(__file__), '.service/session.secret'), 'rb').read()
os.environ['PY4WEB_SERVICE_FOLDER'] = os.path.join(os.path.dirname(__file__), 'apps/.service')
Session.SECRET = str(uuid.uuid4())
Reloader.import_apps()
app = bottle.default_app()
1 change: 0 additions & 1 deletion deployment_tools/gae/requirements.in

This file was deleted.

0 comments on commit 89bc8dd

Please sign in to comment.