53 lines
2.0 KiB
Python
53 lines
2.0 KiB
Python
FROM python:3.13 AS builder
|
|
|
|
ARG LITE=false
|
|
|
|
WORKDIR /app
|
|
|
|
COPY Pipfile* ./
|
|
|
|
RUN pip install -i https://mirrors.aliyun.com/pypi/simple pipenv
|
|
|
|
RUN PIPENV_VENV_IN_PROJECT=1 pipenv install --deploy\
|
|
&& if [ "$LITE" = false ]; then pipenv install selenium; fi
|
|
|
|
|
|
FROM python:3.13-slim
|
|
|
|
ARG APP_WORKDIR=/iptv
|
|
ARG LITE=false
|
|
|
|
ENV APP_WORKDIR=$APP_WORKDIR
|
|
ENV PIPENV_VENV_IN_PROJECT=1
|
|
ENV PATH="/.venv/bin:$PATH"
|
|
|
|
WORKDIR $APP_WORKDIR
|
|
|
|
COPY . $APP_WORKDIR
|
|
|
|
COPY --from=builder /app/.venv /.venv
|
|
|
|
RUN echo "deb https://mirrors.aliyun.com/debian/ bookworm main contrib non-free non-free-firmware\n \
|
|
deb-src https://mirrors.aliyun.com/debian/ bookworm main contrib non-free non-free-firmware\n \
|
|
deb https://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free non-free-firmware\n \
|
|
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free non-free-firmware\n \
|
|
deb-src https://mirrors.aliyun.com/debian/ bookworm-updates main contrib non-free non-free-firmware\n \
|
|
deb https://mirrors.aliyun.com/debian/ bookworm-backports main contrib non-free non-free-firmware\n \
|
|
deb-src https://mirrors.aliyun.com/debian/ bookworm-backports main contrib non-free non-free-firmware\n \
|
|
deb https://mirrors.aliyun.com/debian-security/ bookworm-security main contrib non-free non-free-firmware\n \
|
|
deb-src https://mirrors.aliyun.com/debian-security/ bookworm-security main contrib non-free non-free-firmware\n" \
|
|
> /etc/apt/sources.list
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends cron
|
|
|
|
RUN if [ "$LITE" = false ]; then apt-get install -y --no-install-recommends chromium chromium-driver; fi \
|
|
&& apt-get clean && rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN (crontab -l ; \
|
|
echo "0 22 * * * python $APP_WORKDIR/main.py scheduled_task"; \
|
|
echo "0 10 * * * python $APP_WORKDIR/main.py scheduled_task") | crontab -
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD . /.venv/bin/activate && service cron start && python $APP_WORKDIR/main.py \
|
|
&& gunicorn -w 4 -b 0.0.0.0:8000 main:app |