chore:docker

This commit is contained in:
guorong.zheng 2024-11-25 18:10:22 +08:00
parent e8616c1156
commit 9ed41daa10
4 changed files with 39 additions and 45 deletions

3
.gitattributes vendored
View file

@ -1,2 +1 @@
*.sh linguist-language=Python
Dockerfile linguist-language=Python
Dockerfile linguist-language=Python

View file

@ -1,51 +1,53 @@
FROM python:3.13 AS builder
ARG APP_WORKDIR=/gtv
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
RUN pip install -i https://mirrors.aliyun.com/pypi/simple pipenv \
&& if [ "$LITE" = true ]; then pipenv install; else pipenv install && pipenv install selenium; fi
COPY --from=builder /app/.venv /.venv
FROM python:3.13-slim
ARG APP_WORKDIR=/gtv
ARG LITE=false
ENV APP_WORKDIR=$APP_WORKDIR
WORKDIR $APP_WORKDIR
COPY --from=builder $APP_WORKDIR $APP_WORKDIR
RUN echo "deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware\n \
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware\n \
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware\n \
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware\n \
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware\n \
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware\n \
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware\n \
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware\n \
deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ bookworm-security main contrib non-free non-free-firmware\n" \
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 \
&& if [ "$LITE" = false ]; then apt-get install -y --no-install-recommends chromium chromium-driver; fi \
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 * * * cd $APP_WORKDIR && /usr/local/bin/pipenv run python main.py scheduled_task"; \
echo "0 10 * * * cd $APP_WORKDIR && /usr/local/bin/pipenv run python main.py scheduled_task") | crontab -
echo "0 22 * * * python $APP_WORKDIR/main.py scheduled_task"; \
echo "0 10 * * * python $APP_WORKDIR/main.py scheduled_task") | crontab -
EXPOSE 8000
COPY entrypoint.sh /gtv_entrypoint.sh
RUN chmod +x /gtv_entrypoint.sh
ENTRYPOINT ["/gtv_entrypoint.sh"]
CMD . /.venv/bin/activate && service cron start && python $APP_WORKDIR/main.py \
&& gunicorn -w 4 -b 0.0.0.0:8000 main:app

View file

@ -6,11 +6,11 @@ verify_ssl = true
[scripts]
dev = "python main.py"
ui = "python tkinter_ui/tkinter_ui.py"
docker_run = "docker run -v config:/gtv/config -v output:/gtv/output -d -p 8000:8000 guovern/gtv"
docker_run_lite = "docker run -v config:/gtv-lite/config -v output:/gtv-lite/output -d -p 8000:8000 guovern/gtv:lite"
docker_run = "docker run -v config:/iptv/config -v output:/iptv/output -d -p 8000:8000 guovern/iptv"
docker_run_lite = "docker run -v config:/iptv-lite/config -v output:/iptv-lite/output -d -p 8000:8000 guovern/iptv:lite"
tkinter_build = "pyinstaller tkinter_ui/tkinter_ui.spec"
docker_build = "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --build-arg APP_WORKDIR=/gtv -t guovern/gtv ."
docker_build_lite = "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --build-arg APP_WORKDIR=/gtv-lite --build-arg LITE=true -t guovern/gtv:lite ."
docker_build = "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --build-arg APP_WORKDIR=/iptv -t guovern/iptv ."
docker_build_lite = "docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --build-arg APP_WORKDIR=/iptv-lite --build-arg LITE=true -t guovern/iptv:lite ."
[dev-packages]
requests = "*"

View file

@ -1,7 +0,0 @@
#!/bin/bash
service cron start
pipenv run python $APP_WORKDIR/main.py
gunicorn -w 4 -b 0.0.0.0:8000 main:app