0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

herokuでアプリをセッティング

Last updated at Posted at 2021-12-28

アプリケーションへの Gunicorn の追加する
まず、pip​ を使用して Gunicorn をインストールします。

(myenv)$ pip install gunicorn

Heroku Postgres をプロビジョニング
プロビジョニングとは、必要に応じてネットワークやコンピュータの設備などのリソースを提供できるよう予測し、準備しておくことです。

エラー

(myenv)$ heroku addons
bash: heroku: command not found
すでにやってたこと
PostgreSQLのインストール https://qiita.com/kyoceda/items/f6512ffdb7737bea2e29 の
(myenv) $ export DATABASE_URL=postgres://$(whoami)

まで

(myenv) ユーザー名-no-MacBook-Pro:heroku1 ユーザー名$ brew install heroku/brew/heroku
Running `brew update --preinstall`...
==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
  https://github.com/Homebrew/brew#donations
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 78 formulae.

==> Tapping heroku/brew
Cloning into '/usr/local/Homebrew/Library/Taps/heroku/homebrew-brew'...
remote: Enumerating objects: 1785, done.
remote: Counting objects: 100% (170/170), done.
remote: Compressing objects: 100% (129/129), done.
remote: Total 1785 (delta 42), reused 169 (delta 41), pack-reused 1615
Receiving objects: 100% (1785/1785), 234.61 KiB | 1.65 MiB/s, done.
Resolving deltas: 100% (438/438), done.
Tapped 2 formulae (16 files, 291.4KB).
==> Downloading https://nodejs.org/download/release/v12.21.0/node-v12.21.0-darwi
######################################################################## 100.0%
==> Downloading https://cli-assets.heroku.com/heroku-v7.59.2/heroku-v7.59.2.tar.
######################################################################## 100.0%
==> Installing heroku from heroku/brew
==> Installing dependencies for heroku/brew/heroku: heroku/brew/heroku-node
==> Installing heroku/brew/heroku dependency: heroku/brew/heroku-node
🍺  /usr/local/Cellar/heroku-node/12.21.0: 6 files, 45.4MB, built in 13 seconds
==> Installing heroku/brew/heroku
==> Caveats
To use the Heroku CLI's autocomplete --
  Via homebrew's shell completion:
    1) Follow homebrew's install instructions https://docs.brew.sh/Shell-Completion
        NOTE: For zsh, as the instructions mention, be sure compinit is autoloaded
              and called, either explicitly or via a framework like oh-my-zsh.
    2) Then run
      $ heroku autocomplete --refresh-cache
  OR
  Use our standalone setup:
    1) Run and follow the install steps:
      $ heroku autocomplete

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
🍺  /usr/local/Cellar/heroku/7.59.2: 28,792 files, 63.0MB, built in 57 seconds
==> Running `brew cleanup heroku`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> heroku
To use the Heroku CLI's autocomplete --
  Via homebrew's shell completion:
    1) Follow homebrew's install instructions https://docs.brew.sh/Shell-Completion
        NOTE: For zsh, as the instructions mention, be sure compinit is autoloaded
              and called, either explicitly or via a framework like oh-my-zsh.
    2) Then run
      $ heroku autocomplete --refresh-cache
  OR
  Use our standalone setup:
    1) Run and follow the install steps:
      $ heroku autocomplete

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

heroku addon

$ heroku addons ›   Warning: Our terms of service have changed: 
 ›   https://dashboard.heroku.com/terms-of-service
 ▸    Invalid credentials provided.
heroku: Press any key to open up the browser to login or q to exit: 
Opening browser to https://cli-auth.heroku.com/auth/cli/browser/5f7fe823-72ca-48b2-8148-96f192b8102b?requestor=SFMyNTY.g2gDbQAAAA4xMTguMjM3LjE5OC4zNG4GANjUnwF-AWIAAVGA.Gj_l1UzPwYeyUGJd0Oj9oz6e1fXCtRBuj3t4KHJzFkc
Logging in... done
Logged in as hoge@gmail.com
Owning App  Add-on                     Plan                         Price  State  
──────────  ─────────────────────────  ───────────────────────────  ─────  ───────
サイト名    postgresql-parallel-5桁  heroku-postgresql:hobby-dev  free   created

pythonの現在の依存関係をチェック

$ pip list
Package            Version
------------------ -------
asgiref            3.4.1
backports.zoneinfo 0.2.1
Django             4.0
gunicorn           20.1.0
pip                21.3.1
setuptools         49.2.1
sqlparse           0.4.2

Python に期待されるファイル
requirements.txt
setup.py
Pipfile
上述のいずれかの​ファイルがアプリのルートディレクトリにある場合、Heroku はそのアプリを Python アプリとして自動的に識別します。

fileの中身を真似た
https://github.com/heroku/python-getting-started

requirements.txt
django
gunicorn
django-heroku

Pipfile.
django
gunicorn
django-heroku

すでにサイトのベースはあった。

サイト更新

$ git add .
fatal: not a git repository (or any of the parent directories): .git

$ git commit -am ""
$ git push origin master


上手く行かない時 git push origin master
git initでうまくいった

$ git push origin master
fatal: not a git repository (or any of the parent directories): .git
(myenv) ユーザー名-no-MacBook-Pro:heroku1 ユーザー名$ git init
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m
Initialized empty Git repository in /Users/ユーザー名/Projects/heroku1/.git/
(myenv) ユーザー名-no-MacBook-Pro:heroku1 ユーザー名$ git add .
(myenv) ユーザー名-no-MacBook-Pro:heroku1 ユーザー名$


git commitがうまくいかなかった。

エラーで直したこと
runtime.txtの追加
runtime.txt内のpython versionの修正

heroku config:set DISABLE_COLLECTSTATIC=1

にした。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?