fix: keep bun, opencode coommand in env
This commit is contained in:
@@ -8,12 +8,15 @@ RUN dnf update -y && dnf install -y \
|
|||||||
openssh-server tar gzip \
|
openssh-server tar gzip \
|
||||||
&& dnf clean all
|
&& dnf clean all
|
||||||
|
|
||||||
|
|
||||||
# 2. 环境变量配置
|
# 2. 环境变量配置
|
||||||
ENV CARGO_HOME=/usr/local/cargo \
|
ENV CARGO_HOME=/usr/local/cargo \
|
||||||
RUSTUP_HOME=/usr/local/rustup \
|
RUSTUP_HOME=/usr/local/rustup \
|
||||||
BUN_INSTALL="/root/.bun"
|
BUN_INSTALL="/root/.bun"
|
||||||
ENV PATH="$BUN_INSTALL/bin:/usr/local/cargo/bin:${PATH}"
|
ENV PATH="$BUN_INSTALL/bin:/usr/local/cargo/bin:${PATH}"
|
||||||
|
|
||||||
|
RUN chsh -s /bin/zsh root
|
||||||
|
|
||||||
# 3. 安装 Rust & Bun
|
# 3. 安装 Rust & Bun
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
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://bun.sh/install | bash
|
||||||
@@ -26,7 +29,7 @@ RUN ssh-keygen -A && \
|
|||||||
mkdir -p /root/.zed /root/.local/share/zed && \
|
mkdir -p /root/.zed /root/.local/share/zed && \
|
||||||
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
|
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
|
||||||
|
|
||||||
# 6. Shell 美化
|
RUN sed -i 's/#PermitUserEnvironment no/PermitUserEnvironment yes/' /etc/ssh/sshd_config
|
||||||
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
||||||
|
|
||||||
# 接收来自 compose 的参数
|
# 接收来自 compose 的参数
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ ENV CARGO_HOME=/usr/local/cargo \
|
|||||||
RUSTUP_HOME=/usr/local/rustup \
|
RUSTUP_HOME=/usr/local/rustup \
|
||||||
BUN_INSTALL="/root/.bun"
|
BUN_INSTALL="/root/.bun"
|
||||||
ENV PATH="$BUN_INSTALL/bin:/usr/local/cargo/bin:${PATH}"
|
ENV PATH="$BUN_INSTALL/bin:/usr/local/cargo/bin:${PATH}"
|
||||||
|
RUN chsh -s /bin/zsh root
|
||||||
|
|
||||||
# 3. 安装 Rust & Bun
|
# 3. 安装 Rust & Bun
|
||||||
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
|
||||||
@@ -25,6 +26,7 @@ RUN ssh-keygen -A && \
|
|||||||
mkdir -p /root/.zed /root/.local/share/zed && \
|
mkdir -p /root/.zed /root/.local/share/zed && \
|
||||||
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
|
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
|
||||||
|
|
||||||
|
RUN sed -i 's/#PermitUserEnvironment no/PermitUserEnvironment yes/' /etc/ssh/sshd_config
|
||||||
# 6. Shell 美化
|
# 6. Shell 美化
|
||||||
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
|
||||||
|
|
||||||
|
|||||||
@@ -8,28 +8,34 @@ services:
|
|||||||
# 将路径传递给 Dockerfile 阶段
|
# 将路径传递给 Dockerfile 阶段
|
||||||
CONTAINER_WORKSPACE: ${CONTAINER_WORKSPACE_PATH:-/workspace}
|
CONTAINER_WORKSPACE: ${CONTAINER_WORKSPACE_PATH:-/workspace}
|
||||||
container_name: vibe-coding-env
|
container_name: vibe-coding-env
|
||||||
|
hostname: vibe-coding
|
||||||
env_file: .env
|
env_file: .env
|
||||||
environment:
|
environment:
|
||||||
# 让容器内部程序也能感知工作目录
|
# 让容器内部程序也能感知工作目录
|
||||||
- WORKSPACE=${CONTAINER_WORKSPACE_PATH:-/workspace}
|
- WORKSPACE=${CONTAINER_WORKSPACE_PATH:-/workspace}
|
||||||
|
- SHELL=/bin/zsh
|
||||||
|
- TERM=xterm-256color
|
||||||
ports:
|
ports:
|
||||||
- "${SSH_PORT:-2222}:22"
|
- "${SSH_PORT:-2222}:22"
|
||||||
- "6300:3000"
|
- "6300:3000"
|
||||||
- "6173-6175:5173-5175"
|
- "6173-6175:5173-5175"
|
||||||
volumes:
|
volumes:
|
||||||
- ${HOST_PROJECT_PATH:-.}:${CONTAINER_WORKSPACE_PATH:-/workspace}:cached
|
- ${HOST_PROJECT_PATH:-.}:${CONTAINER_WORKSPACE_PATH:-/workspace}:cached
|
||||||
|
# 1. 使用命名卷持久化整个 .ssh 目录
|
||||||
|
- ssh-data:/root/.ssh
|
||||||
|
|
||||||
- ${SSH_PUB_KEY_PATH:-~/.ssh/id_ed25519.pub}:/tmp/host_id_ed25519.pub:ro
|
- ${SSH_PUB_KEY_PATH:-~/.ssh/id_ed25519.pub}:/tmp/host_id_ed25519.pub:ro
|
||||||
- cargo-cache:/usr/local/cargo/registry
|
- cargo-cache:/usr/local/cargo/registry
|
||||||
- bun-cache:/root/.bun/install/cache
|
- bun-cache:/root/.bun/install/cache
|
||||||
# --- 新增:Zed 远程开发缓存 ---
|
# --- 新增:Zed 远程开发缓存 ---
|
||||||
- zed-server:/root/.zed
|
- zed-server:/root/.zed_server
|
||||||
- zed-share:/root/.local/share/zed
|
- zed-share:/root/.local/share/zed
|
||||||
stdin_open: true
|
stdin_open: true
|
||||||
tty: true
|
tty: true
|
||||||
restart: always
|
restart: always
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
ssh-data:
|
||||||
cargo-cache:
|
cargo-cache:
|
||||||
bun-cache:
|
bun-cache:
|
||||||
zed-server:
|
zed-server:
|
||||||
|
|||||||
@@ -5,7 +5,9 @@ set -e
|
|||||||
mkdir -p /root/.ssh
|
mkdir -p /root/.ssh
|
||||||
chmod 700 /root/.ssh
|
chmod 700 /root/.ssh
|
||||||
touch /root/.ssh/authorized_keys
|
touch /root/.ssh/authorized_keys
|
||||||
|
touch /root/.ssh/environment
|
||||||
|
|
||||||
|
printenv | grep -E '^(PATH|BUN|CARGO|RUST|ANTHROPIC|OPENAI|OPENCODE|TERM|SHELL|WORKSPACE)' > /root/.ssh/environment
|
||||||
# 2. 动态注入挂载的公钥 (解决只读冲突的核心逻辑)
|
# 2. 动态注入挂载的公钥 (解决只读冲突的核心逻辑)
|
||||||
if [ -f /tmp/host_id_ed25519.pub ]; then
|
if [ -f /tmp/host_id_ed25519.pub ]; then
|
||||||
echo "检测到挂载的公钥,正在注入..."
|
echo "检测到挂载的公钥,正在注入..."
|
||||||
@@ -20,7 +22,7 @@ fi
|
|||||||
|
|
||||||
# 3. 强制修复权限 (SSH 对此非常敏感)
|
# 3. 强制修复权限 (SSH 对此非常敏感)
|
||||||
chmod 600 /root/.ssh/authorized_keys
|
chmod 600 /root/.ssh/authorized_keys
|
||||||
chown root:root /root/.ssh/authorized_keys
|
chown -R root:root /root/.ssh
|
||||||
|
|
||||||
|
|
||||||
# 根据不同 OS 启动 SSH
|
# 根据不同 OS 启动 SSH
|
||||||
|
|||||||
Reference in New Issue
Block a user