Skip to content

devcontainer: Ubuntu 24.04 (GCC 13) に上げて CI と compiler を一致させる#45

Merged
thawk105 merged 2 commits into
masterfrom
devcontainer-ubuntu-24
May 13, 2026
Merged

devcontainer: Ubuntu 24.04 (GCC 13) に上げて CI と compiler を一致させる#45
thawk105 merged 2 commits into
masterfrom
devcontainer-ubuntu-24

Conversation

@thawk105
Copy link
Copy Markdown
Owner

@thawk105 thawk105 commented May 13, 2026

背景

#44-Werror=maybe-uninitialized を有効化した際、CI (GCC 13) でだけ落ちる箇所が 3 ラウンド 出て、毎回 push して CI 待ち → fix のループに陥った(cicada pre_ver、mocc threshold、silo LogRecord padding)。原因は devcontainer が ubuntu:22.04 = GCC 11 で、CI の ubuntu-latest = GCC 13 と flow-sensitive 警告の挙動が一致していなかったこと。

ついでに、#46 で「CI を devcontainer image の中で走らせれば apt install が消えて高速化できる」と試したところ、image に dev 専用ツール (zsh / clang-format / sudo / openssh-client / curl) が乗っていて container init で +15s 食われ、ネットでは逆に遅くなっていた。

この PR でその両方を根本対応する:

  1. devcontainer base を ubuntu:22.04 → ubuntu:24.04g++ が GCC 13.x に解決され、CI と一致
  2. Dockerfile を multi-stage 化 し、image を 2 タグに分けて publish:
    • :latest (= dev stage) ← devcontainer 用、zsh/clang-format/sudo/openssh-client/curl 入り (今まで通り)
    • :ci (= base stage) ← CI 用、上記 dev ツールなしの slim 版

変更

  • .devcontainer/Dockerfile: ubuntu:22.04ubuntu:24.04、Multi-stage (base + dev) に分割。base stage で userdel -r ubuntu 2>/dev/null || true を入れて 24.04 のデフォルト ubuntu ユーザー (uid=1000) と vscode の衝突を回避。--platform=linux/amd64 維持で Apple Silicon QEMU 動作は変わらず。
  • .github/workflows/devcontainer-image.yml: docker/build-push-action を 2 回呼び、target: dev:latest に、target: base:ci に push。layer cache は :cache tag で共有。
  • CLAUDE.md: oze: 未初期化 ScanRange union を修正 + -Werror=maybe-uninitialized を有効化 #44 で追加した "Compiler-version mismatch with CI" workaround セクションを 1 行 ("both ship GCC 13") に縮約。

認証

ghcr image は public (anonymous bearer-token pull で manifest 取得可能、HTTP 200)。CI 側でも credentials: 不要。

検証

トレードオフ

観点 Before After
devcontainer の GCC 11 (22.04) 13 (24.04)
dev tooling (zsh, clang-format, sudo, openssh-client, curl) あり あり (:latest)
CI で使う image (CI は apt install) :ci (slim) — :latest の重い layers を pull せずに済む
image build 時間 1 stage 2 stage (キャッシュ共有で実質変わらず)

Related

CI runs on ubuntu-latest (24.04, GCC 13) but the devcontainer was
pinned to ubuntu:22.04 (GCC 11). The two compilers disagreed on flow-
sensitive warnings — most visibly -Wmaybe-uninitialized in #44, where
GCC 11 let three false-negative sites through that GCC 13 caught,
costing three CI round-trips before the gap was closed.

Bumping the devcontainer image to 24.04 makes `g++` resolve to 13.x,
matching CI. Anything that builds locally now also builds in CI.

Side effects of the bump:

- Ubuntu 24.04 images ship a default `ubuntu` user at uid=1000, which
  collided with the existing `useradd --uid 1000 vscode`. The Dockerfile
  now deletes the stock user first; `|| true` keeps it tolerant of
  older bases that lack one.
- `--platform=linux/amd64` is retained, so Apple Silicon QEMU emulation
  still works (still: build/edit/test only, not for benchmarking).
- ubuntu.deps package names (libboost-filesystem-dev, libgflags-dev,
  libgoogle-glog-dev, cmake, g++) are unchanged on 24.04.

Verified locally with gcc-13 (13.4.0 from ubuntu-toolchain-r PPA): all
34 binaries build clean under -DCMAKE_BUILD_TYPE=Release with the
Werror=maybe-uninitialized that #44 turned on.

CLAUDE.md's "Compiler-version mismatch with CI" section, added in #44
as a workaround, collapses into a one-line "both ship GCC 13" note now
that there's no mismatch to work around.
…e :latest

The previous single-stage image bundled zsh / clang-format / sudo /
openssh-client / curl — fine for the human-facing devcontainer, but
dead weight in CI where `actions/checkout` and the cmake build are
the only consumers. Container init in PR #46 paid for those layers on
every CI run.

Split the Dockerfile into two stages and publish them as two tags from
the same workflow:

- `base` stage  -> :ci   (minimum apt deps + vscode user, root by default)
- `dev` stage   -> :latest (`base` + zsh, clang-format, sudo,
                           openssh-client, curl, USER vscode)

`.github/workflows/devcontainer-image.yml` now invokes
`docker/build-push-action` twice, each with a different `target:`,
sharing the same `:cache` so layers are deduplicated.

Devcontainer users keep using :latest with no change. CI's build.yml
will be flipped to :ci in a follow-up PR once this lands and the new
tag is published.
@thawk105 thawk105 merged commit 00405d8 into master May 13, 2026
1 check passed
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