Compare commits

..
4 Commits
Author SHA1 Message Date
SahikandClaude Opus 5.5 b266f59399 Retry docker push in release script on Cloudflare timeouts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 22:14:34 +08:00
SahikandClaude Opus 5.5 359021fd83 Save release.ps1 as UTF-8 with BOM for Windows PowerShell 5.1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 22:04:27 +08:00
SahikandClaude Opus 5.5 2dcd91b528 Add .dockerignore to keep .env and local data out of the image
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 21:59:53 +08:00
SahikandClaude Opus 5.5 7df53679cb Add TrueNAS compose, separate DB volume, and release script
Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 21:59:13 +08:00
4 changed files with 62 additions and 0 deletions

No files matched your search

+12
View File
@@ -0,0 +1,12 @@
# 不要把機密和本機資料打包進 image
.env
command.txt
data/
.git/
.gitignore
__pycache__/
*.pyc
.ipynb_checkpoints/
*.ipynb
docker-compose.yml
release.ps1
+5
View File
@@ -3,4 +3,9 @@ WORKDIR /app
COPY requirements.txt . COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt RUN pip install --no-cache-dir -r requirements.txt
COPY . . COPY . .
# 資料庫放在獨立的 volume
ENV DB_PATH=/data/game.db
VOLUME ["/data"]
CMD ["python", "main.py"] CMD ["python", "main.py"]
+11
View File
@@ -0,0 +1,11 @@
# TrueNAS 部署用:Apps → Discover Apps → Install via YAML
services:
game-bot:
image: gitea.sthkm3.org/sthkm3/discordgamebot:latest
container_name: discord-game-bot
restart: unless-stopped
environment:
DISCORD_BOT_TOKEN: ${DISCORD_BOT_TOKEN}
volumes:
# 換成 TrueNAS 上的 dataset 路徑
- /mnt/pool/apps/discord-game-bot/db:/data
+34
View File
@@ -0,0 +1,34 @@
# 用法:.\release.ps1
# 從 config.py 讀版本號 → build image → 推到 gitea registry → 打 git tag
$ErrorActionPreference = "Stop"
$Image = "gitea.sthkm3.org/sthkm3/discordgamebot"
$Version = (Select-String -Path config.py -Pattern 'VERSION = "V?([^"]+)"').Matches[0].Groups[1].Value
if (git status --porcelain) {
throw "有未 commit 的修改,請先 commit 再發布"
}
if (git tag --list "v$Version") {
throw "v$Version 已經發布過了,請先更新 config.py 的 VERSION"
}
docker build -t "${Image}:$Version" -t "${Image}:latest" .
if ($LASTEXITCODE) { throw "docker build 失敗" }
# Cloudflare 對單一請求有 100 秒限制,大的 layer 可能 524 逾時;
# 已上傳的 layer 會被略過,所以重試幾次通常就會成功
function Push-WithRetry($Ref) {
for ($i = 1; $i -le 5; $i++) {
docker push $Ref
if (-not $LASTEXITCODE) { return }
Write-Host "推送失敗,重試 ($i/5)..."
}
throw "docker push $Ref 失敗"
}
Push-WithRetry "${Image}:$Version"
Push-WithRetry "${Image}:latest"
git tag "v$Version"
git push origin "v$Version"
Write-Host "已發布 ${Image}:$Version"