From 728b8748a9e653d9a4f899c41a1737f8351ba816 Mon Sep 17 00:00:00 2001 From: xinian Date: Sun, 29 Mar 2026 11:18:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E4=BB=B6=20Dockerfi?= =?UTF-8?q?le?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .ide/Dockerfile | 216 ++++++++++++++++++++++++------------------------ 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/.ide/Dockerfile b/.ide/Dockerfile index 4cb9bcf4c..ef5406286 100644 --- a/.ide/Dockerfile +++ b/.ide/Dockerfile @@ -27,123 +27,123 @@ ENV OPENAI_API_KEY="sk-foAHgsJtmanACECtBlFYZE2z4LkwBboEOYETO3ZdWvCxdmNr" # ========================================== RUN set -ex; \ apt update && \ - apt install -y --no-install-recommends \ - wget rsync unzip openssh-server vim lsof git git-lfs \ - locales libgit2-1.5 libgit2-dev net-tools jq curl ca-certificates sudo gnupg lsb-release && \ - # 安装 Golang \ - curl -fsSLO "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" && \ - rm -rf /usr/local/go && tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz" && \ - rm -f "go${GO_VERSION}.linux-amd64.tar.gz" && \ - # 安装 golangci-lint \ - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2 && \ - # 安装 Node.js 22 (供 Codex 使用) \ - curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ - apt install -y nodejs && \ - # 安装 code-server \ - curl -fsSL https://code-server.dev/install.sh | sh && \ - # 清理缓存 \ - apt clean && rm -rf /var/lib/apt/lists/* + apt install -y --no-install-recommends \ + wget rsync unzip openssh-server vim lsof git git-lfs \ + locales libgit2-1.5 libgit2-dev net-tools jq curl ca-certificates sudo gnupg lsb-release && \ + # 安装 Golang \ + curl -fsSLO "https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz" && \ + rm -rf /usr/local/go && tar -C /usr/local -xzf "go${GO_VERSION}.linux-amd64.tar.gz" && \ + rm -f "go${GO_VERSION}.linux-amd64.tar.gz" && \ + # 安装 golangci-lint \ + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2 && \ + # 安装 Node.js 22 (供 Codex 使用) \ + curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ + apt install -y nodejs && \ + # 安装 code-server \ + curl -fsSL https://code-server.dev/install.sh | sh && \ + # 清理缓存 \ + apt clean && rm -rf /var/lib/apt/lists/* - # ========================================== - # 4. 安装 Go & Node 工具链 - # ========================================== - RUN set -ex; \ - go install -v golang.org/x/tools/gopls@latest && \ - go install -v github.com/cweill/gotests/gotests@latest && \ - go install -v github.com/josharian/impl@latest && \ - go install -v github.com/haya14busa/goplay/cmd/goplay@latest && \ - go install -v github.com/go-delve/delve/cmd/dlv@latest && \ - go install github.com/goreleaser/goreleaser/v2@latest && \ - npm install -g @openai/codex +# ========================================== +# 4. 安装 Go & Node 工具链 +# ========================================== +RUN set -ex; \ + go install -v golang.org/x/tools/gopls@latest && \ + go install -v github.com/cweill/gotests/gotests@latest && \ + go install -v github.com/josharian/impl@latest && \ + go install -v github.com/haya14busa/goplay/cmd/goplay@latest && \ + go install -v github.com/go-delve/delve/cmd/dlv@latest && \ + go install github.com/goreleaser/goreleaser/v2@latest && \ + npm install -g @openai/codex - # ========================================== - # 5. 安装 code-server 插件 - # ========================================== - RUN set -eux; \ - USER_DATA_DIR=/var/lib/code-server; \ - EXTENSIONS_DIR="${USER_DATA_DIR}/extensions"; \ - mkdir -p "${EXTENSIONS_DIR}" /root/.vscode-server; \ - FAILED_EXTENSIONS=""; \ - for ext in \ - dbaeumer.vscode-eslint \ - redhat.vscode-yaml \ - esbenp.prettier-vscode \ - golang.go \ - eamodio.gitlens \ - waderyan.gitblame \ - donjayamanne.githistory \ - mhutchie.git-graph \ - tencent-cloud.coding-copilot\ - ; do \ - if ! /usr/bin/code-server --install-extension "${ext}" --user-data-dir "${USER_DATA_DIR}" --extensions-dir "${EXTENSIONS_DIR}"; then \ - FAILED_EXTENSIONS="${FAILED_EXTENSIONS} ${ext}"; \ - echo "WARN: extension install failed: ${ext}"; \ - fi; \ - done; \ - rm -rf /root/.vscode-server/extensions /root/extensions; \ - ln -s "${EXTENSIONS_DIR}" /root/.vscode-server/extensions; \ - ln -s "${EXTENSIONS_DIR}" /root/extensions; \ - chmod -R a+rwX "${USER_DATA_DIR}"; \ - chmod -R a+rX /root/.vscode-server; \ - [ -z "${FAILED_EXTENSIONS}" ] && echo "所有插件安装完成 ✅" || echo "以下插件安装失败:${FAILED_EXTENSIONS}" +# ========================================== +# 5. 安装 code-server 插件 +# ========================================== +RUN set -eux; \ + USER_DATA_DIR=/var/lib/code-server; \ + EXTENSIONS_DIR="${USER_DATA_DIR}/extensions"; \ + mkdir -p "${EXTENSIONS_DIR}" /root/.vscode-server; \ + FAILED_EXTENSIONS=""; \ + for ext in \ + dbaeumer.vscode-eslint \ + redhat.vscode-yaml \ + esbenp.prettier-vscode \ + golang.go \ + eamodio.gitlens \ + waderyan.gitblame \ + donjayamanne.githistory \ + mhutchie.git-graph \ + tencent-cloud.coding-copilot\ + ; do \ + if ! /usr/bin/code-server --install-extension "${ext}" --user-data-dir "${USER_DATA_DIR}" --extensions-dir "${EXTENSIONS_DIR}"; then \ + FAILED_EXTENSIONS="${FAILED_EXTENSIONS} ${ext}"; \ + echo "WARN: extension install failed: ${ext}"; \ + fi; \ + done; \ + rm -rf /root/.vscode-server/extensions /root/extensions; \ + ln -s "${EXTENSIONS_DIR}" /root/.vscode-server/extensions; \ + ln -s "${EXTENSIONS_DIR}" /root/extensions; \ + chmod -R a+rwX "${USER_DATA_DIR}"; \ + chmod -R a+rX /root/.vscode-server; \ + [ -z "${FAILED_EXTENSIONS}" ] && echo "所有插件安装完成 ✅" || echo "以下插件安装失败:${FAILED_EXTENSIONS}" - # ========================================== - # 6. 统一缓存目录 & 环境变量 - # ========================================== - RUN mkdir -p /workspace/.cache/go-build /workspace/.cache/gomod /workspace/.cache/goimports && \ - chmod -R a+rwx /workspace/.cache && \ - printf '%s\n' \ - 'export XDG_CACHE_HOME=/workspace/.cache' \ - 'export GOCACHE=/workspace/.cache/go-build' \ - 'export GOMODCACHE=/workspace/.cache/gomod' \ - >> /etc/profile +# ========================================== +# 6. 统一缓存目录 & 环境变量 +# ========================================== +RUN mkdir -p /workspace/.cache/go-build /workspace/.cache/gomod /workspace/.cache/goimports && \ + chmod -R a+rwx /workspace/.cache && \ + printf '%s\n' \ + 'export XDG_CACHE_HOME=/workspace/.cache' \ + 'export GOCACHE=/workspace/.cache/go-build' \ + 'export GOMODCACHE=/workspace/.cache/gomod' \ + >> /etc/profile - # ========================================== - # 7. 核心优化:内置动态 Entrypoint 脚本 - # (每次容器启动时,根据当前环境变量动态生成 Codex 配置) - # ========================================== - RUN cat > /entrypoint.sh <<'SCRIPT' - #!/bin/bash - set -e +# ========================================== +# 7. 核心优化:内置动态 Entrypoint 脚本 +# (每次容器启动时,根据当前环境变量动态生成 Codex 配置) +# ========================================== +RUN cat > /entrypoint.sh <<'SCRIPT' +#!/bin/bash +set -e - # 确保目录存在 - mkdir -p /root/.codex +# 确保目录存在 +mkdir -p /root/.codex - # 动态渲染 config.toml - cat > /root/.codex/config.toml < /root/.codex/config.toml < /root/.codex/auth.json < /root/.codex/auth.json <