Files
CFDivePlatform/openspec/changes/cloud-ready-p1/tasks.md
T
a620906209 d423cf5079
Run Tests / test (pull_request) Successful in 29s
feat(infra): 雲端就緒 P1 — Session/Log/Scheduler 改造
- Dockerfile:移除 cron 安裝與 scheduler crontab 設定
- docker-entrypoint.sh:移除 service cron start
- docker-compose.yml:新增 scheduler service(php artisan schedule:work)
- .env.example:SESSION_DRIVER=redis、LOG_CHANNEL=stderr、移除 LOG_STACK/LOG_DAILY_DAYS
- docs/STARTUP.md:新增 Log 查看、VPS 維護窗口操作與 Rollback 說明

VPS 部署需手動更新 .env 並執行 docker compose up -d --build(詳見 STARTUP.md §11)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-18 02:34:01 +08:00

46 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 1. Dockerfile 移除 cron
- [x] 1.1 [後端] 從 `Dockerfile``apt-get install -y` 清單移除 `cron`
- [x] 1.2 [後端] 從 `Dockerfile` 移除寫入 `/etc/cron.d/laravel-scheduler``RUN echo ...` 指令
- [x] 1.3 [後端] 從 `Dockerfile` 移除 `crontab /etc/cron.d/laravel-scheduler` 指令
## 2. docker-entrypoint.sh 移除 cron 啟動
- [x] 2.1 [後端] 從 `docker/php/docker-entrypoint.sh` 移除 `service cron start || cron || true` 這一行
## 3. docker-compose.yml 新增 scheduler service
- [x] 3.1 [後端] 在 `docker-compose.yml` 新增 `scheduler` service,設定如下:
- `image: cfdive-platform``container_name: cfdive-scheduler``restart: unless-stopped`
- `working_dir: /var/www/``command: php artisan schedule:work`
- `volumes: - ./:/var/www`
- 環境變數:`DB_CONNECTION``DB_HOST=db``DB_PORT``DB_DATABASE``DB_USERNAME``DB_PASSWORD`(與 queue-worker 相同)
- `networks: - cfdive-network`
- `depends_on: app: condition: service_healthy`
## 4. .env.example 更新
- [x] 4.1 [後端] 將 `.env.example``SESSION_DRIVER=database # 雲端建議改為 redis` 改為 `SESSION_DRIVER=redis`(升級為預設值,移除說明)
- [x] 4.2 [後端] 將 `.env.example``LOG_CHANNEL=stack` 改為 `LOG_CHANNEL=stderr`
- [x] 4.3 [後端] 從 `.env.example` 移除 `LOG_STACK=daily``LOG_DAILY_DAYS=14` 兩行(改 stderr 後無作用)
## 5. 文件更新
- [x] 5.1 [後端] 更新 `docs/STARTUP.md`,補充以下內容:
- 服務清單新增 `scheduler``docker compose ps` 應見 `cfdive-scheduler`
- Log 查看方式:`docker compose logs -f app`(不再有 `storage/logs/` 檔案)
- **VPS 維護窗口操作**:說明 `sed` 更新 `.env` 的四個指令 + `docker compose up -d --build`
- **Config cache 注意**`.env` 改完須清 cacherebuild 時 entrypoint 自動處理)
- **Rollback 步驟**Session/Log 還原指令(不需 rebuild+ Scheduler 還原(需 rebuild
## 6. 手動驗證(本機,不需 VPS .env)
- [x] 6.1 [整合測試] 在本機 rebuild 後確認 `cfdive-scheduler` 正常啟動:`docker compose ps` 顯示 scheduler Up
- [x] 6.2 [整合測試] 確認 app container 無 cron`docker compose exec app sh -c "which cron 2>/dev/null || echo 'cron binary not found'"`cron binary 已從 image 移除,輸出 `cron binary not found`
## 7. 手動驗證(VPS,需更新 .env 後)
- [ ] 7.1 [整合測試] 確認 log 走 stderr:呼叫任意 API 後 `docker compose logs app | tail -20` 有日誌輸出
- [ ] 7.2 [整合測試] 確認 `storage/logs/` 無新增日誌檔(舊檔保留)
- [ ] 7.3 [整合測試] 確認 session 走 Redis:登入後 `docker compose exec redis redis-cli keys "laravel_session*"` 有輸出