Herokuで動かしているStrapiをRaspberry Piに移行するプロジェクト。
前回 → 【Strapi on Raspberry Pi】Raspberry Pi セットアップ (5)
今回はStrapi本体をデプロイする。
環境変数
Strapiで必要な環境変数は以下の通り。
HOST=0.0.0.0
PORT=1337
APP_KEYS="toBeModified1,toBeModified2"
API_TOKEN_SALT=tobemodified
ADMIN_JWT_SECRET=tobemodified
TRANSFER_TOKEN_SALT=tobemodified
JWT_SECRET=tobemodified
基本的にはHerokuで使っていた環境変数をそのまま移行した。
TRANSFER_TOKEN_SALTはHerokuでも使っていなかった。調べてみるとstrapi transferで使う変数のようだ。使う事はなさそうだがとりあえずセットはしておいた。
HOST IPはhostname -Iで取得した。
デプロイ
Dockerのデプロイを行う。
$ docker compose -f deploy/compose.prod.yml build
$ docker compose -f deploy/compose.prod.yml up -d
ログを確認。
$ docker compose -f deploy/compose.prod.yml logs -f app
noura-release-note-strapi-app |
noura-release-note-strapi-app | > [email protected] start
noura-release-note-strapi-app | > strapi start
noura-release-note-strapi-app |
noura-release-note-strapi-app | [2026-03-18 22:53:33.373] warn: admin.auth.options.expiresIn is deprecated and will be removed in Strapi 6. Please configure admin.auth.sessions.maxRefreshTokenLifespan and admin.auth.sessions.maxSessionLifespan.
noura-release-note-strapi-app |
noura-release-note-strapi-app | Project information
noura-release-note-strapi-app |
noura-release-note-strapi-app | ┌────────────────────┬──────────────────────────────────────────────────┐
noura-release-note-strapi-app | │ Time │ Wed Mar 18 2026 22:53:33 GMT+0000 (Coordinated … │
noura-release-note-strapi-app | │ Launched in │ 1967 ms │
noura-release-note-strapi-app | │ Environment │ production │
noura-release-note-strapi-app | │ Process PID │ 19 │
noura-release-note-strapi-app | │ Version │ 5.31.3 (node v20.10.0) │
noura-release-note-strapi-app | │ Edition │ Community │
noura-release-note-strapi-app | │ Database │ postgres │
noura-release-note-strapi-app | │ Database name │ strapi │
noura-release-note-strapi-app | └────────────────────┴──────────────────────────────────────────────────┘
noura-release-note-strapi-app |
noura-release-note-strapi-app | Actions available
noura-release-note-strapi-app |
noura-release-note-strapi-app | Welcome back!
noura-release-note-strapi-app | To manage your project 🚀, go to the administration panel at:
noura-release-note-strapi-app | http://192.168.xxx.xxx:xxxx/admin
noura-release-note-strapi-app |
noura-release-note-strapi-app | To access the server ⚡️, go to:
noura-release-note-strapi-app | http://192.168.xxx.xxx:xxxx
noura-release-note-strapi-app |
noura-release-note-strapi-app | [2026-03-18 22:53:33.614] info: Strapi started successfully
noura-release-note-strapi-app | [2026-03-18 22:54:38.016] http: GET /_health (26 ms) 204
正常に起動している。
ブラウザからの疎通
ただ、Chromeからhttp://192.168.xxx.xxx:xxxxにアクセス出来ない。
This site can’t be reached
http://192.168.xxx.xxx:xxxx/ is unreachable.
ERR_ADDRESS_UNREACHABLE
ブラウザ以外からもリクエストは通らない。
% curl http://192.168.xxx.xxx:yyyy/_health
curl: (7) Failed to connect to 192.168.xxx.xxx port yyyy after 1 ms: Could not connect to server
Raspberry Pi上でDockerのポードフォワーディングを確認したが問題ない。
admin@noura-release-note-cms:~$ docker ps --format "table {{.Names}}\t{{.Ports}}"
NAMES PORTS
noura-release-note-strapi-app 0.0.0.0:xxxx->xxxx/tcp, [::]:xxxx->xxxx/tcp
noura-release-note-strapi-db yyyy/tcp
色々調査して解決した。
Macのプライバシー設定でアプリからローカルネットワークへのアクセスがブロックされていただけだった。設定を更新してローカルネットワークからadminダッシュボードにアクセスすることに成功。