2023-03-26 03:42:43 +08:00
|
|
|
FROM busybox:latest AS resource
|
2023-03-07 12:19:52 +08:00
|
|
|
|
2023-03-04 14:30:13 +08:00
|
|
|
COPY docker-entrypoint.sh /res/entrypoint.sh
|
|
|
|
|
|
|
|
RUN dos2unix /res/entrypoint.sh \
|
|
|
|
&& chmod +x /res/entrypoint.sh
|
|
|
|
|
|
|
|
|
2023-06-26 03:42:11 +08:00
|
|
|
FROM node:lts-bullseye-slim AS runtime
|
2023-03-04 14:30:13 +08:00
|
|
|
|
2023-03-26 03:42:43 +08:00
|
|
|
ARG BUNDLE_FFMPEG true
|
|
|
|
ARG BUNDLE_POETRY true
|
|
|
|
ARG USE_APT_MIRROR true
|
|
|
|
ARG USE_NPM_MIRROR true
|
|
|
|
ARG USE_PYPI_MIRROR true
|
|
|
|
ARG REPO_URL https://gitee.com/yoimiya-kokomi/Miao-Yunzai.git
|
|
|
|
ARG REPO_BRANCH master
|
|
|
|
|
|
|
|
RUN export BUNDLE_FFMPEG=${BUNDLE_FFMPEG:-true} \
|
|
|
|
&& export BUNDLE_POETRY=${BUNDLE_POETRY:-true} \
|
|
|
|
&& export USE_APT_MIRROR=${USE_APT_MIRROR:-true} \
|
|
|
|
&& export USE_NPM_MIRROR=${USE_NPM_MIRROR:-true} \
|
|
|
|
&& export USE_PYPI_MIRROR=${USE_PYPI_MIRROR:-true} \
|
|
|
|
\
|
|
|
|
&& ((test "$USE_APT_MIRROR"x = "true"x \
|
2023-04-15 01:09:42 +08:00
|
|
|
&& sed -i "s/deb.debian.org/mirrors.ustc.edu.cn/g" /etc/apt/sources.list) || true) \
|
2023-03-26 03:42:43 +08:00
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get upgrade -y \
|
|
|
|
&& apt-get install -y wget xz-utils dos2unix \
|
|
|
|
&& ((test "$BUNDLE_FFMPEG"x = "true"x \
|
|
|
|
&& wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-$(dpkg --print-architecture)-static.tar.xz \
|
|
|
|
&& mkdir -p /res/ffmpeg \
|
|
|
|
&& tar -xvf ./ffmpeg-git-$(dpkg --print-architecture)-static.tar.xz -C /res/ffmpeg --strip-components 1 \
|
|
|
|
&& cp /res/ffmpeg/ffmpeg /usr/bin/ffmpeg \
|
|
|
|
&& cp /res/ffmpeg/ffprobe /usr/bin/ffprobe) || true) \
|
|
|
|
\
|
2023-03-11 19:41:39 +08:00
|
|
|
&& apt-get update \
|
2023-03-04 14:30:13 +08:00
|
|
|
&& apt-get upgrade -y \
|
2023-03-26 03:42:43 +08:00
|
|
|
&& apt-get install -y curl wget gnupg git fonts-wqy-microhei xfonts-utils chromium fontconfig libxss1 libgl1 \
|
2023-03-04 14:30:13 +08:00
|
|
|
&& apt-get autoremove \
|
2023-03-26 03:42:43 +08:00
|
|
|
&& apt-get clean \
|
|
|
|
\
|
|
|
|
&& fc-cache -f -v \
|
|
|
|
\
|
|
|
|
&& git config --global --add safe.directory '*' \
|
2023-03-04 14:30:13 +08:00
|
|
|
&& git config --global pull.rebase false \
|
|
|
|
&& git config --global user.email "Yunzai@yunzai.bot" \
|
2023-03-26 03:42:43 +08:00
|
|
|
&& git config --global user.name "Yunzai" \
|
|
|
|
\
|
|
|
|
&& _NPM_MIRROR_FLAG="" \
|
|
|
|
&& if [ "$USE_NPM_MIRROR"x = "true"x ]; then _NPM_MIRROR_FLAG="--registry=https://registry.npmmirror.com"; fi \
|
2023-11-17 01:32:19 +08:00
|
|
|
&& npm install pnpm -g $_NPM_MIRROR_FLAG \
|
2023-03-26 03:42:43 +08:00
|
|
|
\
|
|
|
|
&& ((test "$BUNDLE_POETRY"x = "true"x \
|
|
|
|
&& apt-get update \
|
|
|
|
&& apt-get install -y python3-pip python3-venv \
|
|
|
|
&& apt-get autoremove \
|
|
|
|
&& apt-get clean \
|
|
|
|
&& ln -s /usr/bin/python3 /usr/bin/python \
|
2023-03-11 21:34:33 +08:00
|
|
|
&& POETRY_HOME=$HOME/venv-poetry \
|
|
|
|
&& python -m venv $POETRY_HOME \
|
2023-03-26 03:42:43 +08:00
|
|
|
&& _PYPI_MIRROR_FLAG="" \
|
|
|
|
&& if [ "$USE_PYPI_MIRROR"x = "true"x ]; then _PYPI_MIRROR_FLAG="-i https://pypi.tuna.tsinghua.edu.cn/simple"; fi \
|
|
|
|
&& $POETRY_HOME/bin/pip install --upgrade pip setuptools $_PYPI_MIRROR_FLAG \
|
|
|
|
&& $POETRY_HOME/bin/pip install poetry $_PYPI_MIRROR_FLAG \
|
2023-03-11 21:34:33 +08:00
|
|
|
&& ln -s $POETRY_HOME/bin/poetry /usr/bin \
|
2023-03-26 03:42:43 +08:00
|
|
|
&& poetry config virtualenvs.in-project true) || true) \
|
|
|
|
\
|
|
|
|
&& rm -rf /var/cache/* \
|
2023-03-04 14:30:13 +08:00
|
|
|
&& rm -rf /tmp/*
|
|
|
|
|
|
|
|
|
|
|
|
FROM runtime AS prod
|
|
|
|
|
|
|
|
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true \
|
|
|
|
PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
|
|
|
|
2023-03-26 03:42:43 +08:00
|
|
|
RUN REPO_URL=${REPO_URL:-"https://gitee.com/yoimiya-kokomi/Miao-Yunzai.git"} \
|
|
|
|
&& REPO_BRANCH=${REPO_BRANCH:-master} \
|
|
|
|
&& USE_NPM_MIRROR=${USE_NPM_MIRROR:-true} \
|
|
|
|
\
|
|
|
|
&& _NPM_MIRROR_FLAG="" \
|
|
|
|
&& if [ "$USE_NPM_MIRROR"x = "true"x ]; then _NPM_MIRROR_FLAG="--registry=https://registry.npmmirror.com"; fi \
|
|
|
|
&& git clone --depth=1 --branch $REPO_BRANCH $REPO_URL /app/Miao-Yunzai \
|
2023-03-06 11:38:52 +08:00
|
|
|
&& cd /app/Miao-Yunzai \
|
2023-03-04 14:30:13 +08:00
|
|
|
&& sed -i 's/127.0.0.1/redis/g' ./config/default_config/redis.yaml \
|
2023-03-26 03:42:43 +08:00
|
|
|
&& pnpm install -P $_NPM_MIRROR_FLAG \
|
|
|
|
&& git remote set-url origin https://gitee.com/yoimiya-kokomi/Miao-Yunzai.git
|
2023-03-04 14:30:13 +08:00
|
|
|
|
2023-03-06 11:38:52 +08:00
|
|
|
COPY --from=resource /res/entrypoint.sh /app/Miao-Yunzai/entrypoint.sh
|
2023-03-04 14:30:13 +08:00
|
|
|
|
2023-03-06 11:38:52 +08:00
|
|
|
WORKDIR /app/Miao-Yunzai
|
2023-03-04 14:30:13 +08:00
|
|
|
|
2023-03-06 11:38:52 +08:00
|
|
|
ENTRYPOINT ["/app/Miao-Yunzai/entrypoint.sh"]
|