-
Dockerを使って、以下のコマンドでFirebaseにログインします。
-
コマンド:
firebase login --no-localhost
-
注意: すでにFirebaseプロジェクトを作成しており、ログインするアカウントには権限が必要です。
-
エラー時のレポートについて(お好みで) Firebase optionally collects CLI and Emulator Suite usage and error reporting information to help improve our products. Data is collected in accordance with Google's privacy policy (https://policies.google.com/privacy) and is not used to identify you. ? Allow Firebase to collect CLI and Emulator Suite usage and error reporting information? (y/n)
To sign in to the Firebase CLI:
-
Take note of your session ID:
- session ID が表示される
-
Visit the URL below on any device and follow the instructions to get your code:
- URL が表示されるので、クリックする
- 1の session ID と同じかどうか確認し、authorization code をコピーする
-
Paste or enter the authorization code below once you have it:
- コピーした authorization code を貼り付けてEnterを押す ? Enter authorization code:
-
-
以下の手順でアクセストークンを取得し、ターミナルに貼り付けます。
- コマンド:
docker compose run --rm firebase firebase login --no-localhost
- コマンド:
- 以下のコマンドを実行してFirebaseを初期設定します。
-
コマンド:
docker compose run --rm firebase firebase init emulators
-
エミュレータは 'bin' フォルダにインストールされます。
-
-
上記の「Firebaseの初期設定」が完了していること
-
コンテナ起動
- コマンド:
docker compose up
- 起動後、ブラウザで
localhost:4000
にアクセスすると、Firebaseエミュレータの画面が表示されます。
- コマンド:
-
ログアウト
- コマンド:
docker compose run --rm firebase firebase logout
- コマンド:
-
再ログイン
- コマンド:
docker compose run --rm firebase firebase login --no-localhost
- 表示されたURLへアクセス
- step1,2 と進み、表示されたトークンをコンソールに貼り付け
- コマンド:
-
再度dockerコンテナを立ち上げ
- コマンド:
docker compose up -d
- コマンド:
- Docker
- Windows 環境の場合はいくつか注意点があるので、Windows 環境の注意点 を参照してください。
- ストレージ: 約 5GB
- メモリ: 約 4GB
.env.sample
を.env
に変更してください。
- Docker Compose で、Strapi やそれに必要なアプリ (MySQL など) を起動します。
バックグラウンドで起動したい場合は、オプション -d を付けます
docker compose up strapi
docker compose up strapi -d
- 上記を実行すると、Strapi が実行されます。
- ストレージを約 5GB 消費します。
- メモリが約 4GB 必要です。
- http://localhost:1337/admin から管理画面にアクセスできます。
- Strapi の起動には時間がかかります。バックグラウンドで動作している場合にログを確認するには以下を実行します。
docker compose logs strapi
- Strapi の起動には時間がかかります。バックグラウンドで動作している場合にログを確認するには以下を実行します。
- 以下を実行すると、Docker の全体が停止します。
docker compose down
- Docker Desktop バックエンドを WSL にすることをお勧めします。
- Settings -> General -> Use the WSL 2 based engine
- WSL 上の Linux で、Windows の Docker を操作可能
- Settings -> Resources -> Network -> Enable host networking
- Docker container で
localhost
としてホストしているアプリに、Windows からアクセスする際に必要
- Docker container で
- Settings -> General -> Use the WSL 2 based engine
- WSL の Docker (docker-desktop) が時々故障 (消滅) することがあります。
- この場合、Docker Desktop の再インストールが必要
- Windows 環境で
docker compose build
やdocker compose up --build
を実行 (特に、再ビルド時) すると、以下のようなエラーが発生することがあります。ERROR [strapi internal] load build context failed to solve: archive/tar: unknown file mode ?rwxr-xr-x
- Docker Desktop で WSL integration を有効にし、WSL 上の Linux 上から Windows の Docker を操作することで回避
- WSL から Windows の Docker Desktop を操作するには、以下の要件が必要
- WSL に docker-desktop 以外のディストリビューションがインストールされていること
- Docker Desktop の WSL integration が有効になっていること
- Settings -> Resources -> WSL integration -> Enable integration with ...
- 何か不具合が発生した場合や、ファイルの変更を確実に反映させたい場合には、以下を実行するとキャッシュを無効化して再ビルドできます。
docker compose down docker image prune -a docker compose build strapi --no-cache docker compose up strapi