Git Product home page Git Product logo

flask-docker-heroku's Introduction

Flask Docker/Heroku Sample App

Sample flask Docker Compose project with heroku deployment configuration

Getting started

Local Development

Build the image:

$ docker-compose build

Initialize the Database

Flask-Migrate and Flask-SQLAlchemy are used to manage db schema and migrations.

$ docker-compose run web_app flask db upgrade

The command may fail on the first try if the database container is slow to boot up. If it failed, simply rerun the command again. Alternatively you can use this command instead:

$ docker-compose run web_app ./wait-for-pg.sh db flask db upgrade

3. Start the dev server

$ docker-compose up

This will run the flask development web server for web_app/app.py The default runs on port 5000 by default for development. Open localhost:5000 on the browser to view the app. You can now start adding code to app.py. The flask development web server is configure to reload on code change.

Hit CTRL-C to exit.

4. Installing additional packages

Uses pipenv to manage depency versions but not for virtual environments.

$ docker-compose run web_app pipenv install [package]

We still need to rebuild the image if we installed a dependency:

$ docker-compose build

Deploying to Heroku:

1. Setup Heroku-CLI

See official Docs: https://devcenter.heroku.com/articles/heroku-cli

2. Commit your changes to Git:

If you did not clone this repo, make sure to have git initialized on the root directory (where heroku.yml lives). Commit your changes to Git.

$ git add . 
$ git commit -m "Commit message"

3. Create the heroku app and deploy:

Upgrade to heroku-cli beta and install plugin-manifest

$ heroku update beta
$ heroku plugins:install @heroku-cli/plugin-manifest

Create the heroku app

$ heroku create [your-app-name] --manifest

Deploy the app via git

$ git push heroku master

This will rebuild the docker image and deploy it to heroku. It may take while to complete the rebuild.

Open your Web App in the browser:

$ heroku open

flask-docker-heroku's People

Contributors

macr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.