2025-12-29 15:23:36 +08:00
|
|
|
|
# Go 1.25 + VS Code Server (ARM64/AMD64) Dev Container
|
2025-12-28 18:33:35 +08:00
|
|
|
|
FROM golang:1.25-bookworm
|
|
|
|
|
|
|
2025-12-29 15:23:36 +08:00
|
|
|
|
# 安装常用工具
|
2025-12-28 18:33:35 +08:00
|
|
|
|
RUN apt-get update \
|
|
|
|
|
|
&& apt-get install -y --no-install-recommends \
|
|
|
|
|
|
git sudo ca-certificates curl unzip \
|
|
|
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
2025-12-29 15:23:36 +08:00
|
|
|
|
# 创建 vscode 用户
|
2025-12-28 18:33:35 +08:00
|
|
|
|
RUN useradd -m -s /bin/bash vscode \
|
|
|
|
|
|
&& echo "vscode ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-vscode \
|
|
|
|
|
|
&& chmod 0440 /etc/sudoers.d/90-vscode
|
|
|
|
|
|
|
|
|
|
|
|
WORKDIR /workspaces
|
2025-12-29 15:23:36 +08:00
|
|
|
|
|
|
|
|
|
|
# 预装 VS Code Server,避免运行时下载卡顿
|
|
|
|
|
|
ARG VSCODE_COMMIT="994fd12f8d3a5aa16f17d42c041e5809167e845a"
|
|
|
|
|
|
RUN set -eux; \
|
|
|
|
|
|
arch=$(dpkg --print-architecture); \
|
|
|
|
|
|
case "$arch" in \
|
|
|
|
|
|
amd64) server_arch=linux-x64 ;; \
|
|
|
|
|
|
arm64) server_arch=linux-arm64 ;; \
|
|
|
|
|
|
*) echo "Unsupported architecture: $arch"; exit 1 ;; \
|
|
|
|
|
|
esac; \
|
|
|
|
|
|
mkdir -p /home/vscode/.vscode-server/bin/${VSCODE_COMMIT}; \
|
|
|
|
|
|
curl -fsSL "https://update.code.visualstudio.com/commit:${VSCODE_COMMIT}/server-${server_arch}/stable" -o /tmp/vscode-server.tar.gz; \
|
|
|
|
|
|
tar -xzf /tmp/vscode-server.tar.gz -C /home/vscode/.vscode-server/bin/${VSCODE_COMMIT} --strip-components=1; \
|
|
|
|
|
|
chown -R vscode:vscode /home/vscode/.vscode-server
|
|
|
|
|
|
|
|
|
|
|
|
# 容器启动后自动安装 dlv 并下载依赖
|
|
|
|
|
|
USER vscode
|
|
|
|
|
|
RUN go install github.com/go-delve/delve/cmd/dlv@latest
|