From b77b1b0f95b4639a3c5c7fc164d041b0e911dcc2 Mon Sep 17 00:00:00 2001 From: Achilles Kars Date: Wed, 22 Nov 2023 12:54:46 +0800 Subject: [PATCH] add missing dependency: apscheduler (#189) fix some bugs in Dockerfile Co-authored-by: Night-stars-1 <99261160+Night-stars-1@users.noreply.github.com> --- Dockerfile | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index b1b0b8d..d4331e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,33 @@ -FROM python:3.12.0-slim +FROM python:alpine + +RUN sed -i 's|https://dl-cdn.alpinelinux.org|http://mirrors.tuna.tsinghua.edu.cn|g' /etc/apk/repositories RUN apt-get update \ && apt-get install -y gcc musl-dev libffi-dev libssl-dev ca-certificates cron \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* -RUN pip install --no-cache-dir pdm +RUN apk add --no-cache --virtual .build-app curl -COPY ./utils /srv/utils/ +RUN pip config set global.index-url 'https://mirrors.sustech.edu.cn/pypi/web/simple' -COPY ./miuitask.py /srv/ +RUN curl -sSL https://pdm-project.org/install-pdm.py | python3 - -COPY pyproject.toml pdm.lock /srv/ +ENV PATH="/root/.local/bin:$PATH" + +RUN pdm config pypi.url 'https://mirrors.sustech.edu.cn/pypi/web/simple' WORKDIR /srv -RUN pip install --no-cache-dir urllib3 certifi +COPY ./utils ./utils -RUN pdm install --prod && \ - echo "0 4 * * * python /srv/miuitask.py" > /var/spool/cron/crontabs/root +COPY ./pyproject.toml ./pdm.lock ./miuitask.py ./ + +RUN pdm install --prod + +RUN { crontab -l; printf '%s\t%s\t%s\t%s\t%s\t%s\n' '0' '4' '*' '*' '*' '/usr/bin/env pdm run python /srv/miuitask.py'; } | crontab - + +RUN apk del .build-app VOLUME ["./data", "/srv/data"]