diff --git a/.ide/Dockerfile b/.ide/Dockerfile index 5f0f2393f..a121f7667 100644 --- a/.ide/Dockerfile +++ b/.ide/Dockerfile @@ -1,28 +1,38 @@ # 远程开发环境完整配置 FROM debian:bookworm +# 环境变量 ENV GO_VERSION=1.25.0 -ENV GOPATH /root/go -ENV PATH="${PATH}:${GOPATH}/bin" -ENV LC_ALL zh_CN.UTF-8 -ENV LANG zh_CN.UTF-8 -ENV LANGUAGE zh_CN.UTF-8 +ENV GOPATH=/root/go +ENV PATH=${PATH}:/usr/local/go/bin:${GOPATH}/bin +ENV LC_ALL=zh_CN.UTF-8 +ENV LANG=zh_CN.UTF-8 +ENV LANGUAGE=zh_CN.UTF-8 -# 安装系统基础依赖 -RUN apt update && \ - apt install -y wget rsync unzip openssh-server vim lsof git git-lfs locales locales-all libgit2-1.5 libgit2-dev net-tools jq curl sudo lsb-release && \ +# 1. 安装系统依赖(最基础,先做) +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + wget rsync unzip openssh-server vim lsof git git-lfs \ + locales locales-all libgit2-1.5 libgit2-dev net-tools jq curl \ + ca-certificates gnupg lsb-release sudo && \ + apt-get clean && \ rm -rf /var/lib/apt/lists/* -# 安装 Golang + golangci-lint -RUN 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 && \ +# 2. 安装 Go +RUN wget -q 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 && \ ln -sf /usr/local/go/bin/go /usr/bin/go && \ ln -sf /usr/local/go/bin/gofmt /usr/bin/gofmt && \ - curl -sSfL https://raw.github.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2 && \ - rm -rf go${GO_VERSION}.linux-amd64.tar.gz + rm go${GO_VERSION}.linux-amd64.tar.gz -# 安装 code-server + 常用插件 +# 3. 安装 golangci-lint +RUN curl -sSfL https://raw.github.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2 + +# 4. 安装 code-server RUN curl -fsSL https://code-server.dev/install.sh | sh + +# 5. 安装 code-server 插件 RUN code-server --install-extension dbaeumer.vscode-eslint && \ code-server --install-extension pinage404.git-extension-pack && \ code-server --install-extension redhat.vscode-yaml && \ @@ -35,33 +45,27 @@ RUN code-server --install-extension dbaeumer.vscode-eslint && \ code-server --install-extension ms-azuretools.vscode-docker && \ code-server --install-extension PKief.material-icon-theme -# 安装 Go 开发工具 -RUN go install -v golang.org/x/tools/gopls@latest -RUN go install -v github.com/cweill/gotests/gotests@latest -RUN go install -v github.com/josharian/impl@latest -RUN go install -v github.com/haya14busa/goplay/cmd/goplay@latest -RUN go install -v github.com/go-delve/delve/cmd/dlv@latest -RUN go install github.com/goreleaser/goreleaser/v2@latest +# 6. 安装 Go 工具 +RUN 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 -# ===================== 修复完成:安装并配置 Codex ===================== -RUN set -eux && \ - # 基础配置 - BASE_URL="https://api.jucode.cn/v1" && \ - API_KEY="sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ" && \ - CODEX_DIR="/root/.codex" && \ - CONFIG_FILE="${CODEX_DIR}/config.toml" && \ - AUTH_FILE="${CODEX_DIR}/auth.json" && \ - # 安装 Node.js - curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ +# 7. 安装 Node.js (使用 npmmirror 源) +RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ apt-get install -y nodejs && \ - # 配置 npm 镜像 - npm config set registry https://registry.npmmirror.com/ && \ - # 安装 Codex - npm install -g @openai/codex && \ - # 创建配置目录 - mkdir -p "${CODEX_DIR}" && \ - # 写入 config.toml - cat > "${CONFIG_FILE}" << 'EOT' + npm config set registry https://registry.npmmirror.com/ + +# 8. 安装 Codex CLI +RUN npm install -g @openai/codex + +# 9. 配置 Codex (硬编码配置,零变量冲突) +RUN mkdir -p /root/.codex + +# 写入 config.toml +RUN cat > /root/.codex/config.toml << 'EOF' model_provider = "OpenAI" model = "gpt-5.4" model_reasoning_effort = "high" @@ -72,20 +76,17 @@ name = "OpenAI" base_url = "https://api.jucode.cn/v1" wire_api = "responses" requires_openai_auth = true -EOT - && \ - # 写入 auth.json - cat > "${AUTH_FILE}" << EOT +EOF + +# 写入 auth.json (直接把 Key 写在这里,避免转义) +RUN cat > /root/.codex/auth.json << 'EOF' { "auth_mode": "apikey", - "OPENAI_API_KEY": "${API_KEY}" + "OPENAI_API_KEY": "sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ" } -EOT - && \ - # 权限配置 - chmod 600 "${AUTH_FILE}" && \ - # 写入环境变量 - echo "export OPENAI_API_KEY=\"${API_KEY}\"" >> /root/.bashrc && \ - echo "export CODEX_API_KEY=\"${API_KEY}\"" >> /root/.bashrc && \ - # 清理 - apt clean && rm -rf /var/lib/apt/lists/* +EOF + +# 10. 配置环境变量和权限 +RUN chmod 600 /root/.codex/auth.json && \ + echo 'export OPENAI_API_KEY="sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ"' >> /root/.bashrc && \ + echo 'export CODEX_API_KEY="sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ"' >> /root/.bashrc