diff --git a/Dockerfile b/Dockerfile index 96d5b69..9d10e52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,7 +14,10 @@ FROM source AS test # Test packages create independent SQLite stores. Serialize packages to avoid # concurrent server/store initialization exhausting the shared runner's I/O. # Keep production database deadlines and the complete test suite unchanged. -RUN go test -p 1 ./... +# Temporary test databases use bounded RAM-backed storage rather than the +# runner's overlay filesystem. Compiler temporary files remain on disk. +RUN --mount=type=tmpfs,target=/test-tmp,size=2147483648 \ + TMPDIR=/test-tmp GOTMPDIR=/tmp go test -p 1 ./... FROM source AS runtime RUN go build -o /pageswiki ./cmd/pageswiki diff --git a/docs/operations/gitea-images.md b/docs/operations/gitea-images.md index aea2284..d6d0e64 100644 --- a/docs/operations/gitea-images.md +++ b/docs/operations/gitea-images.md @@ -121,6 +121,19 @@ Gitea 1.24 の自動ジョブトークンによるパッケージ公開は前提 アプリイメージにはソースコードが含まれるため、パッケージの公開範囲にも注意する。 +## テスト用一時領域 + +Dockerfileのtest段階では、全Goテストを`-p 1`でパッケージ単位に直列化する。 +テスト用`TMPDIR`は最大2GiBのtmpfsとし、SQLiteの一時DBをrunnerのoverlay filesystemから分離する。 +コンパイラ用`GOTMPDIR`はディスク側の`/tmp`に残す。tmpfsは当該RUNの間だけ存在し、 +runtime段階や本番の保存先・WAL・接続タイムアウトには影響しない。 + +CI run 54では、直列化後も既存の壁紙・Ordoschnellic・Seheweitのテストが +SQLite接続初期化の5秒タイムアウトで失敗した。ストレージ競合を避ける措置であり、 +テスト除外・再試行による成功扱い・本番の期限緩和は行わない。 +tmpfsは最大2GiBのメモリを消費し得るため、runnerにはコンパイラ等と合わせた余裕が必要。 +実ファイル保存の移行確認は、CIとは別に本番DBの隔離コピーで行う。 + ## タグ・容量・本番利用 3 イメージ共通で `sha-<40桁のコミットID>` を使用し、自動 latest は付けない。 @@ -161,3 +174,4 @@ prefix の変更は `PAGESWIKI_IMAGE_PREFIX`(既定 git.anya.jp/anya)。 - [Gitea 1.24 Actions の互換性・制限](https://docs.gitea.com/1.24/usage/actions/comparison/) - [Gitea Container Registry](https://docs.gitea.com/usage/packages/container/) - [Docker コンテナの DNS と hosts](https://docs.docker.com/engine/network/#dns-services) +- [Dockerfileの一時tmpfsマウント](https://docs.docker.com/reference/dockerfile/#run---mounttype-tmpfs)