yumaojun03 4cbf3531bc ```
feat(devcontainer): 优化 Go 开发容器配置并预装 VS Code Server

- 使用 ghcr.io/devcontainers/base:ubuntu 基础镜像并通过 Dev Containers Feature 安装 Go 1.25
- 在 Dockerfile 中预装 VS Code Server 避免运行时下载卡顿,支持 ARM64/AMD64 架构
- 自动安装 dlv 调试工具并配置 vscode 用户权限
- 更新 README 文档说明备用本地 Dockerfile 方案和预装 VS Code Server 选项
```
2025-12-29 15:23:36 +08:00

34 lines
1.2 KiB
Docker
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.

# Go 1.25 + VS Code Server (ARM64/AMD64) Dev Container
FROM golang:1.25-bookworm
# 安装常用工具
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git sudo ca-certificates curl unzip \
&& rm -rf /var/lib/apt/lists/*
# 创建 vscode 用户
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
# 预装 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