Files
2026-04-02 08:55:07 +08:00

69 lines
2.1 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 \
openssh-server \
&& 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
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN curl -fsSL https://code-server.dev/install.sh | sh
RUN useradd -m -u 1000 vnpy && echo "vnpy ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers && mkdir -p /home/vnpy/.ssh && chown -R vnpy:vnpy /home/vnpy /app && chmod 700 /home/vnpy/.ssh
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin no/' /etc/ssh/sshd_config && 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 entrypoint.sh /app/
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]