TORIFUKUKaiou/temperature_and_humidity_nervesでNervesデバイス(Raspberry Pi)から打ち上がってくる温湿度値の値をグラフ表示するPhoenix Webアプリ. うねうねしてます.Dockerでイゴかせます.
macOS CatalinaとDocker Desktopで動作を確かめてみます.
Ubuntuでも動くはずですが,その場合は docker compose
-> sudo docker-compose
に読み替えてください.
- .envファイルを用意する
EMAIL
はご自身のものでVIRTUAL_HOST
は,localhostではなくIP直打ちにしてください(NervesからIP指定でpostするため)
$ cp .env.sample .env $ vim .env $ cat .env [email protected] VIRTUAL_HOST=192.168.1.2
- Docker内でPhoenixを立ち上げる
$ docker compose config $ docker compose up
- Webブラウザでアクセス! http://192.168.1.2
- TORIFUKUKaiou/temperature_and_humidity_nervesから飛んできた温度がうねうねしていることを確認する http://192.168.1.2/temperature-chart
Microsoft AzureにUbuntuイメージのVMを立ち上げて展開する場合です.所定のVM利用料が発生しますので,自己責任で行ってください(参考:料金 - Linux Virtual Machines | Microsoft Azure
2021年11月30日までは,下記を公開しています.単純にクラウドに打ち上げたい用途でしたらご利用ください.ただしセキュリティ対策はきちんと設定していませんので,自己責任でご利用ください.
https://nervesjp-dsf2021.japaneast.cloudapp.azure.com/
- Virtual Machinesを作成
- サブスクリプションや仮想マシン名などはご自身の設定で
- イメージは "Ubuntu Server 20.04 LTS - Gen2"
- サイズは "Standard_B1s" で十分です
- OSディスクの種類は "Standard SSD" で十分です
- その他の設定はデフォルト
- ネットワークの設定
- 仮想マシンの左メニューバー「ネットワーク」を選択
- 受信ポートの規則:HTTP, HTTPSを追加する
- 送信ポートの規則:HTTP, HTTPSを追加する
- 仮想マシンのメニューの「DNS名」を選択
- 「IPアドレスの割り当て」を "静的" に変更
- 「DNS名ラベル」をお好きなものに設定(例: "nervesjp-dsf2021")
- 仮想マシンを再起動する
- 仮想マシンの左メニューバー「ネットワーク」を選択
- sshログインしていろいろ設定する
$ cp ~/Download/<your_key>_key.pem ~/.ssh/ $ chmod 400 ~/.ssh/<your_key>_key.pem $ ssh -i ~/.ssh/<your_key>_key.pem azureuser@<your_domain>.japaneast.cloudapp.azure.com
$ sudo fallocate -l 1G /swapfile $ sudo chmod 600 /swapfile $ sudo mkswap /swapfile $ sudo swapon /swapfile $ sudo swapon --show NAME TYPE SIZE USED PRIO /swapfile file 1024M 0B -2 $ sudo cp /etc/fstab /etc/fstab.bak $ echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
- Docker Engine on Ubuntuをインストールする(ry
docker-compose
をインストールする
$ sudo apt-get install docker-compose
$ git clone https://github.com/TORIFUKUKaiou/hello_iot_cloud.git
### .envファイルの用意
$ cp .env.sample .env
$ vim .env
$ cat .env
[email protected]
VIRTUAL_HOST=<your_domain>.japaneast.cloudapp.azure.com
### WebアプリケーションのRun
sudo docker-compose config
sudo docker-compose up -d
あとはTORIFUKUKaiou/temperature_and_humidity_nervesから飛んできたうねうねをお楽しみください 🚀
https://<your_domain>.japaneast.cloudapp.azure.com/temperature-chart
To start your Phoenix server:
- Install dependencies with
mix deps.get
- Create and migrate your database with
mix ecto.setup
- Install Node.js dependencies with
npm install
inside theassets
directory - Start Phoenix endpoint with
mix phx.server
Now you can visit localhost:4000
from your browser.
Ready to run in production? Please check our deployment guides.
- Official website: https://www.phoenixframework.org/
- Guides: https://hexdocs.pm/phoenix/overview.html
- Docs: https://hexdocs.pm/phoenix
- Forum: https://elixirforum.com/c/phoenix-forum
- Source: https://github.com/phoenixframework/phoenix