Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 49 additions & 15 deletions containers/base/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# ==================================
# devbase-base: 共通基盤イメージ
# Ubuntu noble + 共通ツール群
# Ubuntu 26.04 LTS (resolute) + 共通ツール群
# ==================================
Comment thread
takemi-ohama marked this conversation as resolved.
FROM ubuntu:noble
# 26.04 は 2026-04 リリースの最新 LTS (サポート 2031-04 まで)。
# 24.04 (noble) からの主な差分は system python が 3.12 -> 3.14 になること。
# 3.12/3.13 は既定リポジトリに無いため、必要なら `uv python install 3.12` を使う。
FROM ubuntu:26.04
Comment thread
takemi-ohama marked this conversation as resolved.

Comment thread
takemi-ohama marked this conversation as resolved.
ENV DEBIAN_FRONTEND=noninteractive

Expand Down Expand Up @@ -59,8 +62,45 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
apt-get clean; \
rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/* /tmp/* /var/tmp/*

# ユーザー設定
# npm グローバル領域 (後述の NPM_CONFIG_PREFIX) を sudo なしで更新できるようにするため、
# ユーザーとグループは npm パッケージのインストールより「前」に作っておく。
# こうすると所有者・パーミッションの変更を install と同じ RUN 内で完結でき、
# 数百MBの node_modules がメタデータ変更だけのために新しいレイヤーへ
# 丸ごと複製されるのを避けられる。
ARG USERNAME="ubuntu"
# npm グループの GID は派生イメージ (containers/lfm) と揃える必要があるため固定する。
# lfm は base から /usr/local を COPY するだけで base のグループ定義を引き継がないため、
# GID が動的だと COPY されたファイルの GID が派生側で未定義になる。
# 2000 は Ubuntu の system group (<1000) とも既定ユーザー ubuntu (1000) とも衝突しない。
ARG NPM_GID="2000"
RUN set -eux; \
groupadd -f users; \
groupadd -f docker; \
groupadd -g "$NPM_GID" npm; \
if ! id -u $USERNAME >/dev/null 2>&1; then \
useradd -m -s /bin/bash $USERNAME; \
fi; \
usermod -aG users,docker,npm $USERNAME; \
echo '%users ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/users; \
echo "$USERNAME ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME; \
chmod 0440 /etc/sudoers.d/users /etc/sudoers.d/$USERNAME

# npm のグローバル prefix を /usr/local/share/npm-global に置く。
# 既定の /usr/lib/node_modules + /usr/bin は root しか書けず、ubuntu ユーザでの
# `npm i -g`(codex などの自動バージョンアップ)が EACCES で失敗するため。
# 置き場所とパーミッション設計は Dev Containers 標準
# (devcontainers/images の javascript-node) に合わせている。
# ディレクトリは ubuntu:npm 所有 + setgid で作る(下の RUN で実施)。
ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
ENV PATH="/usr/local/share/npm-global/bin:${PATH}"

# AWS CLI + gcloud SDK + uv + npm globals(1レイヤーにまとめる)
RUN set -eux; \
# 所有を $USERNAME:npm、ディレクトリへ setgid を付けて作る。
# 後から誰が入れてもグループが npm のまま揃う
# (UID/GID を振り直しても壊れない Dev Containers 方式)。
install -d -m 2775 -o "$USERNAME" -g npm "$NPM_CONFIG_PREFIX"; \
# AWS CLI v2
curl -fsSL "https://awscli.amazonaws.com/awscli-exe-linux-$(uname -m).zip" -o /tmp/awscliv2.zip; \
unzip -q /tmp/awscliv2.zip -d /tmp; \
Expand Down Expand Up @@ -93,8 +133,14 @@ RUN set -eux; \
docker-credential-gcr cloud-run-proxy 2>&1 || true; \
# uv (Python パッケージマネージャー)
curl -LsSf https://astral.sh/uv/install.sh | sh; \
# npm グローバルパッケージ
# npm グローバルパッケージ(umask 0002 で npm グループにも書き込み権を残す)
umask 0002; \
npm i -g yarn @playwright/test aws-cdk aws-cdk-lib typescript @google/gemini-cli @openai/codex; \
# root が作ったファイルも ubuntu が上書きできるように揃える。
# install レイヤーと同じ RUN なのでレイヤーの複製は発生しない。
chown -R "$USERNAME":npm "$NPM_CONFIG_PREFIX"; \
chmod -R g+rwX "$NPM_CONFIG_PREFIX"; \
find "$NPM_CONFIG_PREFIX" -type d -exec chmod g+s {} +; \
# クリーンアップ
rm -rf /tmp/* /var/tmp/* \
/root/.npm /root/.cache /root/.config \
Expand All @@ -112,18 +158,6 @@ ENV PATH="/root/.local/bin:/opt/google-cloud-sdk/bin:${PATH}"
# 確認
RUN gh --version && node --version && npm --version && aws --version && gcloud --version && session-manager-plugin --version

# ユーザー設定
ARG USERNAME="ubuntu"
RUN groupadd -f users; \
groupadd -f docker; \
if ! id -u $USERNAME >/dev/null 2>&1; then \
useradd -m -s /bin/bash $USERNAME; \
fi; \
usermod -aG users,docker $USERNAME; \
echo '%users ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/users; \
echo "$USERNAME ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME; \
chmod 0440 /etc/sudoers.d/users /etc/sudoers.d/$USERNAME

USER ${USERNAME}
WORKDIR /tmp

Expand Down
6 changes: 4 additions & 2 deletions containers/bi-tools/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@

FROM devbase-base:latest

# --- root: グローバル npm CLI(Lightdash クライアント)---
USER root
# --- ubuntu: グローバル npm CLI(Lightdash クライアント)---
# npm のグローバル prefix (/usr/local/share/npm-global) は base で ubuntu 所有にしてあるため
# root へ切り替えずにインストールする(root で入れると ubuntu が更新できなくなる)。
USER ubuntu
RUN set -eux; \
npm i -g @lightdash/cli; \
lightdash --version
Expand Down
32 changes: 27 additions & 5 deletions containers/lfm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# ==================================
# Stage: CUDA ベース + 追加パッケージ
# ==================================
FROM nvidia/cuda:12.6.3-cudnn-devel-ubuntu24.04 AS cudabase
FROM nvidia/cuda:13.3.1-cudnn-devel-ubuntu26.04 AS cudabase

ENV DEBIAN_FRONTEND=noninteractive

Expand Down Expand Up @@ -75,6 +75,14 @@ RUN locale-gen en_US.UTF-8 && \
FROM cudabase

# devbase-base から共通ツールをコピー
#
# 【重要】cudabase の Ubuntu バージョンは devbase-base と必ず一致させること。
# 下の COPY は node / gh 等の「ビルド済みバイナリ」を持ち込むため、
# devbase-base (ubuntu:26.04 / glibc 2.43) より古い OS の上に置くと
# "GLIBC_2.4x not found" で即座に壊れる。そのため cudabase には
# nvidia/cuda の ubuntu26.04 タグを使用する。
# なお nvidia/cuda の ubuntu26.04 タグは CUDA 13.3.1 系のみが提供されているため、
# containers/base の Ubuntu を上げる際は CUDA のバージョンも追随させる必要がある。
COPY --from=devbase-base:latest /usr/local /usr/local
COPY --from=devbase-base:latest /usr/bin/gh /usr/bin/node /usr/bin/
COPY --from=devbase-base:latest /usr/lib/node_modules /usr/lib/node_modules
Expand All @@ -85,16 +93,30 @@ COPY --from=devbase-base:latest /home/ubuntu/.local /home/ubuntu/.local
RUN ln -sf /usr/lib/node_modules/npm/bin/npm-cli.js /usr/bin/npm && \
ln -sf /usr/lib/node_modules/npm/bin/npx-cli.js /usr/bin/npx

ENV PATH="/home/ubuntu/.local/bin:/opt/google-cloud-sdk/bin:${PATH}"
# npm のグローバル prefix は base と同じ(上の COPY /usr/local で取り込み済み。
# COPY --from は所有者を保持するので ubuntu:npm 所有のまま = sudo なしで `npm i -g` できる。
# ただし npm グループの定義自体は COPY されないので、下のユーザー設定で
# base と同じ GID で作り直して整合させる)。
ENV NPM_CONFIG_PREFIX=/usr/local/share/npm-global
Comment thread
takemi-ohama marked this conversation as resolved.
ENV PATH="/usr/local/share/npm-global/bin:/home/ubuntu/.local/bin:/opt/google-cloud-sdk/bin:${PATH}"
Comment thread
takemi-ohama marked this conversation as resolved.

# 確認
RUN gh --version && node --version && npm --version && aws --version && gcloud --version

# ユーザー設定
ARG USERNAME="ubuntu"
RUN usermod -aG users,docker $USERNAME && \
echo '%users ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/users && \
echo "$USERNAME ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME && \
# npm グループの GID は containers/base/Dockerfile の ARG NPM_GID と必ず一致させる。
# COPY --from が持ち込んだ /usr/local/share/npm-global 配下のファイルは GID 数値だけを
# 保持するため、lfm 側に同じ GID のグループが無いと GID が未定義のまま残り、
# setgid ディレクトリも効かず ubuntu が sudo なしで `npm i -g` できなくなる。
# ここで chown -R し直さないのは、数百MBの node_modules が丸ごと
# 新しいレイヤーへ複製されイメージが肥大化するため。
ARG NPM_GID="2000"
RUN set -eux; \
groupadd -g "$NPM_GID" npm; \
usermod -aG users,docker,npm $USERNAME; \
echo '%users ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/users; \
echo "$USERNAME ALL=(ALL:ALL) NOPASSWD: ALL" > /etc/sudoers.d/$USERNAME; \
chmod 0440 /etc/sudoers.d/users /etc/sudoers.d/$USERNAME

USER ${USERNAME}
Expand Down
14 changes: 8 additions & 6 deletions containers/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Dockerfile.dev - devbase互換の開発コンテナ
# devbase-baseをベースに、PHP 8.3 + MySQL Client + 一般的なPHP拡張を追加
# devbase-baseをベースに、PHP 8.5 + MySQL Client + 一般的なPHP拡張を追加

FROM devbase-base:latest

USER root

# PHP 8.3 + 必要な拡張 + MySQL Client をUbuntuリポジトリからインストール
# PHP 8.5 + 必要な拡張 + MySQL Client をUbuntuリポジトリからインストール
# base が ubuntu:26.04 (resolute) になったため php8.3-* は標準リポジトリに存在しない。
# 26.04 の標準リポジトリが php8.5 (8.5.4) を提供するので PPA は不要。
RUN set -eux; \
apt-get update; \
apt-get install -y \
php8.3-fpm php8.3-cli php8.3-common \
php8.3-gd php8.3-bcmath php8.3-mysql \
php8.3-zip php8.3-exif php8.3-redis \
php8.3-mbstring php8.3-xml php8.3-curl \
php8.5-fpm php8.5-cli php8.5-common \
php8.5-gd php8.5-bcmath php8.5-mysql \
php8.5-zip php8.5-exif php8.5-redis \
php8.5-mbstring php8.5-xml php8.5-curl \
default-mysql-client; \
rm -rf /var/lib/apt/lists/*

Expand Down
8 changes: 4 additions & 4 deletions containers/php85/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ FROM devbase-base:latest

USER root

# Ondřej Surý PPA追加 + PHP 8.5 + 必要な拡張 + MySQL Client をインストール
# PHP 8.5 + 必要な拡張 + MySQL Client をUbuntuリポジトリからインストール
# base が ubuntu:26.04 (resolute) になり、標準リポジトリが php8.5 (8.5.4) を
# 提供するようになったため ppa:ondrej/php は不要になった。
# (ondrej PPA は resolute 向けの dist を公開しておらず、追加すると apt-get update が失敗する)
RUN set -eux; \
apt-get update; \
apt-get install -y software-properties-common; \
add-apt-repository -y ppa:ondrej/php; \
apt-get update; \
apt-get install -y \
php8.5-fpm php8.5-cli php8.5-common \
Expand Down
4 changes: 2 additions & 2 deletions containers/snapshot/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ==================================
# devbase-snapshot: スナップショット専用軽量イメージ
# Ubuntu noble + tar + zstd のみ
# Ubuntu 26.04 + tar + zstd のみ
# ==================================
FROM ubuntu:noble
FROM ubuntu:26.04

RUN apt-get update -qq \
&& apt-get install -y --no-install-recommends zstd \
Expand Down
8 changes: 5 additions & 3 deletions containers/trygroup/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

FROM devbase-base:latest

# --- root レイヤー: pnpm(npm グローバル) ---
USER root
# --- user レイヤー: pnpm(npm グローバル) ---
# npm のグローバル prefix (/usr/local/share/npm-global) は base で ubuntu 所有にしてあるため
# root へ切り替えずにインストールする(root で入れると ubuntu が更新できなくなる)。
USER ubuntu
RUN set -eux; \
npm i -g pnpm; \
npm cache clean --force; \
rm -rf /root/.npm
rm -rf ~/.npm

# --- user レイヤー: Poetry ---
# uv との競合回避:
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def cmd_env_sync(devbase_root: Path, args) -> int:

| 項目 | ルール |
|------|--------|
| ベースイメージ | バージョンを明示する(`ubuntu:noble` 等、`latest` は避ける) |
| ベースイメージ | バージョンを明示する(`ubuntu:26.04` 等、`latest` は避ける) |
| RUN コマンド | 論理的なグループ単位でまとめる。1行1コマンドの羅列は避ける |
| 実行ユーザー | 最終的に `USER ubuntu` で実行する |
| キャッシュ | apt のキャッシュはレイヤー内で削除する |
Expand Down
8 changes: 4 additions & 4 deletions docs/developer/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ devbase のコンテナイメージは `containers/` ディレクトリに定義

```mermaid
flowchart TB
Ubuntu["ubuntu:noble"] --> Base["devbase-base<br/>Docker CLI, Python 3"]
Ubuntu["ubuntu:26.04"] --> Base["devbase-base<br/>Docker CLI, Python 3"]
Base --> General["devbase-general<br/>AWS CLI, gcloud, Node.js, etc."]
Base --> Go["devbase-go<br/>Go 開発環境"]
General --> PHP["devbase-php<br/>PHP 8.3, Composer"]
General --> PHP["devbase-php<br/>PHP 8.5, Composer"]
General --> LaTeX["devbase-latex<br/>LaTeX"]
General --> LFM["devbase-lfm<br/>Rust, gfortran, MeCab"]

Ubuntu2["ubuntu:noble"] --> Snapshot["devbase-snapshot<br/>zstd のみ(軽量)"]
Ubuntu2["ubuntu:26.04"] --> Snapshot["devbase-snapshot<br/>zstd のみ(軽量)"]
```

### 手順 1: ディレクトリとDockerfileの作成
Expand Down Expand Up @@ -285,7 +285,7 @@ USER ubuntu
|------|-----------|
| AWS CLI / gcloud / Node.js 等の一般的な開発ツールが必要 | `devbase-general` |
| 最小限のツールだけでよい(Docker CLI + Python 3) | `devbase-base` |
| Docker も不要で極めて軽量なイメージが必要 | `ubuntu:noble` から直接構築 |
| Docker も不要で極めて軽量なイメージが必要 | `ubuntu:26.04` から直接構築 |

### 手順 2: ビルドと compose.yml への組み込み

Expand Down
6 changes: 3 additions & 3 deletions docs/plugin-dev/compose-yml-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,13 @@ flowchart TD

| イメージ | ベース | 主要ツール | 典型的な用途 |
|---------|--------|-----------|-------------|
| `base` | Ubuntu Noble | Docker CLI、Python 3 | 軽量な自動化・スクリプト |
| `base` | Ubuntu 26.04 | Docker CLI、Python 3 | 軽量な自動化・スクリプト |
| `general` | base | AWS CLI、gcloud、Terraform、Node.js 20、AI CLI | Webアプリ、インフラ管理 |
| `go` | base | Go開発環境 | APIサーバー、CLIツール |
| `php` | general | PHP 8.3、Composer | Laravel、WordPress |
| `php` | general | PHP 8.5、Composer | Laravel、WordPress |
| `latex` | general | LaTeX | 論文、技術文書、レポート |
| `lfm` | general | Rust、gfortran、MeCab | 数値計算、自然言語処理 |
| `snapshot` | Ubuntu Noble | zstd | スナップショットの取得・復元 |
| `snapshot` | Ubuntu 26.04 | zstd | スナップショットの取得・復元 |

### 4.2 標準イメージの使用

Expand Down
6 changes: 3 additions & 3 deletions docs/plugin-dev/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,14 +330,14 @@ flowchart LR

| イメージ | ベース | 主要ツール | 推奨用途 |
|---------|--------|-----------|---------|
| `base` | Ubuntu Noble | Docker CLI、Python 3 | 軽量な開発環境 |
| `base` | Ubuntu 26.04 | Docker CLI、Python 3 | 軽量な開発環境 |
| `general` | base | AWS CLI、gcloud、Terraform、Node.js 20、AI CLI | 汎用開発 |
| `go` | base | Go開発環境 | Go言語プロジェクト |
| `php` | general | PHP 8.3、Composer | PHP 8.3 系プロジェクト |
| `php` | general | PHP 8.5、Composer | PHP 8.5 系プロジェクト |
| `php85` | general | PHP 8.5、Composer | PHP 8.5 系プロジェクト |
| `latex` | general | LaTeX | 文書・論文作成 |
| `lfm` | general | Rust、gfortran、MeCab | 数値計算・自然言語処理 |
| `snapshot` | Ubuntu Noble | zstd | スナップショット専用 |
| `snapshot` | Ubuntu 26.04 | zstd | スナップショット専用 |

### 5.5 Git管理のガイドライン

Expand Down
8 changes: 4 additions & 4 deletions docs/user/container-operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ devbase のコンテナイメージは用途に応じた階層構造になって

```mermaid
graph TD
A[Ubuntu Noble] --> B[base]
A[Ubuntu 26.04] --> B[base]
B --> C[general]
B --> G[go]
C --> D[php]
Expand All @@ -214,14 +214,14 @@ graph TD

| イメージ | ベース | 主な内容 | 用途 |
|---------|-------|---------|------|
| **base** | Ubuntu Noble | Docker CLI、Python 3 | 最小限の開発環境 |
| **base** | Ubuntu 26.04 | Docker CLI、Python 3 | 最小限の開発環境 |
| **general** | base | AWS CLI、gcloud、Terraform、Node.js 20、AI CLI | 汎用開発環境 |
| **php** | general | PHP 8.3、Composer、MySQL Shell | PHP 8.3 系 開発 |
| **php** | general | PHP 8.5、Composer、MySQL Shell | PHP 8.5 系 開発 |
| **php85** | general | PHP 8.5、Composer、MySQL Shell | PHP 8.5 系 開発 |
| **latex** | general | LaTeX | 文書作成 |
| **lfm** | general | Rust、gfortran、MeCab | 数値計算・自然言語処理 |
| **go** | base | Go 開発環境 | Go 開発 |
| **snapshot** | Ubuntu Noble | zstd のみ(約 80MB) | スナップショット専用 |
| **snapshot** | Ubuntu 26.04 | zstd のみ(約 80MB) | スナップショット専用 |

### AI CLI エイリアス

Expand Down
Loading