z / Dockerfile
asfag654's picture
Update Dockerfile
bb3308f verified
# 基于 Ubuntu 22.04 的基础镜像
FROM ubuntu:22.04
# 设置工作目录
WORKDIR /z
# 设置时区
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
ENV DEBIAN_FRONTEND=noninteractive
SHELL ["/bin/bash", "-c"]
# 更新并安装系统依赖
RUN apt-get update -q && apt-get install -y -qq \
git curl wget tzdata \
libglib2.0-0 libnss3 libnspr4 libdbus-1-3 libxcomposite1 \
libxdamage1 libxrandr2 libgtk-3-0 libasound2 libxtst6 \
libxshmfence1 libxcb1 redis-server gnupg ca-certificates nodejs \
python3.10 python3-pip \
fonts-noto fonts-noto-cjk fonts-wqy-zenhei fonts-wqy-microhei \
fonts-dejavu-core fonts-freefont-ttf fonts-ipafont-mincho fonts-ipafont-gothic > /dev/null
# 添加 Google Chrome 的软件源并安装
RUN wget -q -O - https://dl.google.com/linux/linux_signing_key.pub | gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg && \
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list && \
apt-get update -q && apt-get install -y -q google-chrome-stable && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# 克隆相关项目
RUN git clone --quiet --branch create-pr/update_version https://github.com/HibiKier/zhenxun_bot.git
WORKDIR /zmal/zhenxun_bot
# 设置 Playwright 浏览器缓存路径
ENV PLAYWRIGHT_BROWSERS_PATH=/zmal/.cache/ms-playwright
RUN mkdir -p /zmal/.cache/ms-playwright && \
PIP_ROOT_USER_ACTION=ignore pip install -q poetry playwright && \
playwright install chromium --with-deps > /dev/null
# 配置 zhenxun_bot 项目依赖
RUN poetry config virtualenvs.in-project true && \
poetry install --quiet&&poetry update --quiet
COPY .env.dev /zmal/zhenxun_bot/.env.dev
RUN --mount=type=secret,id=zzz,mode=0444,required=true \
    sed -i "s|^DB_URL =.*|DB_URL = \"$(cat /run/secrets/zzz)\"|" /zmal/zhenxun_bot/.env.dev
# 暴露端口
EXPOSE 6221
COPY config.yaml /zmal/zhenxun_bot/data/config.yaml
RUN chmod -R 777 /zmal/
CMD poetry run python bot.py