Files
hair-keeper/.cloud-dev/Dockerfile

141 lines
4.1 KiB
Docker

FROM ubuntu:22.04
# 设置环境变量
ENV DEBIAN_FRONTEND=noninteractive \
NODE_VERSION=22.14.0 \
PYTHON_VERSION=3.12 \
CODE_SERVER_VERSION=4.96.2 \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
TZ=Asia/Shanghai \
DEV_PASSWORD=clouddev
# 安装基础工具和依赖
RUN apt-get update && apt-get install -y \
curl \
wget \
git \
openssh-server \
tmux \
tree \
pwgen \
zip \
unzip \
net-tools \
fontconfig \
ffmpeg \
ca-certificates \
gnupg \
lsb-release \
build-essential \
libssl-dev \
zlib1g-dev \
libbz2-dev \
libreadline-dev \
libsqlite3-dev \
libncursesw5-dev \
xz-utils \
tk-dev \
libxml2-dev \
libxmlsec1-dev \
libffi-dev \
liblzma-dev \
ttyd \
cmake \
telnet \
redis-tools \
iputils-ping \
potrace \
imagemagick \
zsh \
&& rm -rf /var/lib/apt/lists/*
# 安装 Python 3.12
RUN apt-get update && apt-get install -y software-properties-common && \
add-apt-repository ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y python3.12 python3.12-venv python3.12-dev python3-pip && \
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 1 && \
update-alternatives --install /usr/bin/python python /usr/bin/python3.12 1 && \
rm -rf /var/lib/apt/lists/*
# 安装 Node.js 22.14
RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
apt-get install -y nodejs && \
rm -rf /var/lib/apt/lists/*
# 安装 pnpm
RUN npm install -g pnpm
# 安装 uv (Python package manager)
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
# 安装 oh-my-zsh
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended
# 设置 zsh 为默认 shell
RUN chsh -s $(which zsh)
# 配置 zsh
RUN echo 'export ZSH="$HOME/.oh-my-zsh"' > /root/.zshrc && \
echo 'ZSH_THEME="robbyrussell"' >> /root/.zshrc && \
echo 'plugins=(git node npm docker python)' >> /root/.zshrc && \
echo 'source $ZSH/oh-my-zsh.sh' >> /root/.zshrc && \
echo '' >> /root/.zshrc && \
echo '# 添加 uv 到 PATH' >> /root/.zshrc && \
echo 'export PATH="$HOME/.local/bin:$PATH"' >> /root/.zshrc
# 安装 MinIO Client (mc)
RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc -O /usr/local/bin/mc && \
chmod +x /usr/local/bin/mc
# 安装 code-server
RUN curl -fsSL https://code-server.dev/install.sh | sh -s -- --version=${CODE_SERVER_VERSION}
# 安装 npm 全局包
RUN npm install -g \
@anthropic-ai/claude-code \
@musistudio/claude-code-router
# 创建工作目录
RUN mkdir -p /workspace /root/.local/share/code-server/User
# 配置 SSH
RUN mkdir -p /var/run/sshd && \
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \
sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
# 安装 code-server 插件
RUN code-server --install-extension ms-ceintl.vscode-language-pack-zh-hans \
&& code-server --install-extension bierner.markdown-mermaid \
&& code-server --install-extension ms-python.python \
&& code-server --install-extension dbaeumer.vscode-eslint \
&& code-server --install-extension prisma.prisma \
&& code-server --install-extension ecmel.vscode-html-css \
&& code-server --install-extension cweijan.vscode-redis-client
# 配置 code-server (密码将在启动时设置)
RUN mkdir -p /root/.config/code-server && \
echo 'bind-addr: 0.0.0.0:8080' > /root/.config/code-server/config.yaml && \
echo 'auth: password' >> /root/.config/code-server/config.yaml && \
echo 'cert: false' >> /root/.config/code-server/config.yaml
# 配置 tmux
RUN echo 'set -g mouse on' > /root/.tmux.conf && \
echo 'set -g history-limit 10000' >> /root/.tmux.conf && \
echo 'set -g default-terminal "screen-256color"' >> /root/.tmux.conf
# 复制启动脚本
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
# 暴露端口
# 22: SSH
# 8080: code-server
# 7681: ttyd
# 3000: Next.js dev server
EXPOSE 22 8080 7681 3000
WORKDIR /workspace
ENTRYPOINT ["/entrypoint.sh"]