Learn to Code via Tutorials on Repl.it!

← Back to all posts
Workflow for repl.it to Google App Engine
h
busymichael

Hi All -- I have been experimenting with using repl.it to be the sole IDE for my next python/flask web app.

Normally, I develop locally using the google app engine SDK and deploy to either the GAE flex or standard environment.

But to use repl.it, I needed a way to create a workflow that allowed me to develop and test on repl.it and then easily deploy to GAE.

I found that by using repl.it built in repository features, combined with GAE's triggers to auto-build/deploy when a GitHub branch was updated, I was able to make an easy workflow.

how

  1. In repl.it, link your code to a GitHub repository. Just start your project and link it to your GitHub account at https://repl.it/github

  2. In your main.py file, be sure to wrap your app.run in an 'if name == 'main':
    app.run('0.0.0.0', 8080, debug=True)'
    statement. This will allow GAE to recognize when to run gunicorn and not try to start the built in flask webserver. https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/standard_python3/hello_world/main.py

  3. When you develop on repl.it, make sure you are checked into a branch that is NOT master. Never code on master. What we are going to do is setup a google cloud build trigger to deploy MASTER to your live app whenever it detects a change to MASTER. Alternatively, you could create a branch called 'only merge to this branch to deploy' that you would only use when ready to deploy.

  4. Setup a google cloud build trigger as described here: https://cloud.google.com/cloud-build/docs/automating-builds/create-manage-triggers

This will automatically deploy your MASTER branch to your GAE app whenever MASTER is updated.

workflow

Once this is all done, your workflow will be something like this:
1. code and test on repl.it (using a separate git branch)
2. When you are ready to deploy, git commit then goto github to and merge your sub branch to master.
3. The merge to master will automatically trigger a cloud build on GAE and pull your master over to GAE.

gotchas

  1. If you are starting with a blank GAE project, you will still need to do a 'gcloud app create' once to initialize your project over in GAE. You can do it from the cloud terminal.
  2. be careful on what libraries you are using. repl.it doesn't support all of the gae sdk and vice versa.

conclusion

I hope some find this helpful!

Voters
MatthewParry3
datadesigns
hoverdoge
programmeruser
DynamicSquid
busymichael
Comments
hotnewtop
busymichael

One more thought: once I build my unit tests, I can setup continuous integration using a github action to automatically merge my development branches into Master if all tests are passing.