feat(devcontainer): add enhanced Maven development environment with Java 21, Bun, and SSH support
- Add Docker Compose configuration for Maven + Java 21 development container - Include SSH server support for remote development (Zed editor compatible) - Install Bun package manager and opencode-ai for enhanced development workflow - Provide Makefile with commands for build, up, down, restart, logs, shell, ssh, and clean - Add .env.example template for configurable ports and paths - Include .gitignore for Java/Maven artifacts and IDE files - Configure USTC mirrors for faster package installation - Support persistent volume mounting for root user configuration (.ssh, .m2 cache)
This commit is contained in:
55
java-maven/vibe-enhance-version/Containerfile
Normal file
55
java-maven/vibe-enhance-version/Containerfile
Normal file
@@ -0,0 +1,55 @@
|
||||
FROM maven:3.9-eclipse-temurin-21
|
||||
|
||||
# 1. 优化 APT源 (保持你原有的逻辑,但增加了错误处理的安全性)
|
||||
# 注意:eclipse-temurin-21 基于 Ubuntu,sources 路径正确
|
||||
RUN sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/ubuntu.sources && \
|
||||
sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources && \
|
||||
sed -i 's/http:/https:/g' /etc/apt/sources.list.d/ubuntu.sources
|
||||
|
||||
# 2. 安装基础工具 + SSH Server
|
||||
#添加 openssh-server, locales, sudo 等开发常用包
|
||||
RUN apt-get update && \
|
||||
apt-get install -y \
|
||||
git curl vim ripgrep unzip netcat-openbsd bash-completion \
|
||||
openssh-server locales sudo wget && \
|
||||
# 清理缓存以减小镜像体积
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# ============================
|
||||
# 2. 安装 Bun 和 Opencode
|
||||
# ============================
|
||||
# [关键] 设置 BUN_INSTALL 到 /opt 目录,防止被 /root 挂载卷覆盖
|
||||
ENV BUN_INSTALL="/opt/bun"
|
||||
ENV PATH="$BUN_INSTALL/bin:$PATH"
|
||||
|
||||
# 安装 Bun
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
|
||||
# 使用 Bun 安装 opencode
|
||||
RUN bun install -g opencode-ai
|
||||
|
||||
|
||||
|
||||
|
||||
# 3. 配置 SSH 服务
|
||||
RUN mkdir /var/run/sshd && \
|
||||
# 允许 root 登录 (Zed 需要连接用户)
|
||||
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
|
||||
# 修复 SSH 登录后的环境变量问题
|
||||
sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd
|
||||
|
||||
|
||||
# 5. 安装 Opencode (Vibe Coding 工具)
|
||||
# 假设 Opencode 是一个可以通过 curl 下载的二进制文件。
|
||||
# 请将下方的 URL 替换为 Opencode 的真实下载链接。
|
||||
# 如果 Opencode 是 npm 包,则需要先安装 nodejs。
|
||||
# 这里演示二进制安装模式:
|
||||
# RUN curl -L "https://path/to/opencode-linux-x64" -o /usr/local/bin/opencode && \
|
||||
# chmod +x /usr/local/bin/opencode
|
||||
|
||||
# 6. 设置工作目录
|
||||
WORKDIR /workspace
|
||||
|
||||
# 7. 配置容器启动命令
|
||||
# 启动 SSH 服务并挂起容器
|
||||
CMD ["/bin/sh", "-c", "/usr/sbin/sshd -D"]
|
||||
Reference in New Issue
Block a user