default env
0 parents
Showing
5 changed files
with
300 additions
and
0 deletions
container/Dockerfile
0 → 100644
| 1 | FROM debian:13.4 | ||
| 2 | |||
| 3 | RUN sed -i 's/deb.debian.org/mirrors.tencent.com/g' /etc/apt/sources.list.d/debian.sources | ||
| 4 | RUN apt-get update && \ | ||
| 5 | apt-get install -y wget unzip lsof nload htop net-tools dnsutils openssh-server \ | ||
| 6 | build-essential curl git gcc libc6-dev \ | ||
| 7 | pkg-config libssl-dev ca-certificates vim ripgrep jq sudo && \ | ||
| 8 | apt-get clean && \ | ||
| 9 | rm -rf /var/lib/apt/lists/* | ||
| 10 | |||
| 11 | RUN useradd -m -s /bin/bash user && \ | ||
| 12 | echo "user:user" | chpasswd && \ | ||
| 13 | adduser user sudo | ||
| 14 | |||
| 15 | RUN echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers | ||
| 16 | |||
| 17 | USER user | ||
| 18 | # Install code-server and extensions | ||
| 19 | RUN curl -fsSL https://code-server.dev/install.sh | sudo sh \ | ||
| 20 | && code-server --install-extension golang.go \ | ||
| 21 | && code-server --install-extension cnbcool.cnb-welcome \ | ||
| 22 | && code-server --install-extension formulahendry.code-runner \ | ||
| 23 | && code-server --install-extension ms-kubernetes-tools.vscode-kubernetes-tools \ | ||
| 24 | && code-server --install-extension tencent-cloud.coding-copilot \ | ||
| 25 | && code-server --install-extension github.github-vscode-theme \ | ||
| 26 | && code-server --install-extension ms-ceintl.vscode-language-pack-zh-hans \ | ||
| 27 | && code-server --install-extension eddieposey.vscode-icons-mac \ | ||
| 28 | && code-server --install-extension oderwat.indent-rainbow \ | ||
| 29 | && code-server --install-extension yzhang.markdown-all-in-one | ||
| 30 | # leetcode.vscode-leetcode | ||
| 31 | #RUN wget -c -N "https://marketplace.visualstudio.com/_apis/public/gallery/publishers/panxiaoan/vsextensions/themes-falcon-vscode/3.0.1/vspackage" -O panxiaoan.themes-falcon-vscode-3.0.1.vsix && \ | ||
| 32 | # code-server --install-extension ./panxiaoan.themes-falcon-vscode-3.0.1.vsix | ||
| 33 | |||
| 34 | ENV TZ=Asia/Shanghai | ||
| 35 | ENV GIT_TERMINAL_PROMPT=0 | ||
| 36 | |||
| 37 | RUN sudo apt-get -y update && sudo apt-get -y install hx wget curl git git-lfs zsh tmux tzdata && \ | ||
| 38 | RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" && \ | ||
| 39 | sudo apt-get install -y locales \ | ||
| 40 | && sudo rm -rf /var/lib/apt/lists/* \ | ||
| 41 | && sudo sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen \ | ||
| 42 | && sudo localedef -i zh_CN -c -f UTF-8 -A /usr/share/locale/locale.alias zh_CN.UTF-8 \ | ||
| 43 | && sudo dpkg-reconfigure --frontend=noninteractive locales | ||
| 44 | |||
| 45 | RUN sudo /usr/bin/chsh -s $(which zsh) | ||
| 46 | ENV LANG=zh_CN.UTF-8 | ||
| 47 | ENV LANGUAGE=zh_CN:zh | ||
| 48 | # ENV LC_ALL=zh_CN.UTF-8 | ||
| 49 | RUN wget -c -N https://github.com/neovim/neovim/releases/download/v0.12.2/nvim-linux-x86_64.tar.gz && \ | ||
| 50 | sudo tar xf nvim-linux-x86_64.tar.gz -C /usr/local && \ | ||
| 51 | sudo ln -sf /usr/local/nvim-linux-x86_64/bin/nvim /usr/bin/nvim | ||
| 52 | |||
| 53 | RUN cd /home/user && git clone --single-branch https://github.com/gpakosz/.tmux.git && \ | ||
| 54 | ln -s -f .tmux/.tmux.conf && cp .tmux/.tmux.conf.local . |
scripts/bootstrap-claude-plugins.sh
0 → 100755
| 1 | # !/usr/bin/env bash | ||
| 2 | set -euo pipefail | ||
| 3 | |||
| 4 | CLAUDE_CONFIG_DIR=${CLAUDE_CONFIG_DIR:-"${HOME}/.claude"} | ||
| 5 | BOOTSTRAP_MARKER=${BOOTSTRAP_MARKER:-"${CLAUDE_CONFIG_DIR}/.bootstrap-plugins-done"} | ||
| 6 | CLAUDE_FORCE_PLUGIN_BOOTSTRAP=${CLAUDE_FORCE_PLUGIN_BOOTSTRAP:-0} | ||
| 7 | CLAUDE_SKIP_SETTINGS_INIT=${CLAUDE_SKIP_SETTINGS_INIT:-0} | ||
| 8 | CLAUDE_ENABLE_THIRD_PARTY=${CLAUDE_ENABLE_THIRD_PARTY:-0} | ||
| 9 | DEFAULT_PLUGIN_LIST="superpowers pr-review-toolkit claude-code-setup ralph-loop typescript-lsp rust-analyzer-lsp" | ||
| 10 | CLAUDE_PLUGIN_LIST=${CLAUDE_PLUGIN_LIST:-"$DEFAULT_PLUGIN_LIST"} | ||
| 11 | |||
| 12 | require_claude() { | ||
| 13 | if ! command -v claude >/dev/null 2>&1; then | ||
| 14 | echo "[error] 未找到 claude 命令,请先安装 Claude Code。" >&2 | ||
| 15 | exit 1 | ||
| 16 | fi | ||
| 17 | } | ||
| 18 | |||
| 19 | check_auth() { | ||
| 20 | if [ -n "${ANTHROPIC_API_KEY:-}" ] || [ -n "${CLAUDE_CODE_OAUTH_TOKEN:-}" ] || [ -f "${CLAUDE_CONFIG_DIR}/.credentials.json" ]; then | ||
| 21 | return | ||
| 22 | fi | ||
| 23 | |||
| 24 | cat <<'EOF' | ||
| 25 | [warn] 未检测到认证信息。 | ||
| 26 | [warn] 可稍后配置以下任一方式后重跑脚本: | ||
| 27 | export ANTHROPIC_API_KEY=... | ||
| 28 | export CLAUDE_CODE_OAUTH_TOKEN=... | ||
| 29 | EOF | ||
| 30 | } | ||
| 31 | |||
| 32 | prepare_config_dir() { | ||
| 33 | mkdir -p "$CLAUDE_CONFIG_DIR" | ||
| 34 | chmod 700 "$CLAUDE_CONFIG_DIR" | ||
| 35 | } | ||
| 36 | |||
| 37 | already_bootstrapped() { | ||
| 38 | [ "$CLAUDE_FORCE_PLUGIN_BOOTSTRAP" != "1" ] && [ -f "$BOOTSTRAP_MARKER" ] | ||
| 39 | } | ||
| 40 | |||
| 41 | install_plugin() { | ||
| 42 | local plugin=$1 | ||
| 43 | echo "[plugin] 安装 $plugin..." | ||
| 44 | if printf '/plugin install %s@claude-plugins-official\n/reload-plugins\n/exit\n' "$plugin" | claude >/tmp/claude-plugin-${plugin}.log 2>&1; then | ||
| 45 | echo "[plugin] $plugin 安装完成" | ||
| 46 | return 0 | ||
| 47 | fi | ||
| 48 | |||
| 49 | echo "[plugin] $plugin 安装失败,详见 /tmp/claude-plugin-${plugin}.log" >&2 | ||
| 50 | return 1 | ||
| 51 | } | ||
| 52 | |||
| 53 | init_settings() { | ||
| 54 | local settings_file="${CLAUDE_CONFIG_DIR}/settings.json" | ||
| 55 | if [ "$CLAUDE_SKIP_SETTINGS_INIT" = "1" ] || [ -f "$settings_file" ]; then | ||
| 56 | return | ||
| 57 | fi | ||
| 58 | |||
| 59 | cat >"$settings_file" <<'EOF' | ||
| 60 | { | ||
| 61 | "modelType": "anthropic", | ||
| 62 | "alwaysThinkingEnabled": false, | ||
| 63 | "skipDangerousModePermissionPrompt": true, | ||
| 64 | "permissions": { | ||
| 65 | "allow": [ | ||
| 66 | "git status", | ||
| 67 | "git diff", | ||
| 68 | "git log", | ||
| 69 | "ls", | ||
| 70 | "pwd" | ||
| 71 | ], | ||
| 72 | "deny": [] | ||
| 73 | } | ||
| 74 | } | ||
| 75 | EOF | ||
| 76 | } | ||
| 77 | |||
| 78 | install_default_plugins() { | ||
| 79 | local failed=0 | ||
| 80 | local plugin | ||
| 81 | |||
| 82 | echo "[info] 默认插件列表: $CLAUDE_PLUGIN_LIST" | ||
| 83 | for plugin in $CLAUDE_PLUGIN_LIST; do | ||
| 84 | if ! install_plugin "$plugin"; then | ||
| 85 | failed=1 | ||
| 86 | fi | ||
| 87 | done | ||
| 88 | |||
| 89 | if [ "$CLAUDE_ENABLE_THIRD_PARTY" = "1" ]; then | ||
| 90 | echo "[info] 已启用第三方扩展位,但当前未配置第三方插件。" | ||
| 91 | fi | ||
| 92 | |||
| 93 | return "$failed" | ||
| 94 | } | ||
| 95 | |||
| 96 | write_marker() { | ||
| 97 | date -u +"%Y-%m-%dT%H:%M:%SZ" >"$BOOTSTRAP_MARKER" | ||
| 98 | } | ||
| 99 | |||
| 100 | main() { | ||
| 101 | require_claude | ||
| 102 | prepare_config_dir | ||
| 103 | check_auth | ||
| 104 | |||
| 105 | if already_bootstrapped; then | ||
| 106 | echo "[info] 检测到已完成 bootstrap,跳过。" | ||
| 107 | return | ||
| 108 | fi | ||
| 109 | |||
| 110 | install_default_plugins | ||
| 111 | init_settings | ||
| 112 | write_marker | ||
| 113 | echo "[done] Claude Code 插件 bootstrap 完成。" | ||
| 114 | } | ||
| 115 | |||
| 116 | main "$@" |
scripts/bootstrap.sh
0 → 100644
scripts/claude_install.sh
0 → 100644
| 1 | |||
| 2 | #!/usr/bin/env bash | ||
| 3 | set -euo pipefail | ||
| 4 | |||
| 5 | export DEBIAN_FRONTEND=${DEBIAN_FRONTEND:-noninteractive} | ||
| 6 | |||
| 7 | SCRIPT_DIR=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) | ||
| 8 | BOOTSTRAP_SCRIPT=${CLAUDE_BOOTSTRAP_SCRIPT:-"$SCRIPT_DIR/bootstrap-claude-plugins.sh"} | ||
| 9 | CLAUDE_SKIP_BOOTSTRAP=${CLAUDE_SKIP_BOOTSTRAP:-0} | ||
| 10 | |||
| 11 | require_root() { | ||
| 12 | if [ "${EUID:-$(id -u)}" -ne 0 ]; then | ||
| 13 | echo "[error] 请使用 root 运行此脚本。" >&2 | ||
| 14 | exit 1 | ||
| 15 | fi | ||
| 16 | } | ||
| 17 | |||
| 18 | install_base_packages() { | ||
| 19 | echo "[1/5] 安装基础依赖..." | ||
| 20 | apt-get update | ||
| 21 | apt-get install -y --no-install-recommends \ | ||
| 22 | bash \ | ||
| 23 | ca-certificates \ | ||
| 24 | curl \ | ||
| 25 | git \ | ||
| 26 | jq \ | ||
| 27 | less \ | ||
| 28 | procps \ | ||
| 29 | ripgrep \ | ||
| 30 | fd-find \ | ||
| 31 | python3 \ | ||
| 32 | python3-venv \ | ||
| 33 | python3-pip \ | ||
| 34 | nodejs \ | ||
| 35 | npm | ||
| 36 | } | ||
| 37 | |||
| 38 | install_claude_code() { | ||
| 39 | echo "[2/5] 配置 Claude Code 官方 apt 源..." | ||
| 40 | install -d -m 0755 /etc/apt/keyrings | ||
| 41 | curl -fsSL https://downloads.claude.ai/keys/claude-code.asc \ | ||
| 42 | -o /etc/apt/keyrings/claude-code.asc | ||
| 43 | chmod a+r /etc/apt/keyrings/claude-code.asc | ||
| 44 | |||
| 45 | cat >/etc/apt/sources.list.d/claude-code.list <<'EOF' | ||
| 46 | deb [signed-by=/etc/apt/keyrings/claude-code.asc] https://downloads.claude.ai/claude-code/apt/stable stable main | ||
| 47 | EOF | ||
| 48 | |||
| 49 | echo "[3/5] 安装 Claude Code..." | ||
| 50 | apt-get update | ||
| 51 | apt-get install -y claude-code | ||
| 52 | } | ||
| 53 | |||
| 54 | verify_install() { | ||
| 55 | echo "[4/5] 校验 Claude Code 安装..." | ||
| 56 | claude --version | ||
| 57 | } | ||
| 58 | |||
| 59 | run_bootstrap() { | ||
| 60 | if [ "$CLAUDE_SKIP_BOOTSTRAP" = "1" ]; then | ||
| 61 | echo "[5/5] 跳过插件 bootstrap。" | ||
| 62 | return | ||
| 63 | fi | ||
| 64 | |||
| 65 | if [ ! -x "$BOOTSTRAP_SCRIPT" ]; then | ||
| 66 | echo "[error] 未找到可执行 bootstrap 脚本: $BOOTSTRAP_SCRIPT" >&2 | ||
| 67 | exit 1 | ||
| 68 | fi | ||
| 69 | |||
| 70 | echo "[5/5] 执行默认插件 bootstrap..." | ||
| 71 | "$BOOTSTRAP_SCRIPT" | ||
| 72 | } | ||
| 73 | |||
| 74 | print_next_steps() { | ||
| 75 | cat <<'EOF' | ||
| 76 | |||
| 77 | 安装完成。 | ||
| 78 | |||
| 79 | 认证方式二选一: | ||
| 80 | export ANTHROPIC_API_KEY=your_api_key | ||
| 81 | export CLAUDE_CODE_OAUTH_TOKEN=your_oauth_token | ||
| 82 | |||
| 83 | 默认插件: | ||
| 84 | superpowers | ||
| 85 | pr-review-toolkit | ||
| 86 | claude-code-setup | ||
| 87 | ralph-loop | ||
| 88 | typescript-lsp | ||
| 89 | rust-analyzer-lsp | ||
| 90 | |||
| 91 | 如需仅安装 Claude Code 而跳过插件初始化: | ||
| 92 | CLAUDE_SKIP_BOOTSTRAP=1 ./install-claude-code-debian13.sh | ||
| 93 | EOF | ||
| 94 | } | ||
| 95 | |||
| 96 | require_root | ||
| 97 | install_base_packages | ||
| 98 | install_claude_code | ||
| 99 | verify_install | ||
| 100 | run_bootstrap | ||
| 101 | print_next_steps | ||
| 102 |
scripts/install_some_apps.sh
0 → 100644
| 1 | #!/bin.bash | ||
| 2 | cd ~ | ||
| 3 | |||
| 4 | curl -sSLk https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py310_23.11.0-2-Linux-x86_64.sh -o Miniconda3-py310_23.11.0-2-Linux-x86_64.sh && \ | ||
| 5 | bash ./Miniconda3-py310_23.11.0-2-Linux-x86_64.sh -b -p /usr/local/miniconda3 | ||
| 6 | |||
| 7 | curl -sSLk https://unofficial-builds.nodejs.org/download/release/v22.22.2/node-v22.22.2-linux-x64-glibc-217.tar.gz -o node-v22.22.2-linux-x64-glibc-217.tar.gz && \ | ||
| 8 | tar -xzf node-v22.22.2-linux-x64-glibc-217.tar.gz -C /usr/local/ && \ | ||
| 9 | ln -sf /usr/local/node-v22.22.2-linux-x64-glibc-217/bin/node /usr/local/bin/node && \ | ||
| 10 | ln -sf /usr/local/node-v22.22.2-linux-x64-glibc-217/bin/npm /usr/local/bin/npm && \ | ||
| 11 | rm -rf /node-v22.22.2-linux-x64-glibc-217.tar.gz | ||
| 12 | |||
| 13 | |||
| 14 | # 安装 Bun | ||
| 15 | curl -fsSL https://bun.sh/install | bash | ||
| 16 | |||
| 17 | # 重新加载 shell 配置 | ||
| 18 | source ~/.zshrc # 或 exec /usr/bin/zsh | ||
| 19 | |||
| 20 | # 验证安装 | ||
| 21 | # ~/.local/bin/bun --version | ||
| 22 | |||
| 23 | npm i -g opencode-ai --registry https://mirrors.cloud.tencent.com/npm/ | ||
| 24 | |||
| 25 | # cp -r ./container/helix-config /root/.config/helix | ||
| 26 |
-
Please register or sign in to post a comment