Files
sanguo_vnpy/docker/Dockerfile
T
2026-04-11 23:32:02 +08:00

83 lines
2.7 KiB
Docker
Executable File

FROM python:3.10-slim
ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 DEBIAN_FRONTEND=noninteractive TZ=Asia/Shanghai
WORKDIR /app
# 第一批:基础工具和基础依赖
RUN apt-get update && apt-get install -y \
--no-install-recommends \
git \
curl \
wget \
vim \
nano \
tzdata \
sudo \
&& rm -rf /var/lib/apt/lists/*
# 第二批:基础编译工具
RUN apt-get update && apt-get install -y \
--no-install-recommends \
make \
patch \
bzip2 \
xz-utils \
dpkg-dev \
&& rm -rf /var/lib/apt/lists/*
# 第三批:完整gcc工具链
RUN apt-get update && apt-get install -y \
--no-install-recommends \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 第四批:图形库和SSH
RUN apt-get update && apt-get install -y \
--no-install-recommends \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
dropbear \
&& rm -rf /var/lib/apt/lists/*
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN pip install --no-cache-dir --upgrade pip setuptools wheel
# 分层安装依赖:利用Docker缓存实现差分下载
# 第一层:基础依赖 - 大文件、不常变,会被长期缓存
COPY docker/requirements/requirements-base.txt .
RUN pip install --no-cache-dir -r requirements-base.txt
# 第二层:额外依赖 - 小文件、可能频繁变更,只重新下载这一层
COPY docker/requirements/requirements-extra.txt .
RUN pip install --no-cache-dir -r requirements-extra.txt
# code-server 安装:由于网络环境问题,这里跳过安装
# 用户可以在容器启动后手动安装
# 手动安装命令:curl -fsSL https://code-server.dev/install.sh | sh
# RUN curl -fsSL https://code-server.dev/install.sh | sh
RUN echo "code-server skipped - install manually after container startup if needed"
RUN useradd -m -u 1000 vnpy && echo "vnpy ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && mkdir -p /home/vnpy/.ssh && mkdir -p /etc/dropbear && chown -R vnpy:vnpy /home/vnpy /app /etc/dropbear && chmod 700 /home/vnpy/.ssh
# dropbear doesn't need sed configuration, we just set password
RUN echo "vnpy:sanguo123" | chpasswd
USER vnpy
RUN mkdir -p /home/vnpy/.config/code-server && echo 'bind-addr: 0.0.0.0:8080' > /home/vnpy/.config/code-server/config.yaml && echo 'auth: password' >> /home/vnpy/.config/code-server/config.yaml && echo 'password: sanguo123' >> /home/vnpy/.config/code-server/config.yaml
EXPOSE 8888 8000 8080 2222
COPY --chown=vnpy:vnpy docker/entrypoint.sh /app/
RUN chmod +x /app/entrypoint.sh
COPY --chown=vnpy:vnpy scripts /app/scripts
RUN find /app/scripts -name "*.sh" -type f -exec chmod +x {} \;
ENTRYPOINT ["/app/entrypoint.sh"]