编辑文件 Dockerfile
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
xinian
2026-03-28 13:22:58 +08:00
committed by cnb
parent 30cf53402c
commit 076e021752

View File

@@ -1,71 +1,60 @@
# 远程开发环境完整配置 # 此文件为远程开发环境配置文件
FROM debian:bookworm FROM debian:bookworm
# 环境变量
ENV GO_VERSION=1.25.0 ENV GO_VERSION=1.25.0
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
# 1. 安装系统依赖最基础先做 RUN apt update &&\
RUN apt-get 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 &&\
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/* rm -rf /var/lib/apt/lists/*
# 2. 安装 Go # install golang
RUN wget -q https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz && \ RUN curl -fsSLO https://dl.google.com/go/go${GO_VERSION}.linux-amd64.tar.gz &&\
rm -rf /usr/local/go && \ rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-amd64.tar.gz &&\
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/go /usr/bin/go && \ ln -sf /usr/local/go/bin/gofmt /usr/bin/gofmt &&\
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 go${GO_VERSION}.linux-amd64.tar.gz rm -rf go${GO_VERSION}.linux-amd64.tar.gz
# 3. 安装 golangci-lint # install code-server
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 RUN curl -fsSL https://code-server.dev/install.sh | sh
RUN code-server --install-extension dbaeumer.vscode-eslint &&\
code-server --install-extension pinage404.git-extension-pack &&\
code-server --install-extension redhat.vscode-yaml &&\
code-server --install-extension esbent.prettier-vscode &&\
code-server --install-extension golang.go &&\
code-server --install-extension eamodio.gitlens &&\
code-server --install-extension waderyan.gitblame &&\
code-server --install-extension donjayamanne.githistory &&\
code-server --install-extension mhutchie.git-graph &&\
code-server --install-extension ms-azuretools.vscode-docker &&\
code-server --install-extension PKief.material-icon-theme &&\
code-server --install-extension tencent-cloud.coding-copilot &&\
echo done
# 5. 安装 code-server 插件 # install Go Tools
RUN code-server --install-extension dbaeumer.vscode-eslint && \ ENV GOPATH /root/go
code-server --install-extension pinage404.git-extension-pack && \ ENV PATH="${PATH}:${GOPATH}/bin"
code-server --install-extension redhat.vscode-yaml && \
code-server --install-extension esbenp.prettier-vscode && \
code-server --install-extension golang.go && \
code-server --install-extension eamodio.gitlens && \
code-server --install-extension waderyan.gitblame && \
code-server --install-extension donjayamanne.githistory && \
code-server --install-extension mhutchie.git-graph && \
code-server --install-extension ms-azuretools.vscode-docker && \
code-server --install-extension PKief.material-icon-theme
# 6. 安装 Go 工具 RUN go install -v golang.org/x/tools/gopls@latest
RUN go install -v golang.org/x/tools/gopls@latest && \ RUN go install -v github.com/cweill/gotests/gotests@latest
go install -v github.com/cweill/gotests/gotests@latest && \ RUN go install -v github.com/josharian/impl@latest
go install -v github.com/josharian/impl@latest && \ RUN go install -v github.com/haya14busa/goplay/cmd/goplay@latest
go install -v github.com/haya14busa/goplay/cmd/goplay@latest && \ RUN go install -v github.com/go-delve/delve/cmd/dlv@latest
go install -v github.com/go-delve/delve/cmd/dlv@latest && \ # install goreleaser
go install github.com/goreleaser/goreleaser/v2@latest RUN go install github.com/goreleaser/goreleaser/v2@latest
# 7. 安装 Node.js (使用 npmmirror ) # ===================== 以下为新增安全安装 codex不影响原有插件 =====================
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \ RUN apt update && \
apt-get install -y nodejs && \ apt install -y nodejs npm && \
npm config set registry https://registry.npmmirror.com/ npm config set registry https://registry.npmmirror.com/ && \
npm install -g @openai/codex && \
rm -rf /var/lib/apt/lists/*
# 8. 安装 Codex CLI # 创建 codex 配置目录
RUN npm install -g @openai/codex
# 9. 配置 Codex (硬编码配置零变量冲突)
RUN mkdir -p /root/.codex RUN mkdir -p /root/.codex
# 写入 config.toml # 写入 config.toml不变动任何 vscode 相关路径
RUN cat > /root/.codex/config.toml << 'EOF' RUN cat > /root/.codex/config.toml <<'EOF'
model_provider = "OpenAI" model_provider = "OpenAI"
model = "gpt-5.4" model = "gpt-5.4"
model_reasoning_effort = "high" model_reasoning_effort = "high"
@@ -78,15 +67,20 @@ wire_api = "responses"
requires_openai_auth = true requires_openai_auth = true
EOF EOF
# 写入 auth.json (直接把 Key 写在这里避免转义) # 写入 auth.json
RUN cat > /root/.codex/auth.json << 'EOF' RUN cat > /root/.codex/auth.json <<'EOF'
{ {
"auth_mode": "apikey", "auth_mode": "apikey",
"OPENAI_API_KEY": "sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ" "OPENAI_API_KEY": "sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ"
} }
EOF EOF
# 10. 配置环境变量和权限 # 权限 + 环境变量
RUN chmod 600 /root/.codex/auth.json && \ RUN chmod 600 /root/.codex/auth.json && \
echo 'export OPENAI_API_KEY="sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ"' >> /root/.bashrc && \ echo "export OPENAI_API_KEY=sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ" >> /root/.bashrc && \
echo 'export CODEX_API_KEY="sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ"' >> /root/.bashrc echo "export CODEX_API_KEY=sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ" >> /root/.bashrc
# 语言环境
ENV LC_ALL zh_CN.UTF-8
ENV LANG zh_CN.UTF-8
ENV LANGUAGE zh_CN.UTF-8