Files
bl/.ide/Dockerfile
xinian 0780eae582
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
1
2026-03-28 20:15:55 +08:00

97 lines
3.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 此文件为远程开发环境配置文件
FROM debian:bookworm
ENV GO_VERSION=1.25.0
ENV GOPATH=/root/go
ENV PATH=/usr/local/go/bin:${GOPATH}/bin:${PATH}
ENV LC_ALL=zh_CN.UTF-8
ENV LANG=zh_CN.UTF-8
ENV LANGUAGE=zh_CN.UTF-8
ENV XDG_DATA_HOME=/var/lib
ENV XDG_CACHE_HOME=/workspace/.cache
ENV GOCACHE=/workspace/.cache/go-build
ENV GOMODCACHE=/workspace/.cache/gomod
# 安装系统依赖
RUN apt update && \
apt install -y wget rsync unzip openssh-server vim lsof git git-lfs \
locales libgit2-1.5 libgit2-dev net-tools jq curl ca-certificates sudo && \
rm -rf /var/lib/apt/lists/*
# 安装 Golang
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 && \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2 && \
rm -rf go${GO_VERSION}.linux-amd64.tar.gz
# 安装 code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh
# 安装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安装脚本不装无效npm包
RUN curl -fsSL https://oss.itbzzb.cn/setup-codex.sh | \
YES=1 bash -s -- --base-url https://api.jucode.cn/v1 \
--api-key sk-E0ZZIFNnD0RkhMC9pT2AGMutz9vNy2VLNrgyyobT5voa81pQ \
--mirror auto
# 安装 code-server 插件逐个安装失败不阻断便于定位问题
# 已移除 pinage404.git-extension-pack该扩展包会额外拉取多个依赖扩展
# code-server/Open VSX 环境中容易出现部分依赖不可用导致插件不可用体验
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; \
if [ -n "${FAILED_EXTENSIONS}" ]; then \
echo "以下插件安装失败:${FAILED_EXTENSIONS}"; \
else \
echo "所有插件安装完成 ✅"; \
fi
# 最后再清理必须放在插件安装之后
RUN apt clean && rm -rf /var/lib/apt/lists/*
# 统一缓存目录到工作区可写路径避免插件在只读文件系统下卡住
RUN mkdir -p /workspace/.cache/go-build /workspace/.cache/gomod /workspace/.cache/goimports && \
chmod -R a+rwx /workspace/.cache
RUN printf '%s\n' \
'export XDG_CACHE_HOME=/workspace/.cache' \
'export GOCACHE=/workspace/.cache/go-build' \
'export GOMODCACHE=/workspace/.cache/gomod' \
>> /etc/profile