きっかけ
- pi-holeをインストールしてLAN内で快適なAdBlockを実現する – Loochs などでDocker composeでサービスを走らせることが増えた
- gethomepage/homepage: A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations.を入れてサービスを管理し始めるようになった
- kichinosukey/gpt-discord-bot: Discord bot written in Python that uses the assistants API to have conversations with the `gpt-4` model.もDocker composeによる起動をするモチベーションが強まった
やったこと
非常に簡単で下記の二つ
- systemctrlの設定を解除
- Dockerfile & docker composeの作成
systemctrlの設定を解除
- これでサービスを止める、設定を無効にする
sudo systemctl stop gpt-discord-bot.service; sudo systemctl disable gpt-discord-bot.service
- Dockerfile
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "-m", "src.main"]
- docker-compose.yml
- ポイントはlabelsで、これを入れておくとhomepageが自然と拾ってくれる
services:
gpt-discord-bot:
build: .
container_name: gpt_discord_bot
env_file:
- .env
restart: unless-stopped
labels:
- "homepage.name=GPT Discord Bot"
- "homepage.group=Bot"
- "homepage.icon=https://external-content.duckduckgo.com/ip3/support.discord.com.ico"
- "homepage.href=https://github.com/kichinosukey/gpt-discord-bot"
- 最後はいつものこれでok
docker-compose up -d