Add Go support to dev containers and Makefile

This commit is contained in:
2026-02-25 14:07:16 +08:00
parent d04243817e
commit dc947beafa
4 changed files with 19 additions and 7 deletions

View File

@@ -12,14 +12,18 @@ RUN dnf update -y && dnf install -y \
# 2. 环境变量配置
ENV CARGO_HOME=/usr/local/cargo \
RUSTUP_HOME=/usr/local/rustup \
BUN_INSTALL="/root/.bun"
ENV PATH="$BUN_INSTALL/bin:/usr/local/cargo/bin:${PATH}"
BUN_INSTALL="/root/.bun" \
GOPATH="/root/go"
ENV PATH="$BUN_INSTALL/bin:/usr/local/cargo/bin:/usr/local/go/bin:$GOPATH/bin:${PATH}"
RUN chsh -s /bin/zsh root
# 3. 安装 Rust & Bun
# 3. 安装 Rust & Bun & Go
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN curl -fsSL https://bun.sh/install | bash
RUN curl -fsSL https://go.dev/dl/go1.24.4.linux-amd64.tar.gz | tar -C /usr/local -xzf - \
&& go install golang.org/x/tools/gopls@latest \
&& go install github.com/go-delve/delve/cmd/dlv@latest
# 4. 全局安装 AI 工具 (Vibe Coding 核心)
RUN bun install -g opencode-ai

View File

@@ -10,13 +10,17 @@ RUN dnf update -y && dnf install -y \
# 2. 环境变量
ENV CARGO_HOME=/usr/local/cargo \
RUSTUP_HOME=/usr/local/rustup \
BUN_INSTALL="/root/.bun"
ENV PATH="$BUN_INSTALL/bin:/usr/local/cargo/bin:${PATH}"
BUN_INSTALL="/root/.bun" \
GOPATH="/root/go"
ENV PATH="$BUN_INSTALL/bin:/usr/local/cargo/bin:/usr/local/go/bin:$GOPATH/bin:${PATH}"
RUN chsh -s /bin/zsh root
# 3. 安装 Rust & Bun
# 3. 安装 Rust & Bun & Go
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN curl -fsSL https://bun.sh/install | bash
RUN curl -fsSL https://go.dev/dl/go1.24.4.linux-amd64.tar.gz | tar -C /usr/local -xzf - \
&& go install golang.org/x/tools/gopls@latest \
&& go install github.com/go-delve/delve/cmd/dlv@latest
# 4. 全局安装 AI 工具
RUN bun install -g opencode-ai

View File

@@ -30,6 +30,7 @@ restart: down up
build:
@echo "🛠️ 正在重新构建镜像..."
docker compose build --no-cache
docker compose down
docker compose up -d
# --- 连接与交互 ---
@@ -64,6 +65,7 @@ logs:
check:
@echo "🔍 执行工具自检..."
@docker exec -it $(CONTAINER_NAME) rustc --version || echo "❌ Rust 未就绪"
@docker exec -it $(CONTAINER_NAME) go version || echo "❌ Go 未就绪"
@docker exec -it $(CONTAINER_NAME) bun --version || echo "❌ Bun 未就绪"
@docker exec -it $(CONTAINER_NAME) aider --version || echo "❌ Aider 未就绪"
@docker exec -it $(CONTAINER_NAME) opencode version || echo "❌ OpenCode 未就绪"

View File

@@ -3,7 +3,7 @@ services:
build:
context: .
# 根据需要切换 Dockerfile.fedora 或 Dockerfile.ubuntu
dockerfile: Dockerfile.fedora
dockerfile: Dockerfile.fedora
args:
# 将路径传递给 Dockerfile 阶段
CONTAINER_WORKSPACE: ${CONTAINER_WORKSPACE_PATH:-/workspace}
@@ -27,6 +27,7 @@ services:
- ${SSH_PUB_KEY_PATH:-~/.ssh/id_ed25519.pub}:/tmp/host_id_ed25519.pub:ro
- cargo-cache:/usr/local/cargo/registry
- bun-cache:/root/.bun/install/cache
- go-cache:/root/go
# --- 新增Zed 远程开发缓存 ---
- zed-server:/root/.zed_server
- zed-share:/root/.local/share/zed
@@ -38,5 +39,6 @@ volumes:
ssh-data:
cargo-cache:
bun-cache:
go-cache:
zed-server:
zed-share: