diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..dc9ec87 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,54 @@ +name: "Release features" + +on: + workflow_dispatch: + +permissions: + contents: write + packages: write + pull-requests: write + +jobs: + publish: + name: "Publish to GHCR" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: "Publish features" + uses: devcontainers/action@v1 + with: + publish-features: "true" + base-path-to-features: "./src" + generate-docs: "true" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: "Publish per-feature releases" + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + for manifest in src/*/devcontainer-feature.json; do + dir=$(dirname "$manifest") + id=$(jq -r '.id' "$manifest") + version=$(jq -r '.version' "$manifest") + tag="${id}-v${version}" + + if gh release view "$tag" >/dev/null 2>&1; then + echo "Release $tag already exists, skipping." + continue + fi + + readme="${dir}/README.md" + if [[ ! -f "$readme" ]]; then + echo "No README for $id, skipping." + continue + fi + + gh release create "$tag" \ + --target "$GITHUB_SHA" \ + --title "${id} v${version}" \ + --notes-file "$readme" \ + "$readme#${id}-README.md" + done diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..1c5ceef --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,153 @@ +name: "Test features" + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +jobs: + test-autogenerated: + name: "Autogenerated tests / ${{ matrix.feature }} on ${{ matrix.base-image }}" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + # pnpm requires Node — only typescript-node:24 has it. + - feature: pnpm + base-image: mcr.microsoft.com/devcontainers/typescript-node:24-trixie + - feature: pnpm + base-image: mcr.microsoft.com/devcontainers/typescript-node:24-bookworm + - feature: pnpm + base-image: mcr.microsoft.com/devcontainers/typescript-node:24-bullseye + + # claude / gitbutler / opencode are Node-less — test on the bare base + # across all current Debian + Ubuntu LTS releases. + - feature: claude + base-image: mcr.microsoft.com/devcontainers/base:trixie + - feature: claude + base-image: mcr.microsoft.com/devcontainers/base:bookworm + - feature: claude + base-image: mcr.microsoft.com/devcontainers/base:bullseye + - feature: claude + base-image: mcr.microsoft.com/devcontainers/base:noble + - feature: claude + base-image: mcr.microsoft.com/devcontainers/base:jammy + - feature: claude + base-image: mcr.microsoft.com/devcontainers/base:focal + + # gitbutler's upstream binary needs glibc >= 2.32, so bullseye + # (Debian 11, glibc 2.31) and focal (Ubuntu 20.04, glibc 2.31) are + # excluded. + - feature: gitbutler + base-image: mcr.microsoft.com/devcontainers/base:trixie + - feature: gitbutler + base-image: mcr.microsoft.com/devcontainers/base:bookworm + - feature: gitbutler + base-image: mcr.microsoft.com/devcontainers/base:noble + - feature: gitbutler + base-image: mcr.microsoft.com/devcontainers/base:jammy + + - feature: opencode + base-image: mcr.microsoft.com/devcontainers/base:trixie + - feature: opencode + base-image: mcr.microsoft.com/devcontainers/base:bookworm + - feature: opencode + base-image: mcr.microsoft.com/devcontainers/base:bullseye + - feature: opencode + base-image: mcr.microsoft.com/devcontainers/base:noble + - feature: opencode + base-image: mcr.microsoft.com/devcontainers/base:jammy + - feature: opencode + base-image: mcr.microsoft.com/devcontainers/base:focal + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: 24 + - uses: pnpm/action-setup@v6 + with: + version: 11 + - name: Get pnpm store path + id: pnpm-cache + shell: bash + run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" + - uses: actions/cache@v5 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('.github/workflows/test.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install @devcontainers/cli + run: pnpm add -g @devcontainers/cli + - name: Run autogenerated tests + run: | + devcontainer features test \ + --features "${{ matrix.feature }}" \ + --base-image "${{ matrix.base-image }}" \ + --skip-scenarios \ + --project-folder . + + test-scenarios: + name: "Scenario tests / ${{ matrix.feature }}" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + feature: [claude, gitbutler, opencode, pnpm] + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: 24 + - uses: pnpm/action-setup@v6 + with: + version: 11 + - name: Get pnpm store path + id: pnpm-cache + shell: bash + run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" + - uses: actions/cache@v5 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('.github/workflows/test.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install @devcontainers/cli + run: pnpm add -g @devcontainers/cli + - name: Run scenario tests + run: | + devcontainer features test \ + --features "${{ matrix.feature }}" \ + --skip-autogenerated \ + --project-folder . + + test-global: + name: "Global scenarios" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version: 24 + - uses: pnpm/action-setup@v6 + with: + version: 11 + - name: Get pnpm store path + id: pnpm-cache + shell: bash + run: echo "STORE_PATH=$(pnpm store path --silent)" >> "$GITHUB_OUTPUT" + - uses: actions/cache@v5 + with: + path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('.github/workflows/test.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + - name: Install @devcontainers/cli + run: pnpm add -g @devcontainers/cli + - name: Run global scenarios + run: | + devcontainer features test \ + --global-scenarios-only \ + --project-folder . diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3cbbefe --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.devcontainer/ +plans/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..6b6864d --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +FEATURES ?= claude,gitbutler,opencode,pnpm +BASE_IMAGE ?= mcr.microsoft.com/devcontainers/typescript-node:24-trixie + +.PHONY: help test test-auto test-scenarios test-global + +help: + @echo "Targets:" + @echo " test auto + scenario + global tests" + @echo " test-auto autogenerated tests" + @echo " test-scenarios scenario tests" + @echo " test-global global scenario tests" + @echo "" + @echo "Vars:" + @echo " FEATURES='$(FEATURES)' (comma-separated; e.g. FEATURES=claude)" + @echo " BASE_IMAGE='$(BASE_IMAGE)'" + +test: test-auto test-scenarios test-global + +test-auto: + devcontainer features test \ + --features "$(FEATURES)" \ + --base-image "$(BASE_IMAGE)" \ + --skip-scenarios \ + --project-folder . + +test-scenarios: + devcontainer features test \ + --features "$(FEATURES)" \ + --skip-autogenerated \ + --project-folder . + +test-global: + devcontainer features test \ + --global-scenarios-only \ + --project-folder . diff --git a/README.md b/README.md new file mode 100644 index 0000000..9ad4c73 --- /dev/null +++ b/README.md @@ -0,0 +1,95 @@ +# Synergy Shock Dev Container Features + +A collection of [Dev Container Features](https://containers.dev/features) published to GHCR. Drop any of them into a `devcontainer.json` to get the same tooling we use internally. + +## Features + +| ID | Name | Description | Reference | +|----|------|-------------|-----------| +| [`claude`](./src/claude) | Claude Code | Installs the Claude Code CLI (`@anthropic-ai/claude-code`). | `ghcr.io/synergy-shock/devcontainer/claude` | +| [`gitbutler`](./src/gitbutler) | GitButler CLI | Installs the GitButler CLI (`but`). | `ghcr.io/synergy-shock/devcontainer/gitbutler` | +| [`opencode`](./src/opencode) | OpenCode | Installs the OpenCode AI CLI and `rtk`. | `ghcr.io/synergy-shock/devcontainer/opencode` | +| [`pnpm`](./src/pnpm) | pnpm | Installs pnpm globally and configures the store and npm prefix. | `ghcr.io/synergy-shock/devcontainer/pnpm` | + +## Usage + +Reference a feature from any `devcontainer.json` by its GHCR URL and version tag: + +```jsonc +{ + "image": "mcr.microsoft.com/devcontainers/typescript-node:24-trixie", + "features": { + "ghcr.io/synergy-shock/devcontainer/pnpm:1": {}, + "ghcr.io/synergy-shock/devcontainer/claude:2": {}, + "ghcr.io/synergy-shock/devcontainer/opencode:2": { + "installRtk": true + }, + "ghcr.io/synergy-shock/devcontainer/gitbutler:1": {} + } +} +``` + +Version tags follow the `MAJOR`, `MAJOR.MINOR`, and `MAJOR.MINOR.PATCH` aliases that `devcontainers/action` publishes automatically. + +## Local development + +This repo's own `.devcontainer/devcontainer.json` composes all four features from `../src/` so contributors can iterate on the install scripts in-place. Open the repo in VS Code Dev Containers, or run: + +```bash +devcontainer up --workspace-folder . +``` + +Then inside the container verify the binaries you touched: + +```bash +claude --version +but --version +opencode --version +pnpm --version +``` + +## Testing + +Tests use the official `@devcontainers/cli`. Install it once: + +```bash +npm install -g @devcontainers/cli +``` + +Then from the repo root: + +```bash +# Autogenerated checks for a single feature +devcontainer features test -f pnpm \ + -i mcr.microsoft.com/devcontainers/typescript-node:24-trixie \ + -p . + +# Custom scenarios for a single feature +devcontainer features test -f opencode --skip-autogenerated -p . + +# Cross-feature combinations +devcontainer features test --global-scenarios-only -p . +``` + +Each per-feature test lives at `test//test.sh`; scenario tests at `test//.sh` with the matching `test//scenarios.json`; cross-feature tests in `test/_global/`. + +CI runs all three of these in `.github/workflows/test.yaml` on every push and PR. + +## Releasing + +1. Bump `version` in `src//devcontainer-feature.json` for any feature you changed. Follow SemVer. +2. Merge the PR to `main`. +3. From the **Actions** tab, run the **Release features** workflow (`workflow_dispatch`). It will: + - publish each feature to `ghcr.io/synergy-shock/devcontainer/` with the new version tag + - open a follow-up PR with auto-generated `src//README.md` updates +4. **First-time only**, visit (or your account `?tab=packages` if published under a user namespace), open each new package, and change its visibility to **public**. GHCR publishes private by default. + +## Contributing + +- Author hand-written context in `src//NOTES.md` — it gets concatenated into the auto-generated `README.md` so consumers see it. +- Don't edit `src//README.md` by hand; the release workflow regenerates it. +- Run the relevant `devcontainer features test` locally before opening a PR. + +## License + +MIT — see [LICENSE](./LICENSE). diff --git a/features/opencode/NOTES.md b/features/opencode/NOTES.md new file mode 100644 index 0000000..d801e33 --- /dev/null +++ b/features/opencode/NOTES.md @@ -0,0 +1,14 @@ +## OS support + +Debian/Ubuntu-based images. The feature is self-contained — it fetches the +official opencode installer via `curl` and does not require Node.js or `npm` +on the host image. + +## What gets installed + +- **opencode** — installed under `/usr/local/share/opencode` via the official installer (`https://opencode.ai/install`), symlinked to `/usr/local/bin/opencode`. +- **rtk** *(optional, default on)* — fetched from the latest GitHub release of `rtk-ai/rtk` and placed at `/usr/local/bin/rtk`. + +## Architectures + +`x86_64` and `aarch64` (`arm64` is mapped to `aarch64`) for `rtk`. diff --git a/features/opencode/devcontainer-feature.json b/features/opencode/devcontainer-feature.json new file mode 100644 index 0000000..0f02e82 --- /dev/null +++ b/features/opencode/devcontainer-feature.json @@ -0,0 +1,20 @@ +{ + "id": "opencode", + "version": "2.0.0", + "name": "OpenCode", + "description": "Installs the OpenCode AI CLI and (optionally) rtk.", + "documentationURL": "https://github.com/Synergy-Shock/devcontainer/tree/main/features/opencode", + "options": { + "version": { + "type": "string", + "default": "latest", + "description": "Version selector (currently unused by the curl installer).", + "proposals": ["latest"] + }, + "installRtk": { + "type": "boolean", + "default": true, + "description": "Install the rtk CLI." + } + } +} diff --git a/features/opencode/install.sh b/features/opencode/install.sh new file mode 100755 index 0000000..a448c8d --- /dev/null +++ b/features/opencode/install.sh @@ -0,0 +1,70 @@ +#!/bin/bash +set -e + +#----------------------------------------------------------------------------------------------------- +# OpenCode Dev Container Feature +# Installs: opencode, rtk (optional) +# Intended for use on Debian/Ubuntu-based images. Does not require Node.js. +#----------------------------------------------------------------------------------------------------- + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +OPENCODE_VERSION="${VERSION:-latest}" +INSTALL_RTK="${INSTALLRTK:-true}" + +ARCH=$(uname -m) +case "${ARCH}" in + x86_64) + RTK_ARCH="x86_64" + ;; + aarch64|arm64) + RTK_ARCH="aarch64" + ;; + *) + echo "(!) Architecture ${ARCH} is not supported for rtk." + exit 1 + ;; +esac + +export DEBIAN_FRONTEND=noninteractive + +apt-get update +apt-get install -y --no-install-recommends curl jq +rm -rf /var/lib/apt/lists/* + +# ------------------------------------------------------------------ +# Install rtk (optional) +# ------------------------------------------------------------------ +if [ "${INSTALL_RTK}" = "true" ]; then + echo "==> Installing rtk..." + RTK_LATEST=$(curl -fsSL https://api.github.com/repos/rtk-ai/rtk/releases/latest | jq -r '.tag_name') + RTK_URL="https://github.com/rtk-ai/rtk/releases/download/${RTK_LATEST}/rtk-${RTK_ARCH}-unknown-linux-gnu.tar.gz" + curl -fsSL "${RTK_URL}" | tar -xz -C /usr/local/bin rtk + chmod +x /usr/local/bin/rtk + rtk --version +else + echo "==> Skipping rtk installation." +fi + +# ------------------------------------------------------------------ +# Install opencode +# ------------------------------------------------------------------ +echo "==> Installing opencode..." +# Install into a system-wide HOME and expose the launcher without relying on shell rc files. +OPENCODE_INSTALL_HOME="/usr/local/share/opencode" +mkdir -p "${OPENCODE_INSTALL_HOME}" +curl -fsSL https://opencode.ai/install | env -u VERSION HOME="${OPENCODE_INSTALL_HOME}" bash -s -- --no-modify-path +ln -sf "${OPENCODE_INSTALL_HOME}/.opencode/bin/opencode" /usr/local/bin/opencode +opencode --version + +echo "==> Adjusting permissions for ${_REMOTE_USER} user..." +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${OPENCODE_INSTALL_HOME}" 2>/dev/null || true + +echo "==> Pre-creating XDG directories for ${_REMOTE_USER} user..." +mkdir -p "${_REMOTE_USER_HOME}/.config" "${_REMOTE_USER_HOME}/.local" +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${_REMOTE_USER_HOME}" + +echo "==> OpenCode feature installation complete!" diff --git a/src/claude/NOTES.md b/src/claude/NOTES.md new file mode 100644 index 0000000..2a6836e --- /dev/null +++ b/src/claude/NOTES.md @@ -0,0 +1,7 @@ +## OS support + +Debian/Ubuntu-based images. The feature uses `apt-get` to install `curl`, `ca-certificates`, and `git`, then runs the official installer from `https://claude.ai/install.sh`. + +## Implementation details + +Claude Code is installed under `/usr/local/share/claude` (`$HOME` is redirected during install) so that bind-mounting `/home//.claude` from the host at runtime does not shadow the binaries. A symlink at `/usr/local/bin/claude` exposes the launcher on `PATH` without depending on shell rc files. diff --git a/src/claude/devcontainer-feature.json b/src/claude/devcontainer-feature.json new file mode 100644 index 0000000..c93310c --- /dev/null +++ b/src/claude/devcontainer-feature.json @@ -0,0 +1,21 @@ +{ + "id": "claude", + "version": "2.1.145", + "name": "Claude Code", + "description": "Installs the Claude Code CLI (@anthropic-ai/claude-code).", + "documentationURL": "https://github.com/Synergy-Shock/devcontainer/tree/main/features/claude", + "options": { + "version": { + "type": "string", + "default": "latest", + "description": "Select or enter the version of @anthropic-ai/claude-code to install globally.", + "proposals": ["latest"] + } + }, + "containerEnv": { + "NPM_CONFIG_PREFIX": "/usr/local/share/npm-global", + "PNPM_HOME": "/usr/local/share/pnpm", + "PNPM_STORE_DIR": "/usr/local/share/pnpm-store", + "PATH": "/usr/local/share/npm-global/bin:/usr/local/share/pnpm:/usr/local/bin:${PATH}" + } +} diff --git a/src/claude/install.sh b/src/claude/install.sh new file mode 100755 index 0000000..1f4a472 --- /dev/null +++ b/src/claude/install.sh @@ -0,0 +1,43 @@ +#!/bin/bash +set -e + +#----------------------------------------------------------------------------------------------------- +# Claude Code Dev Container Feature +# Installs the Claude Code CLI via the official installer: https://claude.ai/install.sh +# Intended for use on Debian/Ubuntu-based images. +#----------------------------------------------------------------------------------------------------- + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +CLAUDE_VERSION="${VERSION:-latest}" + +export DEBIAN_FRONTEND=noninteractive + +apt-get update +apt-get install -y --no-install-recommends curl ca-certificates git +rm -rf /var/lib/apt/lists/* + +# Install into a system-wide HOME so we do not write into /home/node/.claude, which +# is bind-mounted from the host at runtime and would shadow anything we put there. +CLAUDE_INSTALL_HOME="/usr/local/share/claude" +mkdir -p "${CLAUDE_INSTALL_HOME}" + +INSTALL_ARG="" +if [ "${CLAUDE_VERSION}" != "latest" ]; then + INSTALL_ARG="${CLAUDE_VERSION}" +fi + +echo "==> Installing Claude Code (${CLAUDE_VERSION}) via https://claude.ai/install.sh ..." +HOME="${CLAUDE_INSTALL_HOME}" bash -c "curl -fsSL https://claude.ai/install.sh | bash -s -- ${INSTALL_ARG}" + +# Expose the launcher on PATH for every user without depending on shell rc files. +ln -sf "${CLAUDE_INSTALL_HOME}/.local/bin/claude" /usr/local/bin/claude + +claude --version + +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${CLAUDE_INSTALL_HOME}" + +echo "==> Claude Code feature installation complete!" diff --git a/src/gitbutler/NOTES.md b/src/gitbutler/NOTES.md new file mode 100644 index 0000000..99fdbff --- /dev/null +++ b/src/gitbutler/NOTES.md @@ -0,0 +1,13 @@ +## OS support + +Debian/Ubuntu-based images with **glibc ≥ 2.32**. Verified on Debian 12+ (bookworm, trixie) and Ubuntu 22.04+ (jammy, noble). The upstream `but` binary links against newer glibc symbols, so older distros — notably Debian 11 (bullseye) and Ubuntu 20.04 (focal) — are not supported and will fail at load time with `GLIBC_2.32 not found`. + +The feature installs `curl`, `libc6`, and `libdbus-1-3`, then downloads the prebuilt binary from `releases.gitbutler.com`. + +## Architectures + +`x86_64` and `aarch64` (the script maps `arm64` → `aarch64`). Anything else fails fast with a clear error. + +## Source + +Binaries come from `https://releases.gitbutler.com/releases/release//linux//but` and are installed to `/usr/local/bin/but`. diff --git a/src/gitbutler/devcontainer-feature.json b/src/gitbutler/devcontainer-feature.json new file mode 100644 index 0000000..43b99a7 --- /dev/null +++ b/src/gitbutler/devcontainer-feature.json @@ -0,0 +1,15 @@ +{ + "id": "gitbutler", + "version": "1.0.0", + "name": "GitButler CLI", + "description": "Installs the GitButler CLI (but).", + "documentationURL": "https://github.com/Synergy-Shock/devcontainer/tree/main/features/gitbutler", + "options": { + "version": { + "type": "string", + "default": "0.19.12-3040", + "description": "Select or enter the version of the GitButler CLI (but) to install.", + "proposals": ["0.19.12-3040", "0.19.9-2990"] + } + } +} diff --git a/src/gitbutler/install.sh b/src/gitbutler/install.sh new file mode 100755 index 0000000..95c11e8 --- /dev/null +++ b/src/gitbutler/install.sh @@ -0,0 +1,45 @@ +#!/bin/bash +set -e + +#----------------------------------------------------------------------------------------------------- +# GitButler Dev Container Feature +# Installs: the GitButler CLI (but) +# Intended for use on Debian/Ubuntu-based images +#----------------------------------------------------------------------------------------------------- + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +BUT_VERSION="${VERSION:-0.19.12-3040}" + +ARCH=$(uname -m) +case "${ARCH}" in + x86_64) + BUT_ARCH="x86_64" + ;; + aarch64|arm64) + BUT_ARCH="aarch64" + ;; + *) + echo "(!) Architecture ${ARCH} is not supported for the 'but' binary." + exit 1 + ;; +esac + +export DEBIAN_FRONTEND=noninteractive + +apt-get update +apt-get install -y --no-install-recommends curl libc6 libdbus-1-3 +rm -rf /var/lib/apt/lists/* + +echo "==> Installing GitButler CLI (but) v${BUT_VERSION} for ${BUT_ARCH}..." +BUT_URL="https://releases.gitbutler.com/releases/release/${BUT_VERSION}/linux/${BUT_ARCH}/but" +BUT_BIN="/usr/local/bin/but" + +curl -fsSL -o "${BUT_BIN}" "${BUT_URL}" +chmod +x "${BUT_BIN}" +"${BUT_BIN}" --version + +echo "==> GitButler feature installation complete!" diff --git a/src/opencode/NOTES.md b/src/opencode/NOTES.md new file mode 100644 index 0000000..877251d --- /dev/null +++ b/src/opencode/NOTES.md @@ -0,0 +1,12 @@ +## OS support + +Debian/Ubuntu-based images. The feature only relies on `curl`, `jq`, and `git` — no Node.js or `npm` required. + +## What gets installed + +- **opencode** — installed under `/usr/local/share/opencode` via the official installer (`https://opencode.ai/install`), symlinked to `/usr/local/bin/opencode`. +- **rtk** *(optional, default on)* — fetched from the latest GitHub release of `rtk-ai/rtk` and placed at `/usr/local/bin/rtk`. + +## Architectures + +`x86_64` and `aarch64` (`arm64` is mapped to `aarch64`) for `rtk`. diff --git a/src/opencode/devcontainer-feature.json b/src/opencode/devcontainer-feature.json new file mode 100644 index 0000000..ff1a80c --- /dev/null +++ b/src/opencode/devcontainer-feature.json @@ -0,0 +1,20 @@ +{ + "id": "opencode", + "version": "2.1.0", + "name": "OpenCode", + "description": "Installs the OpenCode AI CLI and rtk.", + "documentationURL": "https://github.com/Synergy-Shock/devcontainer/tree/main/src/opencode", + "options": { + "version": { + "type": "string", + "default": "latest", + "description": "Version selector (currently unused by the curl installer).", + "proposals": ["latest"] + }, + "installRtk": { + "type": "boolean", + "default": true, + "description": "Install the rtk CLI." + } + } +} diff --git a/src/opencode/install.sh b/src/opencode/install.sh new file mode 100755 index 0000000..513c5de --- /dev/null +++ b/src/opencode/install.sh @@ -0,0 +1,70 @@ +#!/bin/bash +set -e + +#----------------------------------------------------------------------------------------------------- +# OpenCode Dev Container Feature +# Installs: opencode-ai, rtk +# Intended for use on Debian/Ubuntu-based images. Does not require Node.js. +#----------------------------------------------------------------------------------------------------- + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +OPENCODE_VERSION="${VERSION:-latest}" +INSTALL_RTK="${INSTALLRTK:-true}" + +ARCH=$(uname -m) +case "${ARCH}" in + x86_64) + RTK_TARGET="x86_64-unknown-linux-musl" + ;; + aarch64|arm64) + RTK_TARGET="aarch64-unknown-linux-gnu" + ;; + *) + echo "(!) Architecture ${ARCH} is not supported for rtk." + exit 1 + ;; +esac + +export DEBIAN_FRONTEND=noninteractive + +apt-get update +apt-get install -y --no-install-recommends curl jq git +rm -rf /var/lib/apt/lists/* + +# ------------------------------------------------------------------ +# Install rtk (optional) +# ------------------------------------------------------------------ +if [ "${INSTALL_RTK}" = "true" ]; then + echo "==> Installing rtk..." + RTK_LATEST=$(curl -fsSL https://api.github.com/repos/rtk-ai/rtk/releases/latest | jq -r '.tag_name') + RTK_URL="https://github.com/rtk-ai/rtk/releases/download/${RTK_LATEST}/rtk-${RTK_TARGET}.tar.gz" + curl -fsSL "${RTK_URL}" | tar -xz -C /usr/local/bin rtk + chmod +x /usr/local/bin/rtk + rtk --version +else + echo "==> Skipping rtk installation." +fi + +# ------------------------------------------------------------------ +# Install opencode +# ------------------------------------------------------------------ +echo "==> Installing opencode..." +# Install into a system-wide HOME and expose the launcher without relying on shell rc files. +OPENCODE_INSTALL_HOME="/usr/local/share/opencode" +mkdir -p "${OPENCODE_INSTALL_HOME}" +curl -fsSL https://opencode.ai/install | env -u VERSION HOME="${OPENCODE_INSTALL_HOME}" bash -s -- --no-modify-path +ln -sf "${OPENCODE_INSTALL_HOME}/.opencode/bin/opencode" /usr/local/bin/opencode +opencode --version + +echo "==> Adjusting permissions for ${_REMOTE_USER} user..." +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${OPENCODE_INSTALL_HOME}" 2>/dev/null || true + +echo "==> Pre-creating XDG directories for ${_REMOTE_USER} user..." +mkdir -p "${_REMOTE_USER_HOME}/.config" "${_REMOTE_USER_HOME}/.local" +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${_REMOTE_USER_HOME}" + +echo "==> OpenCode feature installation complete!" diff --git a/src/pnpm/NOTES.md b/src/pnpm/NOTES.md new file mode 100644 index 0000000..7f00ebf --- /dev/null +++ b/src/pnpm/NOTES.md @@ -0,0 +1,11 @@ +## OS support + +Debian/Ubuntu-based images with Node.js and `npm` pre-installed (e.g., the `mcr.microsoft.com/devcontainers/typescript-node` family). + +## Implementation details + +- `npm config set prefix /usr/local/share/npm-global` so global installs land in a system-wide location. +- `PNPM_HOME=/usr/local/share/pnpm` and `PNPM_STORE_DIR=/usr/local/share/pnpm-store`. +- `pnpm setup` is run under `SHELL=/bin/bash`. +- A `/etc/profile.d/pnpm.sh` snippet exports `NPM_CONFIG_PREFIX`, `PNPM_HOME`, `PNPM_STORE_DIR`, and prepends both bin dirs to `PATH` so login shells pick them up. +- The directories are `chown`-ed to `_REMOTE_USER` after install. diff --git a/src/pnpm/devcontainer-feature.json b/src/pnpm/devcontainer-feature.json new file mode 100644 index 0000000..4e01a13 --- /dev/null +++ b/src/pnpm/devcontainer-feature.json @@ -0,0 +1,21 @@ +{ + "id": "pnpm", + "version": "1.0.0", + "name": "pnpm", + "description": "Installs pnpm globally and configures the pnpm store directory and npm global prefix.", + "documentationURL": "https://github.com/Synergy-Shock/devcontainer/tree/main/features/pnpm", + "options": { + "version": { + "type": "string", + "default": "10", + "description": "Select or enter the version of pnpm to install globally.", + "proposals": ["latest", "10", "9", "8"] + } + }, + "containerEnv": { + "NPM_CONFIG_PREFIX": "/usr/local/share/npm-global", + "PNPM_HOME": "/usr/local/share/pnpm", + "PNPM_STORE_DIR": "/usr/local/share/pnpm-store", + "PATH": "/usr/local/share/npm-global/bin:/usr/local/share/pnpm:/usr/local/bin:${PATH}" + } +} diff --git a/src/pnpm/install.sh b/src/pnpm/install.sh new file mode 100755 index 0000000..b1ba73b --- /dev/null +++ b/src/pnpm/install.sh @@ -0,0 +1,55 @@ +#!/bin/bash +set -e + +#----------------------------------------------------------------------------------------------------- +# pnpm Dev Container Feature +# Installs: pnpm, configures npm global prefix and pnpm store directory +# Intended for use on Debian/Ubuntu-based images with Node.js/npm pre-installed +#----------------------------------------------------------------------------------------------------- + +if [ "$(id -u)" -ne 0 ]; then + echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' + exit 1 +fi + +PNPM_VERSION="${VERSION:-10}" + +export DEBIAN_FRONTEND=noninteractive + +apt-get update +apt-get install -y --no-install-recommends curl +rm -rf /var/lib/apt/lists/* + +echo "==> Configuring npm global prefix..." +NPM_GLOBAL_PREFIX="/usr/local/share/npm-global" +mkdir -p "${NPM_GLOBAL_PREFIX}" +npm config set prefix "${NPM_GLOBAL_PREFIX}" + +export PNPM_HOME="/usr/local/share/pnpm" +mkdir -p "${PNPM_HOME}" +export PATH="${PNPM_HOME}:${PATH}" + +PROFILE_SCRIPT="/etc/profile.d/pnpm.sh" +cat > "${PROFILE_SCRIPT}" << EOF +export NPM_CONFIG_PREFIX=${NPM_GLOBAL_PREFIX} +export PNPM_HOME=${PNPM_HOME} +export PNPM_STORE_DIR=/usr/local/share/pnpm-store +export PATH=${NPM_GLOBAL_PREFIX}/bin:${PNPM_HOME}:/usr/local/bin:\${PATH} +EOF +chmod +x "${PROFILE_SCRIPT}" + +echo "==> Installing pnpm@${PNPM_VERSION}..." +npm install -g "pnpm@${PNPM_VERSION}" +export SHELL=/bin/bash +pnpm setup +pnpm --version + +echo "==> Configuring pnpm store directory..." +PNPM_STORE="/usr/local/share/pnpm-store" +mkdir -p "${PNPM_STORE}" +pnpm config set store-dir "${PNPM_STORE}" + +echo "==> Adjusting permissions for ${_REMOTE_USER} user..." +chown -R "${_REMOTE_USER}:${_REMOTE_USER}" /usr/local/share/pnpm /usr/local/share/npm-global /usr/local/share/pnpm-store 2>/dev/null || true + +echo "==> pnpm feature installation complete!" diff --git a/test/_global/all_features.sh b/test/_global/all_features.sh new file mode 100755 index 0000000..01d5af2 --- /dev/null +++ b/test/_global/all_features.sh @@ -0,0 +1,17 @@ +#!/bin/bash +set -e + +source dev-container-features-test-lib + +check "pnpm on PATH" bash -c "command -v pnpm" +check "claude on PATH" bash -c "command -v claude" +check "but on PATH" bash -c "command -v but" +check "opencode on PATH" bash -c "command -v opencode" +check "rtk on PATH" bash -c "command -v rtk" + +check "pnpm --version" bash -c "pnpm --version" +check "claude --version" bash -c "claude --version" +check "but --version" bash -c "but --version" +check "opencode --version" bash -c "opencode --version" + +reportResults diff --git a/test/_global/scenarios.json b/test/_global/scenarios.json new file mode 100644 index 0000000..f015ed6 --- /dev/null +++ b/test/_global/scenarios.json @@ -0,0 +1,11 @@ +{ + "all_features": { + "image": "mcr.microsoft.com/devcontainers/typescript-node:24-trixie", + "features": { + "pnpm": {}, + "gitbutler": {}, + "opencode": {}, + "claude": {} + } + } +} diff --git a/test/claude/default.sh b/test/claude/default.sh new file mode 100755 index 0000000..835f682 --- /dev/null +++ b/test/claude/default.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +source dev-container-features-test-lib +check "claude --version" bash -c "claude --version | grep -E '[0-9]+\\.[0-9]+\\.[0-9]+'" +reportResults diff --git a/test/claude/pinned_version.sh b/test/claude/pinned_version.sh new file mode 100755 index 0000000..dd99c33 --- /dev/null +++ b/test/claude/pinned_version.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +source dev-container-features-test-lib +check "claude --version reports 2.1.145" bash -c "claude --version | grep -F '2.1.145'" +reportResults diff --git a/test/claude/scenarios.json b/test/claude/scenarios.json new file mode 100644 index 0000000..bdef3dc --- /dev/null +++ b/test/claude/scenarios.json @@ -0,0 +1,16 @@ +{ + "default": { + "image": "mcr.microsoft.com/devcontainers/base:trixie", + "features": { + "claude": {} + } + }, + "pinned_version": { + "image": "mcr.microsoft.com/devcontainers/base:trixie", + "features": { + "claude": { + "version": "2.1.145" + } + } + } +} diff --git a/test/claude/test.sh b/test/claude/test.sh new file mode 100755 index 0000000..ee0c384 --- /dev/null +++ b/test/claude/test.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +source dev-container-features-test-lib + +check "claude on PATH" bash -c "command -v claude" +check "claude --version" bash -c "claude --version | grep -E '[0-9]+\\.[0-9]+\\.[0-9]+'" +check "launcher symlinked" bash -c "test -L /usr/local/bin/claude" + +reportResults diff --git a/test/gitbutler/default.sh b/test/gitbutler/default.sh new file mode 100755 index 0000000..00a6a00 --- /dev/null +++ b/test/gitbutler/default.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +source dev-container-features-test-lib +check "but --version" bash -c "but --version" +reportResults diff --git a/test/gitbutler/scenarios.json b/test/gitbutler/scenarios.json new file mode 100644 index 0000000..2ea826e --- /dev/null +++ b/test/gitbutler/scenarios.json @@ -0,0 +1,8 @@ +{ + "default": { + "image": "mcr.microsoft.com/devcontainers/base:trixie", + "features": { + "gitbutler": {} + } + } +} diff --git a/test/gitbutler/test.sh b/test/gitbutler/test.sh new file mode 100755 index 0000000..fca4141 --- /dev/null +++ b/test/gitbutler/test.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -e + +source dev-container-features-test-lib + +check "but on PATH" bash -c "command -v but" +check "but --version" bash -c "but --version" +check "but is executable" bash -c "test -x /usr/local/bin/but" + +check "but setup" bash -c ' + set -e + repo="$(mktemp -d)" + cd "$repo" + git init -q -b main + git -c user.email=test@example.com -c user.name=test commit -q --allow-empty -m "init" + git remote add origin "$repo" + git update-ref refs/remotes/origin/main HEAD + but setup +' + +reportResults diff --git a/test/opencode/default.sh b/test/opencode/default.sh new file mode 100755 index 0000000..3ebdc84 --- /dev/null +++ b/test/opencode/default.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +source dev-container-features-test-lib +check "opencode --version" bash -c "opencode --version" +check "rtk present" bash -c "command -v rtk" +reportResults diff --git a/test/opencode/no_rtk.sh b/test/opencode/no_rtk.sh new file mode 100755 index 0000000..0c1b1cd --- /dev/null +++ b/test/opencode/no_rtk.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +source dev-container-features-test-lib +check "opencode --version" bash -c "opencode --version" +check "rtk NOT installed" bash -c "! command -v rtk" +reportResults diff --git a/test/opencode/scenarios.json b/test/opencode/scenarios.json new file mode 100644 index 0000000..e19725a --- /dev/null +++ b/test/opencode/scenarios.json @@ -0,0 +1,16 @@ +{ + "default": { + "image": "mcr.microsoft.com/devcontainers/base:trixie", + "features": { + "opencode": {} + } + }, + "no_rtk": { + "image": "mcr.microsoft.com/devcontainers/base:trixie", + "features": { + "opencode": { + "installRtk": false + } + } + } +} diff --git a/test/opencode/test.sh b/test/opencode/test.sh new file mode 100755 index 0000000..c6d190f --- /dev/null +++ b/test/opencode/test.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +source dev-container-features-test-lib + +check "opencode on PATH" bash -c "command -v opencode" +check "opencode --version" bash -c "opencode --version" +check "rtk on PATH" bash -c "command -v rtk" + +reportResults diff --git a/test/pnpm/default.sh b/test/pnpm/default.sh new file mode 100755 index 0000000..cdf4cb9 --- /dev/null +++ b/test/pnpm/default.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +source dev-container-features-test-lib +check "pnpm major is 10" bash -c "pnpm --version | grep -E '^10\\.'" +reportResults diff --git a/test/pnpm/pnpm_9.sh b/test/pnpm/pnpm_9.sh new file mode 100755 index 0000000..1d16e14 --- /dev/null +++ b/test/pnpm/pnpm_9.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -e +source dev-container-features-test-lib +check "pnpm major is 9" bash -c "pnpm --version | grep -E '^9\\.'" +reportResults diff --git a/test/pnpm/scenarios.json b/test/pnpm/scenarios.json new file mode 100644 index 0000000..20edb3a --- /dev/null +++ b/test/pnpm/scenarios.json @@ -0,0 +1,16 @@ +{ + "default": { + "image": "mcr.microsoft.com/devcontainers/typescript-node:24-trixie", + "features": { + "pnpm": {} + } + }, + "pnpm_9": { + "image": "mcr.microsoft.com/devcontainers/typescript-node:24-trixie", + "features": { + "pnpm": { + "version": "9" + } + } + } +} diff --git a/test/pnpm/test.sh b/test/pnpm/test.sh new file mode 100755 index 0000000..a55f463 --- /dev/null +++ b/test/pnpm/test.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +source dev-container-features-test-lib + +check "pnpm on PATH" bash -c "command -v pnpm" +check "pnpm --version" bash -c "pnpm --version | grep -E '[0-9]+\\.[0-9]+\\.[0-9]+'" +check "store dir configured" bash -c "test -d /usr/local/share/pnpm-store" +check "npm prefix configured" bash -c "test -d /usr/local/share/npm-global" +check "profile.d snippet" bash -c "test -x /etc/profile.d/pnpm.sh" + +reportResults