Help us understand the problem. What is going on with this article?

herokuにFlaskアプリをデプロイする

More than 3 years have passed since last update.

heroku: すごく簡単に使えるPaaS

以前にAWSのEC2にデプロイしたDeep Learning アプリを herokuにデプロイしてみる。

EC2はIaaSのため、ミドルウェアのインストールや設定など色々と必要だったが、PaaSのHerokuなら同じことがterminalに数行でできちゃう。

準備:herokuの登録とツールのインストール

1.公式ページで登録する

2.CLIツールをインストール

mac
$ brew install heroku
ubuntu
$ sudo apt-get install software-properties-common # debian only
$ sudo add-apt-repository "deb https://cli-assets.heroku.com/branches/stable/apt ./"
$ curl -L https://cli-assets.heroku.com/apt/release.key | sudo apt-key add -
$ sudo apt-get update
$ sudo apt-get install heroku

3.ログインする

$ heroku login

Enter your Heroku credentials:
Email: <your-email>
Password: ********
Logged in as <your-email>

pythonアプリをデプロイ

ローカルレポジトリを作成

$ mkdir heroku-app
$ cd heroku-app
$ pyenv virtualenv 3.6.0 heroku_keras_3.6.0
$ pyenv local heroku_keras_3.6.0
$ echo .python-version >> .gitignore
$ git init

requirements.txtに 依存ライブラリを記述

$ pip install tensorflow keras flask h5py
$ pip install gunicorn # web app. server
$ pip freeze > requirements.txt

runtime.txtに pythonのバージョンを指定

$ echo python-3.6.0 > runtime.txt

Procfileに webアプリの起動方法を指定

$ echo web: gunicorn app:app --log-file=- > Procfile

heroku にデプロイ

#$ heroku local web

$ heroku create <app-name>
$ heroku buildpacks:set heroku/python

$ git add -A
$ git commit -m "deploy heroku"
$ git push heroku master
$ heroku ps:scale web=1
$ heroku open

アプリ:https://msrks-numpred.herokuapp.com

msrks
Computer Scienceと物理が好きです
http://msrks.github.io
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした