Merge feature/docker-rootless into develop

This commit is contained in:
bchanot committed 2026-10-09 00:28:52 +02:00
commit 40b72f85c4
7 files changed
+72 -9

No files matched your search

+3
View File
@@ -123,3 +123,6 @@ Done: choose_macos_shell default bash → zsh (Enter, no tty, unknown value). Fo
## 2026-10-07 (3) — gitflow.autopush asked at install, hooksPath fixed, identity bug
Done: `gitconfig` template `[gitflow] autopush = @AUTOPUSH@` + fixed `core.hooksPath = ~/.claude/githooks`; install.sh `resolve_autopush` (existing ~/.gitconfig value via sed → `DOTFILES_GITFLOW_AUTOPUSH` strict, bad value aborts → prompt re-asks exact true/false, Enter = true → true), `render_gitconfig` fail-closed (non-boolean / leaked placeholder = nothing written). Found by challenge: install.sh:688 passed the repo bashrc TEMPLATE to deploy_gitconfig → every install wrote `name = @USER@`; fixed, identity passed directly. `shopt -u patsub_replacement` (bash ≥ 5.2 `&` in names). Oracle harness `.claude/tasks/contracts/check-autopush-render.sh` (12 cases, scratch HOMEs, zero `git config`: that command family is denied to the session). 3 challengers + 1 confirm, verifier ECARTS(1) → CONFORME, security PASS (MEDIUM noted: newline in IDENTITY_* env injects gitconfig lines, pre-existing for rc too). Code commit 9901ec5 on feature/gitconfig-autopush; merge on user signal.
## 2026-10-09 — rootless Docker offered at install
Done: `offer_docker_rootless()` (uidmap/dbus-user-session/slirp4netns/docker-ce-rootless-extras, `dockerd-rootless-setuptool.sh install` no --force, enable-linger, rootful daemon disabled first as the docs recommend, user asked for it), extras in install_docker list, bashrc-linux exports DOCKER_HOST only when the user socket exists (no PATH line: apt variant puts the tool in /usr/bin, not ~/bin). README step 16. Stub harness 4 cases + snippet with/without socket OK, shellcheck clean. Branch feature/docker-rootless, not merged. Machine state: rootless already set up by hand, rootful daemon still enabled, ~/.bashrc has a hardcoded uid 1000 DOCKER_HOST line (redeploy replaces it).
+9
View File
@@ -139,3 +139,12 @@ Port of the Alphalink dotfiles `repo` / `repo-reset` zsh functions, bash + zsh,
## Feature — gitflow.autopush asked at install, written to ~/.gitconfig (2026-10-07)
Branch: feature/gitconfig-autopush (off develop). Plan: .claude/tasks/plans/2026-10-07-gitconfig-autopush-1734.md
- [ ] /feat run: gitconfig `[gitflow] autopush = @AUTOPUSH@` + fixed `core.hooksPath`; install.sh `resolve_autopush` (exact true/false: existing ~/.gitconfig value via sed → DOTFILES_GITFLOW_AUTOPUSH (bad value aborts) → prompt re-asks → true), deploy_gitconfig takes name/email/autopush (fixes `name = @USER@` deployed from the template path) + fail-closed leak check; README/CLAUDE.md; oracle harness .claude/tasks/contracts/check-autopush-render.sh
## Feature — Docker rootless offered at install (2026-10-09)
Branch: feature/docker-rootless (off develop). Mirrors the manual setup done on this machine
(docs.docker.com/engine/security/rootless, apt variant: setuptool lives in /usr/bin, not ~/bin).
- [x] install.sh: `docker-ce-rootless-extras` in the install_docker package list
- [x] install.sh: offer_docker_rootless() — uidmap/dbus-user-session/slirp4netns + extras, setuptool install (no --force), enable-linger; rootful daemon disabled first
- [x] bash/bashrc-linux: DOCKER_HOST exported only when the rootless socket exists (no PATH line: /usr/bin already on PATH)
- [x] README.md: table row, step 2 packages, packages list, new offer step
- [x] shellcheck + bash -n; commit on the feature branch. No finish without explicit signal.
+9 -2
View File
@@ -5,8 +5,15 @@ hook=post-commit
# holds. Never fails the commit: no origin / offline / refused → warning only.
# Opt out for one command with GITFLOW_NO_PUSH=1 (throwaway repos, tests).
[ "${GITFLOW_NO_PUSH:-0}" = 1 ] && exit 0
# Per-repo opt-out (no push rights on a foreign clone): git config gitflow.autopush false
[ "$(git config --bool --default true gitflow.autopush)" = false ] && exit 0
# Manual-push mode (human-set): git config gitflow.autopush false. Fail closed:
# an unparseable value or a config read failure also means "no push", named.
# Mirrors gitflow_push_mode (lib/gitflow.sh); arms pinned by T18b/T18h/T18q2/T18q4.
v=$(git config --bool gitflow.autopush 2>/dev/null); rc=$?
case "$rc:$v" in
0:true|1:*) ;;
0:false) exit 0 ;;
*) echo "gitflow $hook: gitflow.autopush unreadable (git rc $rc) — NOT pushed, treated as manual push mode; fix the value by hand" >&2; exit 0 ;;
esac
git remote get-url origin >/dev/null 2>&1 || exit 0
br=$(git symbolic-ref --short -q HEAD 2>/dev/null) || exit 0 # detached HEAD — nothing to track
if command -v timeout >/dev/null 2>&1; then t="timeout ${GITFLOW_PUSH_TIMEOUT:-30}"; else t=""; fi
+9 -2
View File
@@ -5,8 +5,15 @@ hook=post-merge
# holds. Never fails the commit: no origin / offline / refused → warning only.
# Opt out for one command with GITFLOW_NO_PUSH=1 (throwaway repos, tests).
[ "${GITFLOW_NO_PUSH:-0}" = 1 ] && exit 0
# Per-repo opt-out (no push rights on a foreign clone): git config gitflow.autopush false
[ "$(git config --bool --default true gitflow.autopush)" = false ] && exit 0
# Manual-push mode (human-set): git config gitflow.autopush false. Fail closed:
# an unparseable value or a config read failure also means "no push", named.
# Mirrors gitflow_push_mode (lib/gitflow.sh); arms pinned by T18b/T18h/T18q2/T18q4.
v=$(git config --bool gitflow.autopush 2>/dev/null); rc=$?
case "$rc:$v" in
0:true|1:*) ;;
0:false) exit 0 ;;
*) echo "gitflow $hook: gitflow.autopush unreadable (git rc $rc) — NOT pushed, treated as manual push mode; fix the value by hand" >&2; exit 0 ;;
esac
git remote get-url origin >/dev/null 2>&1 || exit 0
br=$(git symbolic-ref --short -q HEAD 2>/dev/null) || exit 0 # detached HEAD — nothing to track
if command -v timeout >/dev/null 2>&1; then t="timeout ${GITFLOW_PUSH_TIMEOUT:-30}"; else t=""; fi
+5 -4
View File
@@ -16,7 +16,7 @@ curl -fsSL https://git.bchanot.fr/bchanot/config/raw/branch/main/remote-install.
| Path | Purpose |
| -------------------- | -------------------------------------------------------------- |
| `install.sh` | Linux: installs apt packages + Docker + code-server + RDP (gnome-remote-desktop), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools and a low-disk login warning; ends by offering three extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, then prints what was not installed compared with Linux. |
| `install.sh` | Linux: installs apt packages + Docker + code-server + RDP (gnome-remote-desktop), backs up old config, deploys vim + bashrc (OS-detected), installs CLI scripts, pipx tools and a low-disk login warning; ends by offering four extras (`/tmp` on disk, SSH memory guard, the `cloudpex` NAS mount helper, rootless Docker). macOS: same tooling through Homebrew (see [macOS](#macos)), deploys the tmux config, then prints what was not installed compared with Linux. |
| `tmux.conf` | tmux config (vi keys, mouse, status bar, tpm plugins: resurrect + continuum session restore, window-name). Deployed on both OSes to `~/.config/tmux/tmux.conf` (tmux ≥ 3.1). |
| `cloudpex/` | On-demand SMB mount of a NAS share (`cloudpex` command + its installer, offered `[y/N]` at the end of a Linux install). Site values (host, share, SMB user, mount point, SMB version) are prompted at install and stored in `/etc/cloudpex.conf`, never in the script. French README inside. |
| `etc/tmpfiles.d/tmp.conf` | Cleanup rules for a disk-backed `/tmp` (wiped at boot, 10-day purge). Deployed by the `/tmp` on disk offer. |
@@ -63,7 +63,7 @@ No argument — the OS is auto-detected.
What it does:
1. On Debian/Ubuntu, installs a set of CLI/dev packages via `apt-get` (see below). On macOS, Homebrew does it instead: see [macOS](#macos).
2. Sets up Docker's official apt repo (Ubuntu) and installs the engine + compose plugin — skipped if `docker` is already present.
2. Sets up Docker's official apt repo (Ubuntu) and installs the engine + compose plugin + rootless extras — skipped if `docker` is already present.
3. Moves any existing `~/.vim`, `~/.vimrc`, `~/.bashrc`, `~/.Sublivim` to `~/Oldconfig`.
4. Clones the `syntastic` and `nerdtree` vim plugins into `~/.vim/bundle/`.
5. Copies the tracked vim files into `~/.vim` and symlinks `~/.vimrc`.
@@ -77,6 +77,7 @@ What it does:
13. On Linux, installs the **security baseline**, always, no prompt: **fail2ban** (+ `nftables`) with `etc/fail2ban/jail.d/local.conf` (sshd jail reading the journal, bans the offending IP on every port so the SSH port does not matter, 5 failures in 10 min → 1 h ban, loopback and private LAN ranges never banned); **unattended-upgrades** enabled through `etc/apt/apt.conf.d/20auto-upgrades`; and the **sshd drop-in** `etc/ssh/sshd_config.d/20-hardening.conf` (`PermitRootLogin no`, `MaxAuthTries 3`, `LoginGraceTime 20`), checked with `sshd -t` and removed again if sshd rejects it, then `reload ssh`. Authentication methods, port and user lists are left as they are.
14. On Linux, at the very end, **offers** (`[y/N]`, skipped when no terminal is attached) to move **`/tmp` to disk**: Ubuntu mounts `/tmp` as a RAM-backed tmpfs capped at 50% of RAM, which agent runs fill, halving the RAM and breaking every shell with "No space left on device". Accepting masks `tmp.mount` and installs `etc/tmpfiles.d/tmp.conf` (wipe at boot, 10-day purge). Effective at the next reboot.
15. On Linux, at the very end, **offers** to keep **SSH reachable under memory pressure**: installs the `ssh.service` drop-in (`OOMScoreAdjust=-1000`, `MemoryMin=256M`) and `earlyoom` with `etc/default/earlyoom` (kills the largest process, `node`/`java` first and never `sshd`, once free RAM and swap both drop under 10%). Restarting `ssh` keeps open sessions. Note: `MemoryMin` protects the sshd daemon only; login sessions live in `user.slice`, so no setting can reserve RAM for a future shell. earlyoom acting in time is the real protection.
16. On Linux, at the very end, **offers** to set up **rootless Docker**: installs `uidmap dbus-user-session slirp4netns docker-ce-rootless-extras`, runs `dockerd-rootless-setuptool.sh install` as you (the apt package puts it in `/usr/bin`, so no `PATH` line is needed, unlike the `~/bin` install from `get.docker.com/rootless`), then `loginctl enable-linger` so the user daemon starts at boot. The tool creates `~/.config/systemd/user/docker.service` and switches the CLI to the `rootless` context; the deployed bashrc exports `DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock` whenever that socket exists, for tools that ignore contexts. The rootful daemon is disabled first (`systemctl disable --now docker.service docker.socket`, socket removed), as the docs recommend: `docker` then only talks to your user daemon. Needs `/etc/subuid` and `/etc/subgid` entries for the user (Ubuntu adds them at user creation).
### Packages installed (apt)
@@ -86,12 +87,12 @@ What it does:
- **Runtimes**: `nodejs python3-pip pipx php-cli`
- **Web stack (local WordPress/LAMP)**: `mariadb-server imagemagick php-mysql php-gd php-imagick php-mbstring php-xml php-intl php-curl` (unversioned `php-*` metapackages, so they follow the distro's PHP)
- **Media / doc CLI**: `ffmpeg weasyprint poppler-utils qpdf webp libavif-bin`
- **Docker**: `docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin` (via Docker's repo)
- **Docker**: `docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras` (via Docker's repo)
- **Desktop / GPU**: `ubuntu-desktop-minimal` (always, Linux) + the distro-recommended NVIDIA driver via `ubuntu-drivers install` (only when an NVIDIA GPU is detected)
- **Remote access**: `gnome-remote-desktop openssl` (apt) + `code-server` (via its vendor install script, not apt) — RDP remote login + browser VS Code
- **pipx**: `PyMuPDF` (`pymupdf`), `Markdown` (`markdown_py`)
- **Security baseline (Linux, always)**: `fail2ban nftables unattended-upgrades`
- **Optional (end-of-install offer, Linux)**: `earlyoom`
- **Optional (end-of-install offer, Linux)**: `earlyoom`; `uidmap dbus-user-session slirp4netns` (rootless Docker)
The script is re-runnable: each run re-backs up to `~/Oldconfig` (overwriting the previous backup), re-clones plugins, skips Docker if already installed, and re-deploys the `bin/` scripts.
+6
View File
@@ -16,6 +16,12 @@ case ":$PATH:" in
*) export PATH="$HOME/.local/bin:$PATH" ;;
esac
# Rootless Docker (install.sh offer): tools that ignore the CLI context (docker-py,
# testcontainers...) need DOCKER_HOST; only set when the user daemon's socket exists.
if [ -S "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/docker.sock" ]; then
export DOCKER_HOST="unix://${XDG_RUNTIME_DIR:-/run/user/$(id -u)}/docker.sock"
fi
# Set history size to unlimited
if [[ $EUID == 0 ]] ; then
export HISTSIZE=0
+31 -1
View File
@@ -30,7 +30,8 @@ install_docker() {
echo "deb [arch=${arch} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu ${codename} stable" |
sudo tee /etc/apt/sources.list.d/docker.list >/dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin \
docker-compose-plugin docker-ce-rootless-extras
}
# NVIDIA driver: only when an NVIDIA GPU is on the PCI bus (vendor id 10de), so the
@@ -166,6 +167,34 @@ offer_cloudpex() {
bash "$SCRIPT_DIR/cloudpex/install.sh"
}
# Rootless Docker, on request: a second daemon running as the login user (no root,
# no docker group), the docs' apt variant. docker-ce-rootless-extras ships
# dockerd-rootless-setuptool.sh in /usr/bin, so the PATH export the docs mention is
# not needed (that line is for the ~/bin install from get.docker.com/rootless). The
# setup tool writes ~/.config/systemd/user/docker.service, starts it and switches the
# CLI to the "rootless" context; linger keeps the daemon up without a login session.
# The rootful daemon is disabled first, as the docs recommend: one daemon, and the
# tool refuses to run while /var/run/docker.sock is writable by the user anyway.
# Idempotent: apt and the tool both skip what exists. Ubuntu-only (Docker apt repo).
offer_docker_rootless() {
confirm "Set up rootless Docker for $(id -un) (daemon runs as your user)?" || return 0
if ! sudo apt-get install -y uidmap dbus-user-session slirp4netns docker-ce-rootless-extras; then
echo "docker-ce-rootless-extras not installable (Docker apt repo missing?) — skipping" >&2
return 0
fi
if systemctl cat docker.service >/dev/null 2>&1; then
echo "Disabling the rootful Docker daemon (docker.service, docker.socket)"
sudo systemctl disable --now docker.service docker.socket
sudo rm -f /var/run/docker.sock
fi
if ! dockerd-rootless-setuptool.sh install; then
echo "rootless Docker setup failed — see the tool's output above (rootful daemon is disabled)" >&2
return 0
fi
sudo loginctl enable-linger "$(id -un)"
echo "Rootless Docker ready: CLI context 'rootless' selected; the bashrc exports DOCKER_HOST when its socket exists."
}
# fail2ban: bans an IP on every port after repeated SSH failures. The sshd jail
# reads the journal (works with or without /var/log/auth.log) and bans all ports,
# so the port sshd listens on does not matter — the previous server's jail only
@@ -776,6 +805,7 @@ if command -v apt-get >/dev/null 2>&1; then
offer_tmp_on_disk
offer_ssh_memory_guard
offer_cloudpex
offer_docker_rootless
fi
# macOS: login shells skip ~/.bashrc unless ~/.bash_profile sources it (kept even