こんにちは、JS2IIUです。今回もPanelの活用方法について記事を書きました。この記事でちょっとPanel使ってみよう、という人が増えるといいなと思います!
はじめに
作成したPanelアプリケーションを実際にデプロイ(展開)することで、多くのユーザーがアクセスできるWebアプリケーションとして活用することができます。今回は、HerokuやAWS、DigitalOceanといったプラットフォームを用いてPanelアプリをデプロイする方法を解説します。また、SSL証明書の設定など、セキュアなウェブアプリケーションとして運用するための手順も紹介します。
ローカル開発環境の確認
まずは、ローカル環境で作成したPanelアプリケーションを確認します。以下のサンプルコードを実行して、ローカル環境で動作するかを確認しましょう。
import panel as pn
pn.extension()
# シンプルなPanelアプリケーション
def app():
return pn.Column("### My Panel App", pn.widgets.Button(name="Click Me"))
# サーバーとして起動
app().servable()
pn.serve(app)
pn.extension()でPanelの拡張機能をロードします。pn.Column()を使って、シンプルなアプリケーションを作成しています。ここでは「Click Me」ボタンを含むシンプルなレイアウトです。app().servable()は、このアプリをPanelのWebサーバーとして起動する準備をします。pn.serve()を呼び出すことで、ローカルホスト上にサーバーが立ち上がります。ローカル環境でアプリが正常に動作することを確認しましょう。コンソールにはこのように表示されて、サーバが立ち上がったことがわかります。
Launching server at http://localhost:52401

Herokuへのデプロイ
Herokuは、アプリケーションをクラウド上で簡単にデプロイできるプラットフォームです。次に、PanelアプリをHerokuにデプロイする手順を見ていきましょう。なお、以降の記事ではHerokuのユーザー登録が完了している状態であるとします。

手順1: Heroku CLIのインストール
まず、HerokuのCLI(コマンドラインインターフェース)をインストールします。以下のコマンドを実行してインストールします。
curl https://cli-assets.heroku.com/install.sh | sh
MacのApple Siliconだとエラーが出てしまいます。unsupported arch: arm64
brewからインストールすることが可能です。以下の記事を参考にインストールしてみて下さい。記事を要約すると、
brew tap heroku/brew && brew install heroku
少し時間がかかりますが、以下のとおり、インストールできました。
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> New Formulae
bc-gh dra grizzly libblastrampoline rpcsvc-proto
bed fatal immich-cli oasdiff wush
bump-my-version fierce ktor pyupgrade
==> New Casks
blood-on-the-clocktower-online font-departure-mono parallels@19
choice-financial-terminal font-ibm-plex-math rize
crosspaste font-ibm-plex-sans-tc wealthfolio
dfcf font-scientifica zen-browser
flutterflow gitlight
You have 4 outdated formulae installed.
==> Tapping heroku/brew
Cloning into '/opt/homebrew/Library/Taps/heroku/homebrew-brew'...
remote: Enumerating objects: 1979, done.
remote: Counting objects: 100% (364/364), done.
remote: Compressing objects: 100% (236/236), done.
remote: Total 1979 (delta 122), reused 354 (delta 115), pack-reused 1615 (from 1)
Receiving objects: 100% (1979/1979), 268.07 KiB | 775.00 KiB/s, done.
Resolving deltas: 100% (518/518), done.
Tapped 2 formulae (22 files, 348.5KB).
==> Fetching heroku/brew/heroku
==> Downloading https://cli-assets.heroku.com/versions/9.2.1/6e4f307/heroku-v9.2.1-6e4f307-darwin-arm64.tar.xz
################################################################################################################## 100.0%
==> Installing heroku from heroku/brew
==> 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
zsh completions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Summary
🍺 /opt/homebrew/Cellar/heroku/9.2.1: 23,266 files, 161.5MB, built in 19 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`).

手順2: Gitリポジトリの初期化
次に、作成したPanelアプリケーションをGitリポジトリに追加します。オンラインのGitHubではなく、ローカルのGitリポジトリを作成します。ちょっとわかりにくいところですが、手元のPCのプログラムを作っているフォルダで以下の操作を行います。
git init
git add .
git commit -m "Initial commit"
手順3: requirements.txtの作成
Herokuは、アプリケーションに必要なPythonパッケージをrequirements.txtからインストールします。以下のコマンドで、現在の環境にインストールされているパッケージをrequirements.txtとして保存します。
pip freeze > requirements.txt
手順4: Procfileの作成
Procfileは、Herokuにアプリケーションをどのように起動するかを伝えるためのファイルです。Procfileを作成し、以下の内容を記述します。ProcfileはGitリポジトリのルートにおきます。
web: panel serve --port=$PORT --address=0.0.0.0 app.py
panel serveコマンドは、Heroku上でPanelアプリを起動します。--port=$PORTは、Herokuが自動的に割り当てるポートでアプリを起動する設定です。app.pyは、デプロイするPanelアプリケーションのファイル名です。ここで適宜自分のアプリ名に変更してください。
手順5: Herokuにデプロイ
Herokuにログインし、アプリを作成してデプロイします。
heroku login
heroku create my-panel-app
git push heroku master
これで、Heroku上にPanelアプリがデプロイされ、公開URLが生成されます。ブラウザでそのURLにアクセスし、アプリが動作することを確認しましょう。
$ heroku login
ステップバイステップで手順を見ていきます。一部黒塗りにしています。最初はログインです。途中でWebブラウザが開きます。そのままログインボタンをクリックして下さい。
% heroku login
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/*********-c863-4eee-ad5d-73831*******eb?requestor=SFMyNTY.g2gDbQAAAAwxNC4xMS42Ni4yMjVu*****7rkQFiAAFRgA.fNdR_WyM********De0oOUuNSM9huRQEBWr********
Logging in... done
Logged in as *****@*******.com
$ heroku create my-panel-app
% heroku create my-panel-app
Creating ⬢ my-panel-app... done

No such app | https://git.heroku.com/my-panel-app.git
こちらのhttps://my-panel-app-35a40927d***.herokuapp.com/をメモしておきましょう。
HEROKUに支払い情報を登録していないとここでエラーが出ます。以下、エラーの例:
Creating ⬢ my-panel-app... !
› Error: To create an app, verify your account by adding payment information. Verify now at
› https://heroku.com/verify Learn more at
› https://devcenter.heroku.com/articles/account-verification
›
› Error ID: verification_required
この段階でリンク(https://my-panel-app-35a40927d***.herokuapp.com/)にアクセスするとこのような表示が出ます。

$ git push heroku main
このコマンドのmainの部分は、gitのブランチ名を入れて下さい。masterかmainだと思います。成功すればデプロイ完了です。使い回しのvenv環境のrequirements.txtを使ったので酷いことになってしまいました・・・・
% git push heroku main
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 1.02 KiB | 1.02 MiB/s, done.
Total 6 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Updated 3 paths from e4303e7
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-22 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Python app detected
remote: -----> No Python version was specified. Using the buildpack default: python-3.12.6
remote: To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.12.6
remote: -----> Installing pip 24.0, setuptools 70.3.0 and wheel 0.44.0
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: Collecting bleach==6.1.0 (from -r requirements.txt (line 1))
remote: Downloading bleach-6.1.0-py3-none-any.whl.metadata (30 kB)
remote: Collecting bokeh==3.4.3 (from -r requirements.txt (line 2))
remote: Downloading bokeh-3.4.3-py3-none-any.whl.metadata (12 kB)
remote: Collecting certifi==2024.8.30 (from -r requirements.txt (line 3))
remote: Downloading certifi-2024.8.30-py3-none-any.whl.metadata (2.2 kB)
remote: Collecting charset-normalizer==3.3.2 (from -r requirements.txt (line 4))
remote: Downloading charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (33 kB)
remote: Collecting colorcet==3.1.0 (from -r requirements.txt (line 5))
remote: Downloading colorcet-3.1.0-py3-none-any.whl.metadata (6.3 kB)
remote: Collecting contourpy==1.3.0 (from -r requirements.txt (line 6))
remote: Downloading contourpy-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (5.4 kB)
remote: Collecting cycler==0.12.1 (from -r requirements.txt (line 7))
remote: Downloading cycler-0.12.1-py3-none-any.whl.metadata (3.8 kB)
remote: Collecting fonttools==4.53.1 (from -r requirements.txt (line 8))
remote: Downloading fonttools-4.53.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (162 kB)
remote: Collecting holoviews==1.19.1 (from -r requirements.txt (line 9))
remote: Downloading holoviews-1.19.1-py3-none-any.whl.metadata (9.8 kB)
remote: Collecting idna==3.8 (from -r requirements.txt (line 10))
remote: Downloading idna-3.8-py3-none-any.whl.metadata (9.9 kB)
remote: Collecting Jinja2==3.1.4 (from -r requirements.txt (line 11))
remote: Downloading jinja2-3.1.4-py3-none-any.whl.metadata (2.6 kB)
remote: Collecting kiwisolver==1.4.7 (from -r requirements.txt (line 12))
remote: Downloading kiwisolver-1.4.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (6.3 kB)
remote: Collecting linkify-it-py==2.0.3 (from -r requirements.txt (line 13))
remote: Downloading linkify_it_py-2.0.3-py3-none-any.whl.metadata (8.5 kB)
remote: Collecting Markdown==3.7 (from -r requirements.txt (line 14))
remote: Downloading Markdown-3.7-py3-none-any.whl.metadata (7.0 kB)
remote: Collecting markdown-it-py==3.0.0 (from -r requirements.txt (line 15))
remote: Downloading markdown_it_py-3.0.0-py3-none-any.whl.metadata (6.9 kB)
remote: Collecting MarkupSafe==2.1.5 (from -r requirements.txt (line 16))
remote: Downloading MarkupSafe-2.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (3.0 kB)
remote: Collecting matplotlib==3.9.2 (from -r requirements.txt (line 17))
remote: Downloading matplotlib-3.9.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (11 kB)
remote: Collecting mdit-py-plugins==0.4.1 (from -r requirements.txt (line 18))
remote: Downloading mdit_py_plugins-0.4.1-py3-none-any.whl.metadata (2.8 kB)
remote: Collecting mdurl==0.1.2 (from -r requirements.txt (line 19))
remote: Downloading mdurl-0.1.2-py3-none-any.whl.metadata (1.6 kB)
remote: Collecting numpy==2.1.1 (from -r requirements.txt (line 20))
remote: Downloading numpy-2.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB)
remote: Collecting packaging==24.1 (from -r requirements.txt (line 21))
remote: Downloading packaging-24.1-py3-none-any.whl.metadata (3.2 kB)
remote: Collecting pandas==2.2.2 (from -r requirements.txt (line 22))
remote: Downloading pandas-2.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (19 kB)
remote: Collecting panel==1.4.5 (from -r requirements.txt (line 23))
remote: Downloading panel-1.4.5-py3-none-any.whl.metadata (25 kB)
remote: Collecting param==2.1.1 (from -r requirements.txt (line 24))
remote: Downloading param-2.1.1-py3-none-any.whl.metadata (7.2 kB)
remote: Collecting pillow==10.4.0 (from -r requirements.txt (line 25))
remote: Downloading pillow-10.4.0-cp312-cp312-manylinux_2_28_x86_64.whl.metadata (9.2 kB)
remote: Collecting plotly==5.24.0 (from -r requirements.txt (line 26))
remote: Downloading plotly-5.24.0-py3-none-any.whl.metadata (7.3 kB)
remote: Collecting pyparsing==3.1.4 (from -r requirements.txt (line 27))
remote: Downloading pyparsing-3.1.4-py3-none-any.whl.metadata (5.1 kB)
remote: Collecting python-dateutil==2.9.0.post0 (from -r requirements.txt (line 28))
remote: Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl.metadata (8.4 kB)
remote: Collecting pytz==2024.1 (from -r requirements.txt (line 29))
remote: Downloading pytz-2024.1-py2.py3-none-any.whl.metadata (22 kB)
remote: Collecting pyviz_comms==3.0.3 (from -r requirements.txt (line 30))
remote: Downloading pyviz_comms-3.0.3-py3-none-any.whl.metadata (7.7 kB)
remote: Collecting PyYAML==6.0.2 (from -r requirements.txt (line 31))
remote: Downloading PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.1 kB)
remote: Collecting requests==2.32.3 (from -r requirements.txt (line 32))
remote: Downloading requests-2.32.3-py3-none-any.whl.metadata (4.6 kB)
remote: Collecting six==1.16.0 (from -r requirements.txt (line 33))
remote: Downloading six-1.16.0-py2.py3-none-any.whl.metadata (1.8 kB)
remote: Collecting tenacity==9.0.0 (from -r requirements.txt (line 34))
remote: Downloading tenacity-9.0.0-py3-none-any.whl.metadata (1.2 kB)
remote: Collecting tornado==6.4.1 (from -r requirements.txt (line 35))
remote: Downloading tornado-6.4.1-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (2.5 kB)
remote: Collecting tqdm==4.66.5 (from -r requirements.txt (line 36))
remote: Downloading tqdm-4.66.5-py3-none-any.whl.metadata (57 kB)
remote: Collecting typing_extensions==4.12.2 (from -r requirements.txt (line 37))
remote: Downloading typing_extensions-4.12.2-py3-none-any.whl.metadata (3.0 kB)
remote: Collecting tzdata==2024.1 (from -r requirements.txt (line 38))
remote: Downloading tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB)
remote: Collecting uc-micro-py==1.0.3 (from -r requirements.txt (line 39))
remote: Downloading uc_micro_py-1.0.3-py3-none-any.whl.metadata (2.0 kB)
remote: Collecting urllib3==2.2.2 (from -r requirements.txt (line 40))
remote: Downloading urllib3-2.2.2-py3-none-any.whl.metadata (6.4 kB)
remote: Collecting webencodings==0.5.1 (from -r requirements.txt (line 41))
remote: Downloading webencodings-0.5.1-py2.py3-none-any.whl.metadata (2.1 kB)
remote: Collecting xyzservices==2024.9.0 (from -r requirements.txt (line 42))
remote: Downloading xyzservices-2024.9.0-py3-none-any.whl.metadata (4.1 kB)
remote: Downloading bleach-6.1.0-py3-none-any.whl (162 kB)
remote: Downloading bokeh-3.4.3-py3-none-any.whl (7.0 MB)
remote: Downloading certifi-2024.8.30-py3-none-any.whl (167 kB)
remote: Downloading charset_normalizer-3.3.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (141 kB)
remote: Downloading colorcet-3.1.0-py3-none-any.whl (260 kB)
remote: Downloading contourpy-1.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (320 kB)
remote: Downloading cycler-0.12.1-py3-none-any.whl (8.3 kB)
remote: Downloading fonttools-4.53.1-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.9 MB)
remote: Downloading holoviews-1.19.1-py3-none-any.whl (5.0 MB)
remote: Downloading idna-3.8-py3-none-any.whl (66 kB)
remote: Downloading jinja2-3.1.4-py3-none-any.whl (133 kB)
remote: Downloading kiwisolver-1.4.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB)
remote: Downloading linkify_it_py-2.0.3-py3-none-any.whl (19 kB)
remote: Downloading Markdown-3.7-py3-none-any.whl (106 kB)
remote: Downloading markdown_it_py-3.0.0-py3-none-any.whl (87 kB)
remote: Downloading MarkupSafe-2.1.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (28 kB)
remote: Downloading matplotlib-3.9.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.3 MB)
remote: Downloading mdit_py_plugins-0.4.1-py3-none-any.whl (54 kB)
remote: Downloading mdurl-0.1.2-py3-none-any.whl (10.0 kB)
remote: Downloading numpy-2.1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.0 MB)
remote: Downloading packaging-24.1-py3-none-any.whl (53 kB)
remote: Downloading pandas-2.2.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (12.7 MB)
remote: Downloading panel-1.4.5-py3-none-any.whl (24.7 MB)
remote: Downloading param-2.1.1-py3-none-any.whl (116 kB)
remote: Downloading pillow-10.4.0-cp312-cp312-manylinux_2_28_x86_64.whl (4.5 MB)
remote: Downloading plotly-5.24.0-py3-none-any.whl (19.0 MB)
remote: Downloading pyparsing-3.1.4-py3-none-any.whl (104 kB)
remote: Downloading python_dateutil-2.9.0.post0-py2.py3-none-any.whl (229 kB)
remote: Downloading pytz-2024.1-py2.py3-none-any.whl (505 kB)
remote: Downloading pyviz_comms-3.0.3-py3-none-any.whl (83 kB)
remote: Downloading PyYAML-6.0.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (767 kB)
remote: Downloading requests-2.32.3-py3-none-any.whl (64 kB)
remote: Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
remote: Downloading tenacity-9.0.0-py3-none-any.whl (28 kB)
remote: Downloading tornado-6.4.1-cp38-abi3-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (436 kB)
remote: Downloading tqdm-4.66.5-py3-none-any.whl (78 kB)
remote: Downloading typing_extensions-4.12.2-py3-none-any.whl (37 kB)
remote: Downloading tzdata-2024.1-py2.py3-none-any.whl (345 kB)
remote: Downloading uc_micro_py-1.0.3-py3-none-any.whl (6.2 kB)
remote: Downloading urllib3-2.2.2-py3-none-any.whl (121 kB)
remote: Downloading webencodings-0.5.1-py2.py3-none-any.whl (11 kB)
remote: Downloading xyzservices-2024.9.0-py3-none-any.whl (85 kB)
remote: Installing collected packages: webencodings, pytz, xyzservices, urllib3, uc-micro-py, tzdata, typing_extensions, tqdm, tornado, tenacity, six, PyYAML, pyparsing, pillow, param, packaging, numpy, mdurl, MarkupSafe, Markdown, kiwisolver, idna, fonttools, cycler, colorcet, charset-normalizer, certifi, requests, pyviz_comms, python-dateutil, plotly, markdown-it-py, linkify-it-py, Jinja2, contourpy, bleach, pandas, mdit-py-plugins, matplotlib, bokeh, panel, holoviews
remote: Successfully installed Jinja2-3.1.4 Markdown-3.7 MarkupSafe-2.1.5 PyYAML-6.0.2 bleach-6.1.0 bokeh-3.4.3 certifi-2024.8.30 charset-normalizer-3.3.2 colorcet-3.1.0 contourpy-1.3.0 cycler-0.12.1 fonttools-4.53.1 holoviews-1.19.1 idna-3.8 kiwisolver-1.4.7 linkify-it-py-2.0.3 markdown-it-py-3.0.0 matplotlib-3.9.2 mdit-py-plugins-0.4.1 mdurl-0.1.2 numpy-2.1.1 packaging-24.1 pandas-2.2.2 panel-1.4.5 param-2.1.1 pillow-10.4.0 plotly-5.24.0 pyparsing-3.1.4 python-dateutil-2.9.0.post0 pytz-2024.1 pyviz_comms-3.0.3 requests-2.32.3 six-1.16.0 tenacity-9.0.0 tornado-6.4.1 tqdm-4.66.5 typing_extensions-4.12.2 tzdata-2024.1 uc-micro-py-1.0.3 urllib3-2.2.2 webencodings-0.5.1 xyzservices-2024.9.0
remote: -----> Discovering process types
remote: Procfile declares types -> web
remote:
remote: -----> Compressing...
remote: Done: 151.3M
remote: -----> Launching...
remote: Released v3
remote: https://my-panel-app-35a40927d73b.herokuapp.com/ deployed to Heroku
remote:
remote: This app is using the Heroku-22 stack, however a newer stack is available.
remote: To upgrade to Heroku-24, see:
remote: https://devcenter.heroku.com/articles/upgrading-to-the-latest-stack
remote:
remote: Verifying deploy... done.
To https://git.heroku.com/my-panel-app.git
* [new branch] main -> main
このコマンドを実行した際のエラーの例です。
% git push heroku main
remote: ! Heroku does not support Git client version git/2.39.3 (Apple Git-146).
remote: ! Please upgrade to the latest Git version.
remote: ! For more information, please see https://help.heroku.com/GJ1XRFT5/fatal-error-pushing-to-heroku-on-macos-with-git-2-39-3-apple-git-146
fatal: unable to access 'https://git.heroku.com/my-panel-app.git/': The requested URL returned error: 400
上記のエラーが出た場合は、Gitのバージョンが古いので、こちらのGit本家ページを参考にGitのアップデートを行なって下さい。Macの人は出る可能性が高いです。
% brew install git
==> Downloading https://formulae.brew.sh/api/formula.jws.json
################################################################################################# 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
################################################################################################# 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/git/manifests/2.46.0
################################################################################################# 100.0%
==> Fetching dependencies for git: pcre2
==> Downloading https://ghcr.io/v2/homebrew/core/pcre2/manifests/10.44
################################################################################################# 100.0%
==> Fetching pcre2
==> Downloading https://ghcr.io/v2/homebrew/core/pcre2/blobs/sha256:78fe8885f70cc1ec83eefd678e1dfc3b341a
################################################################################################# 100.0%
==> Fetching git
==> Downloading https://ghcr.io/v2/homebrew/core/git/blobs/sha256:5c7ecbe7bcaf95fa6ef3766d97045754d9f56c
################################################################################################# 100.0%
==> Installing dependencies for git: pcre2
==> Installing git dependency: pcre2
==> Downloading https://ghcr.io/v2/homebrew/core/pcre2/manifests/10.44
Already downloaded: /Users/makoto/Library/Caches/Homebrew/downloads/22ed791461c5bf400adde8c3b432c1230866aa1db3c5cb81e06a6ff21cac96ee--pcre2-10.44.bottle_manifest.json
==> Pouring pcre2--10.44.arm64_sonoma.bottle.tar.gz
🍺 /opt/homebrew/Cellar/pcre2/10.44: 237 files, 6.3MB
==> Installing git
==> Pouring git--2.46.0.arm64_sonoma.bottle.tar.gz
==> Caveats
The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula.
Subversion interoperability (git-svn) is now in the `git-svn` formula.
zsh completions and functions have been installed to:
/opt/homebrew/share/zsh/site-functions
==> Summary
🍺 /opt/homebrew/Cellar/git/2.46.0: 1,678 files, 51.5MB
==> Running `brew cleanup git`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> git
The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula.
Subversion interoperability (git-svn) is now in the `git-svn` formula.
zsh completions and functions have been installed to:
/opt/homebrew/share/zsh/site-functions
ソースコードに問題があればこちらの画面が表示されます。

ソースコードを見直し、 $ git commit してから $ git push heroku main
AWSへのデプロイ
Amazon Web Services (AWS)は、信頼性の高いクラウドプラットフォームです。AWS Elastic Beanstalkを使用すると、簡単にPanelアプリケーションをデプロイできます。
手順1: Elastic Beanstalk CLIのインストール
Elastic Beanstalk CLIをインストールします。
pip install awsebcli
手順2: AWSアカウントの設定
AWSアカウントを作成し、CLIを設定します。
aws configure
AWSのアクセスキーやリージョンなどを設定するプロンプトが表示されるので、アカウント情報を入力してください。
手順3: Elastic Beanstalkのセットアップ
Elastic Beanstalkの環境を初期化します。
eb init -p python-3.8 my-panel-app
eb create my-panel-env
eb initはプロジェクトをElastic Beanstalk環境に初期化します。eb createは実際のアプリケーション環境を作成し、デプロイを開始します。
手順4: アプリケーションのデプロイ
アプリケーションをAWSにデプロイします。
eb deploy
デプロイが完了すると、Elastic Beanstalkが提供するURLでPanelアプリケーションが公開されます。
SSL証明書の設定
アプリケーションをセキュアに運用するためには、SSL証明書を設定する必要があります。HerokuやAWSでは、無料でSSL証明書を簡単に設定できます。
Herokuの場合
Herokuでは、カスタムドメインを設定した場合、無料でSSL証明書を自動的に提供してくれます。
heroku certs:auto:enable
このコマンドを実行するだけで、HerokuがSSL証明書を自動的に設定し、HTTPSアクセスが可能になります。
AWSの場合
AWSでは、AWS Certificate Manager (ACM) を使って無料のSSL証明書を取得し、Elastic Beanstalkで使うことができます。以下の手順で設定します。
- AWSマネジメントコンソールにアクセスし、Certificate Managerに移動します。
- 新しい証明書をリクエストし、ドメイン名を指定します。
- 証明書が発行されたら、Elastic BeanstalkのロードバランサーにSSL証明書をアタッチします。
まとめ
PanelアプリケーションをHerokuやAWSにデプロイすることで、クラウド上でアプリを公開し、他のユーザーと共有することができます。また、SSL証明書を設定することで、セキュアなWebアプリケーションとして運用可能です。今回紹介した手順を参考に、ぜひ自分のPanelアプリをデプロイしてみてください。
次回は、ライブデータによるダッシュボードの構築について解説します。お楽しみに!


コメント