8000 feat(sandbox): slim the sandbox image and give containers the host time zone by geminixiang · Pull Request #173 · geminixiang/mikan · GitHub
[go: up one dir, main page]

Skip to content

feat(sandbox): slim the sandbox image and give containers the host time zone - #173

Merged
geminixiang merged 1 commit into
mainfrom
feat/slim-sandbox-image
Oct 11, 2026
Merged

geminixiang merged 1 commit into
mainfrom
feat/slim-sandbox-image

Conversation

@geminixiang
Copy link
Copy Markdown
Owner

為什麼要改

sandbox image 約 2.9 GB,其中有不少 mikan 和 agent 都用不到的東西。另外 Dockerfile 寫死了 TZ=Asia/Taipei,這是公開的 image,對其他使用者不對。研究紀錄:docs/research/sandbox-image-slim-2026-10.md。

改了什麼

項目 改法 理由
gcloud 的預編譯檔(.pyc) 在安裝的同一層刪掉 apt 安裝腳本編譯出 254 MB,佔 gcloud 的三分之一。Python 第一次執行時會自己補回用得到的部分
vim、nano、less、bash-completion 移除 互動式工具,agent 改檔用 edit 工具
python3-venv 移除 uv 會建立虛擬環境
apt-transport-https、lsb-release 移除 apt 1.5 起已內建 https,這兩個是過渡用的空殼
gnupg 移除 只用來轉換 Google apt 金鑰格式,apt 能直接讀 .asc
ENV TZ=Asia/Taipei 移除,image 改為 UTC 由 provisioner 把 mikan 主機的 IANA 時區傳給每個 container(--env TZ=…),和 system prompt 裡「events 預設用主機時區」一致
tzdata 明確列出 TZ 要依賴它,不靠其他套件順帶裝進來
smoke 測試 新增時區檢查 image 本身是 UTC,帶 TZ 時會跟著改

刻意保留:python3-pip。它負責在有人執行 pip install 時,提示改用 uv run --with,smoke 測試也有檢查這點。gsutil、bq 也保留,拿掉會讓 agent 或 skill 呼叫的指令失效。

結果(arm64,同一天、同一個 base 建置)

項目 main 這個 PR
image 大小 2,878 MB 2,489 MB(−389 MB)
gcloud 目錄 696 MB 415 MB
gcloud version(新 container 第一次/之後) 245/190 ms 790/188 ms
gcloud storage ls --help(第一次/之後) 307/290 ms 471/280 ms
scripts/smoke-sandbox-image.sh 新的 UTC 檢查失敗 全部通過
Slack E2E(oci:,nerdctl) — 23 個測試檔、26 個測試全部通過;container 的 TZ 是主機時區

代價:每個新 container 第一次執行某一類 gcloud 指令時,會多 0.2 到 0.5 秒,之後就和原本一樣快。

驗證

  • 先寫測試再改程式:「container 使用主機時區」的 provisioner 測試在修改前失敗,修改後通過。
  • 本機 gate 全過:lint、fmt、knip、build、typecheck、完整測試、文件站建置。
  • 文件:四種語言的 OCI sandbox 頁都補上「container 使用主機時區」。

Release note

  • sandbox image 縮小約 390 MB:移除 vim、nano、less 等互動式工具,以及 gcloud 的預編譯檔。
  • image 不再把時區寫死成 Asia/Taipei:mikan 會把主機的時區傳給 container,部署在台北時行為不變。

…me zone

The Cloud SDK's apt install script compiles 254 MB of bytecode, a third
of the SDK. Deleting it in the install layer costs a new container
0.2-0.5 s on the first run of a gcloud command family, after which
Python has written back what it uses.

Interactive editors and pagers, bash-completion, python3-venv, and the
transitional apt-transport-https and lsb-release packages are unused by
mikan and agents; gnupg only dearmored the Google key, which apt reads
armored. The image is 389 MB smaller.

ENV TZ=Asia/Taipei fixed one deployment's zone in a public image. The
image is UTC, and the provisioner passes the host's IANA zone to each
container, as the system prompt already assumes for events.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying mikan with  Cloudflare Pages  Cloudflare Pages

Latest commit: d0d61b5
Status: ✅  Deploy successful!
Preview URL: https://2dc4e3a2.mikan-1wv.pages.dev
Branch Preview URL: https://feat-slim-sandbox-image.mikan-1wv.pages.dev

View logs

@geminixiang
geminixiang merged commit 5061b89 into main Oct 11, 2026
7 checks passed
@geminixiang
geminixiang deleted the feat/slim-sandbox-image branch October 11, 2026 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0