Skip to content

Commit 93aa2a3

Browse files
committed
WIP2
1 parent e6156da commit 93aa2a3

9 files changed

Lines changed: 512 additions & 213 deletions

File tree

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
./build-user-image.sh -u 22.04 # Ubuntu 22.04
2727

2828
# 2. コンテナを起動
29-
./start-container.sh # ソフトウェアレンダリング
30-
./start-container.sh --gpu nvidia --all # NVIDIA GPU(全GPU使用
31-
./start-container.sh --gpu nvidia --num 0 # NVIDIA GPU(GPU 0のみ)
32-
./start-container.sh --gpu intel # Intel GPU
33-
./start-container.sh --gpu amd # AMD GPU
34-
./start-container.sh --gpu nvidia-wsl --all # WSL2 + NVIDIA
29+
./start-container.sh --encoder software # ソフトウェアエンコード
30+
./start-container.sh --encoder nvidia --gpu all # NVIDIA NVENC(全GPU
31+
./start-container.sh --encoder nvidia --num 0 # NVIDIA NVENC(GPU 0のみ)
32+
./start-container.sh --encoder intel # Intel VA-API
33+
./start-container.sh --encoder amd # AMD VA-API
34+
./start-container.sh --encoder nvidia-wsl --gpu all # WSL2 + NVIDIA NVENC
3535

3636
# 3. ブラウザでアクセス
37-
# → https://localhost:<30000+UID> (例: UID=1000 → https://localhost:41000)
37+
# → https://localhost:<30000+UID> (例: UID=1000 → https://localhost:31000)
3838
# → http://localhost:<40000+UID> (例: UID=1000 → http://localhost:41000)
3939

4040
# 4. 変更を保存(重要!コンテナ削除前に必ず実行)
@@ -92,10 +92,13 @@
9292
- ヒストリー最適化(重複無視、追記モード、タイムスタンプ)
9393
- 便利なエイリアス(ll, la, grep色付けなど)
9494

95-
- **🎮 柔軟なGPU選択**: 明確なコマンド引数
96-
- `--all` - 全利用可能GPU使用
97-
- `--num 0,1` - 特定GPUデバイス
98-
- `--gpu none` - ソフトウェアレンダリング
95+
- **🎮 柔軟なエンコーダー/GPU選択**: 明確なコマンド引数
96+
- `--encoder nvidia` - NVIDIA NVENC
97+
- `--encoder intel` - Intel VA-API
98+
- `--encoder amd` - AMD VA-API
99+
- `--encoder software` - ソフトウェアエンコード
100+
- `--gpu all` - Docker全GPU使用(NVIDIA)
101+
- `--num 0,1` - 特定GPUデバイス指定
99102

100103
### 開発者体験
101104

@@ -105,7 +108,7 @@
105108

106109
- **🛠️ 完全な管理スクリプト**: 全操作用シェルスクリプト
107110
- `build-user-image.sh` - パスワード付きビルド
108-
- `start-container.sh [--gpu <type>]` - GPU選択で起動
111+
- `start-container.sh --encoder <type>` - エンコーダー選択で起動
109112
- `stop/shell-container.sh` - ライフサイクル管理
110113
- `commit-container.sh` - 変更を保存
111114

@@ -124,7 +127,7 @@
124127
| 手動UID/GID設定 | 自動マッチング |
125128
| コマンドにパスワード | 環境変数で安全に |
126129
| 汎用bash | Ubuntu Desktop bash |
127-
| GPU自動検出 | GPU明示的選択 |
130+
| GPU自動検出 | エンコーダー/GPU明示的選択 |
128131
| バージョンドリフト | バージョン固定 |
129132
| 英語のみ | 多言語(EN/JP) |
130133

@@ -327,15 +330,13 @@ UID/GIDが一致するパーソナルイメージを作成(1-2分):
327330

328331
- **HTTPSポート**: `30000 + UID`(例: UID 1000 → ポート 31000)
329332
- **HTTPポート**: `40000 + UID`(例: UID 1000 → ポート 41000)
330-
- **TURNポート**: `45000 + UID`(例: UID 1000 → ポート 46000)
331333

332334
アクセス: `https://localhost:${HTTPS_PORT}`(例: UID 1000で `https://localhost:31000`
333335

334336
**リモートアクセス(LAN/WAN):**
335337

336-
TURNサーバーは**デフォルトで有効**で、追加オプションなしでリモートアクセス可能
338+
WebRTCによるリモートアクセスが可能
337339

338-
- TURNサーバーがWebRTC接続を中継
339340
- LAN IPアドレスを自動検出
340341
- リモートPCからアクセス: `https://<host-ip>:<https-port>`
341342

@@ -686,8 +687,6 @@ docker exec linuxserver-kde-$(whoami) pactl list sinks short
686687
|------|------|----------|
687688
| `PORT_SSL_OVERRIDE` | HTTPSポート上書き | `UID+30000` |
688689
| `PORT_HTTP_OVERRIDE` | HTTPポート上書き | `UID+40000` |
689-
| `PORT_TURN_OVERRIDE` | TURNポート上書き | `UID+45000` |
690-
| `HOST_IP` | TURNサーバー用ホストIP | 自動検出 |
691690

692691
</details>
693692

README_en.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ A containerized Kubuntu (KDE Plasma) desktop environment accessible via browser.
2626
./build-user-image.sh -u 22.04 # Ubuntu 22.04
2727

2828
# 2. Start container
29-
./start-container.sh # Software rendering
30-
./start-container.sh --gpu nvidia --all # NVIDIA GPU (all GPUs)
31-
./start-container.sh --gpu nvidia --num 0 # NVIDIA GPU (GPU 0 only)
32-
./start-container.sh --gpu intel # Intel GPU
33-
./start-container.sh --gpu amd # AMD GPU
34-
./start-container.sh --gpu nvidia-wsl --all # WSL2 + NVIDIA
29+
./start-container.sh --encoder software # Software encoding
30+
./start-container.sh --encoder nvidia --gpu all # NVIDIA NVENC (all GPUs)
31+
./start-container.sh --encoder nvidia --num 0 # NVIDIA NVENC (GPU 0 only)
32+
./start-container.sh --encoder intel # Intel VA-API
33+
./start-container.sh --encoder amd # AMD VA-API
34+
./start-container.sh --encoder nvidia-wsl --gpu all # WSL2 + NVIDIA NVENC
3535

3636
# 3. Access via browser
3737
# → https://localhost:<30000+UID> (e.g., UID=1000 → https://localhost:31000)
@@ -92,10 +92,13 @@ That's it! 🎉
9292
- History optimization (ignoredups, append mode, timestamps)
9393
- Useful aliases (ll, la, grep colors, etc.)
9494

95-
- **🎮 Flexible GPU Selection:** Clear command arguments
96-
- `--all` - Use all available GPUs
95+
- **🎮 Flexible Encoder/GPU Selection:** Clear command arguments
96+
- `--encoder nvidia` - NVIDIA NVENC
97+
- `--encoder intel` - Intel VA-API
98+
- `--encoder amd` - AMD VA-API
99+
- `--encoder software` - Software encoding
100+
- `--gpu all` - Use all Docker GPUs (NVIDIA)
97101
- `--num 0,1` - Specific GPU devices
98-
- `--gpu none` - Software rendering
99102

100103
### Developer Experience
101104

@@ -105,7 +108,7 @@ That's it! 🎉
105108

106109
- **🛠️ Complete Management Scripts:** Shell scripts for all operations
107110
- `build-user-image.sh` - Build with password
108-
- `start-container.sh [--gpu <type>]` - Start with GPU selection
111+
- `start-container.sh --encoder <type>` - Start with encoder selection
109112
- `stop/shell-container.sh` - Lifecycle management
110113
- `commit-container.sh` - Save your changes
111114

@@ -124,7 +127,7 @@ That's it! 🎉
124127
| Manual UID/GID setup | Automatic matching |
125128
| Password in command | Environment variable |
126129
| Generic bash | Ubuntu Desktop bash |
127-
| GPU auto-detected | GPU explicitly selected |
130+
| GPU auto-detected | Encoder/GPU explicitly selected |
128131
| Version drift | Version pinned |
129132
| English only | Multi-language (EN/JP) |
130133

@@ -327,15 +330,13 @@ Ports are automatically assigned based on your user ID to enable multiple users
327330

328331
- **HTTPS Port**: `30000 + UID` (e.g., UID 1000 → port 31000)
329332
- **HTTP Port**: `40000 + UID` (e.g., UID 1000 → port 41000)
330-
- **TURN Port**: `45000 + UID` (e.g., UID 1000 → port 46000)
331333

332334
Access via: `https://localhost:${HTTPS_PORT}` (e.g., `https://localhost:31000` for UID 1000)
333335

334336
**Remote Access (LAN/WAN):**
335337

336-
TURN server is **enabled by default** for remote access without additional options:
338+
WebRTC remote access is available:
337339

338-
- TURN server relays WebRTC connections
339340
- Auto-detects LAN IP address
340341
- Access from remote PC: `https://<host-ip>:<https-port>`
341342

@@ -686,8 +687,7 @@ docker exec linuxserver-kde-$(whoami) pactl list sinks short
686687
|----------|-------------|---------|
687688
| `PORT_SSL_OVERRIDE` | HTTPS port override | `UID+30000` |
688689
| `PORT_HTTP_OVERRIDE` | HTTP port override | `UID+40000` |
689-
| `PORT_TURN_OVERRIDE` | TURN port override | `UID+45000` |
690-
| `HOST_IP` | Host IP for TURN server | Auto-detect |
690+
691691

692692
</details>
693693

compose-env.sh

Lines changed: 75 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
# Generate environment variables for docker-compose (same settings as start-container.sh)
3-
# Usage: source <(./compose-env.sh --gpu nvidia --all)
4-
# ./compose-env.sh --env-file .env --gpu intel
3+
# Usage: source <(./compose-env.sh --encoder nvidia --gpu all)
4+
# ./compose-env.sh --env-file .env --encoder intel
55

66
set -e
77

@@ -10,10 +10,11 @@ show_usage() {
1010
Usage: compose-env.sh [options]
1111
1212
Options (same as start-container.sh):
13-
-g, --gpu <type> GPU vendor: none (default), nvidia, nvidia-wsl, intel, amd
14-
Note: --gpu nvidia requires --all or --num
15-
--all Use all GPUs (required for nvidia/nvidia-wsl, optional for intel/amd)
16-
--num <list> Comma-separated NVIDIA GPU indices (only with --gpu nvidia)
13+
-e, --encoder <type> Encoder: software, nvidia, nvidia-wsl, intel, amd (required)
14+
-g, --gpu <value> Docker --gpus value (optional): all or device=0,1
15+
--all Shortcut for --gpu all
16+
--num <list> Shortcut for --gpu device=<list>
17+
--dri-node <path> DRI render node for VA-API (e.g. /dev/dri/renderD129)
1718
-u, --ubuntu <ver> Ubuntu version: 22.04 or 24.04 (default: 24.04)
1819
-r, --resolution <res> Resolution in WIDTHxHEIGHT format (default: 1920x1080)
1920
-d, --dpi <dpi> DPI setting (default: 96)
@@ -37,9 +38,12 @@ EOF
3738
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3839

3940
# Defaults (matching start-container.sh)
40-
GPU_VENDOR="${GPU_VENDOR:-none}"
41+
ENCODER="${ENCODER:-}"
42+
GPU_VENDOR="${GPU_VENDOR:-}"
4143
GPU_ALL="${GPU_ALL:-false}"
4244
GPU_NUMS="${GPU_NUMS:-}"
45+
DOCKER_GPUS="${DOCKER_GPUS:-}"
46+
DRI_NODE="${DRI_NODE:-}"
4347
UBUNTU_VERSION="${UBUNTU_VERSION:-24.04}"
4448
RESOLUTION="${RESOLUTION:-1920x1080}"
4549
DPI="${DPI:-96}"
@@ -52,20 +56,20 @@ ARCH_OVERRIDE=""
5256
# Option parsing
5357
while [[ $# -gt 0 ]]; do
5458
case $1 in
59+
-e|--encoder)
60+
if [ -z "${2:-}" ]; then
61+
echo "Error: --encoder requires an argument" >&2
62+
exit 1
63+
fi
64+
ENCODER="${2}"
65+
shift 2
66+
;;
5567
-g|--gpu)
5668
if [ -z "${2:-}" ]; then
5769
echo "Error: --gpu requires an argument" >&2
5870
exit 1
5971
fi
60-
case "${2}" in
61-
nvidia|nvidia-wsl|intel|amd|none)
62-
GPU_VENDOR="${2}"
63-
;;
64-
*)
65-
echo "Error: Unknown GPU vendor: ${2}" >&2
66-
exit 1
67-
;;
68-
esac
72+
DOCKER_GPUS="${2}"
6973
shift 2
7074
;;
7175
--all)
@@ -80,6 +84,14 @@ while [[ $# -gt 0 ]]; do
8084
GPU_NUMS="${2}"
8185
shift 2
8286
;;
87+
--dri-node)
88+
if [ -z "${2:-}" ]; then
89+
echo "Error: --dri-node requires a path (e.g. /dev/dri/renderD129)" >&2
90+
exit 1
91+
fi
92+
DRI_NODE="${2}"
93+
shift 2
94+
;;
8395
-u|--ubuntu)
8496
if [ -z "${2:-}" ]; then
8597
echo "Error: --ubuntu requires a version (22.04 or 24.04)" >&2
@@ -155,9 +167,37 @@ if [[ ! $RESOLUTION =~ ^[0-9]+x[0-9]+$ ]]; then
155167
exit 1
156168
fi
157169

158-
if [[ "${GPU_VENDOR}" == "nvidia" ]]; then
159-
if [[ "${GPU_ALL}" != "true" ]] && [[ -z "${GPU_NUMS}" ]]; then
160-
echo "Error: --gpu nvidia requires --all or --num" >&2
170+
if [ -z "${ENCODER}" ]; then
171+
echo "Error: --encoder is required" >&2
172+
exit 1
173+
fi
174+
175+
ENCODER=$(echo "${ENCODER}" | tr '[:upper:]' '[:lower:]')
176+
case "${ENCODER}" in
177+
software|none|cpu)
178+
ENCODER="software"
179+
;;
180+
nvidia|nvidia-wsl|intel|amd)
181+
;;
182+
*)
183+
echo "Error: Unknown encoder: ${ENCODER}" >&2
184+
exit 1
185+
;;
186+
esac
187+
188+
GPU_VENDOR="${ENCODER}"
189+
190+
if [ -z "${DOCKER_GPUS}" ]; then
191+
if [ "${GPU_ALL}" = "true" ]; then
192+
DOCKER_GPUS="all"
193+
elif [ -n "${GPU_NUMS}" ]; then
194+
DOCKER_GPUS="device=${GPU_NUMS}"
195+
fi
196+
fi
197+
198+
if [ -n "${DOCKER_GPUS}" ]; then
199+
if [[ "${DOCKER_GPUS}" != "all" && ! "${DOCKER_GPUS}" =~ ^device=[0-9,]+$ ]]; then
200+
echo "Error: --gpu value must be 'all' or 'device=0,1'." >&2
161201
exit 1
162202
fi
163203
fi
@@ -254,10 +294,10 @@ case "${GPU_VENDOR}" in
254294
nvidia)
255295
ENABLE_NVIDIA="true"
256296
DISABLE_ZINK="true"
257-
if [ "${GPU_ALL}" = "true" ]; then
297+
if [ "${DOCKER_GPUS}" = "all" ]; then
258298
NVIDIA_VISIBLE_DEVICES="all"
259-
else
260-
NVIDIA_VISIBLE_DEVICES="${GPU_NUMS}"
299+
elif [[ "${DOCKER_GPUS}" =~ ^device= ]]; then
300+
NVIDIA_VISIBLE_DEVICES="${DOCKER_GPUS#device=}"
261301
fi
262302
if [ -d "/dev/dri" ]; then
263303
GPU_DEVICES="/dev/dri:/dev/dri:rwm"
@@ -269,10 +309,10 @@ case "${GPU_VENDOR}" in
269309
DISABLE_ZINK="true"
270310
XDG_RUNTIME_DIR="/mnt/wslg/runtime-dir"
271311
LD_LIBRARY_PATH="/usr/lib/wsl/lib"
272-
if [ "${GPU_ALL}" = "true" ]; then
312+
if [ "${DOCKER_GPUS}" = "all" ]; then
273313
NVIDIA_VISIBLE_DEVICES="all"
274-
else
275-
NVIDIA_VISIBLE_DEVICES="${GPU_NUMS}"
314+
elif [[ "${DOCKER_GPUS}" =~ ^device= ]]; then
315+
NVIDIA_VISIBLE_DEVICES="${DOCKER_GPUS#device=}"
276316
fi
277317
;;
278318
intel)
@@ -282,6 +322,10 @@ case "${GPU_VENDOR}" in
282322
else
283323
echo "Warning: /dev/dri not found, Intel VA-API not available." >&2
284324
fi
325+
# Pass DRI_NODE if specified
326+
if [ -n "${DRI_NODE}" ]; then
327+
echo "Using specified DRI node: ${DRI_NODE}" >&2
328+
fi
285329
;;
286330
amd)
287331
LIBVA_DRIVER_NAME="${LIBVA_DRIVER_NAME:-radeonsi}"
@@ -293,8 +337,12 @@ case "${GPU_VENDOR}" in
293337
if [ -e "/dev/kfd" ]; then
294338
GPU_DEVICES="${GPU_DEVICES:+${GPU_DEVICES},}/dev/kfd:/dev/kfd:rwm"
295339
fi
340+
# Pass DRI_NODE if specified
341+
if [ -n "${DRI_NODE}" ]; then
342+
echo "Using specified DRI node: ${DRI_NODE}" >&2
343+
fi
296344
;;
297-
none|"")
345+
software|"")
298346
ENABLE_NVIDIA="false"
299347
;;
300348
esac
@@ -320,7 +368,7 @@ ENV_VARS=(
320368
IMAGE_BASE IMAGE_TAG IMAGE_VERSION IMAGE_ARCH UBUNTU_VERSION
321369
HOST_PORT_SSL HOST_PORT_HTTP HOST_IP
322370
WIDTH HEIGHT DPI SCALE_FACTOR FORCE_DEVICE_SCALE_FACTOR CHROMIUM_FLAGS SHM_SIZE RESOLUTION TIMEZONE
323-
GPU_VENDOR GPU_ALL GPU_NUMS
371+
ENCODER GPU_VENDOR GPU_ALL GPU_NUMS DOCKER_GPUS DRI_NODE
324372
ENABLE_NVIDIA LIBVA_DRIVER_NAME NVIDIA_VISIBLE_DEVICES GPU_DEVICES
325373
WSL_ENVIRONMENT DISABLE_ZINK XDG_RUNTIME_DIR LD_LIBRARY_PATH
326374
SSL_DIR SSL_CERT_PATH SSL_KEY_PATH

0 commit comments

Comments
 (0)