-
![](https://nostrcheck.me/media/e3168078608580b4eee1eaf9d47ac01e94a27c406f4f4477b8447e5510f13b2c/6755ad23501191322edea9598dbf0c6b080f5ccf77f8aeaf59cf8bf73ccfe9e9.webp)
@ まくら
2025-01-21 15:44:45
ノス!
最近Umbrel上のn8nを使ってstacker newsの記事を要約するNostr botを作ってみました。
その際にFirecrawlというスクレイピングのSaaSを使っていたんですがセルフホストできるようなので試してみました。
Firecrawlは動的なページも読めたりマークダウンへの変換をしてくれますが無料プランだと1ヶ月500ページの制限があり、セルフホストすれば気兼ねなく使えます!
今回はUmbrel上のPortainerというアプリを使ってFirecrawlを動かせたのでその記録です。
## 手順
まずはUmbrelにPortainerアプリをインストールします。
Poratinerは今回初めて使ったんですが独自のDockerコンテナをUmbrelで動かす際に推奨されているアプリのようです。
![portainer](https://cdn.satellite.earth/be69ccc7abef5ee7b675570c6425542953de6416f68d125866fdb9c21b575d1b.png)
アプリを開いてパスワードの初期設定などを済ませるとダッシュボードが表示されるかと思います。
ここでStackという機能を使ってFirecrawlのDocker composeを一括で取り込むことができます。
新しいStackを作成する画面で以下を入力します。
Repository URL: https://github.com/mendableai/firecrawl
Repository reference: refs/heads/main
Compose path: docker-compose.**yaml** (デフォルトがymlになっててハマりました…)
![create stack](https://cdn.satellite.earth/46c3626d54bd2d77d71ee5ea6a8ce9bcc76356fc0da7a95ff1860f280bfe0eac.png)
上記に加えてenv varを設定する必要があるんですがPortainerでは上記の画像下部にあるように "Load Variables from .env file" からenvファイルを選択できます。
[Firecrawlのgithub](https://github.com/mendableai/firecrawl/blob/main/SELF_HOST.md)にあるように apps/api/.env.example をダウンロードし以下の内容を更新しPortainerに取り込ませます。
```
USE_DB_AUTHENTICATION=false
TEST_API_KEY=fc-test-key
```
あとはDeploy the stackを押して少し待つとfirecrawlのセットアップ完了です。
## 確認
動作テストにはUmbrelの設定からAdvanced Settings -> Terminal -> Umbrel OSを開き以下のコマンドを実行ししマークダウンが返って来れば成功です。
```
$ curl -X POST http://localhost:3002/v1/scrape -H 'Authorization: Bearer fc-test-key' -H 'Content-Type: application/json' -d '{
"url": "https://example.com",
"formats": ["markdown"]
}'
{"success":true,"data":{"markdown":"Example Domain\n==============\n\nThis domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission.\n\n[More information...](https://www.iana.org/domains/example)","metadata":{"title":"Example Domain","ogLocaleAlternate":[],"scrapeId":"7c196348-6561-4ebb-bb8a-9121a29c64b5","viewport":"width=device-width, initial-scale=1","sourceURL":"https://example.com","url":"https://example.com/","statusCode":200}}}
```
またn8n等のUmbrelの他のアプリ(コンテナ)から利用する場合はlocalhostがコンテナ自身になってしまうので別のIP等(172.17.0.1)を使う必要があるのでご注意ください。
([参考](https://community.n8n.io/t/the-service-refused-the-connection-perhaps-it-is-offline-n8n-and-nocodb/33587?utm_source=chatgpt.com))
以上でUmbrel上でのFirecrawlセルフホストができるようになりn8nからも制限なく使えるようになりました。