diff --git a/Dockerfile b/Dockerfile index d3add2ed05c..c929832888f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,12 +21,13 @@ FROM python:3.13-slim ARG APP_WORKDIR=/iptv-api ARG LITE=False -ARG APP_PORT=8000 ENV APP_WORKDIR=$APP_WORKDIR ENV LITE=$LITE -ENV APP_PORT=$APP_PORT +ENV APP_PORT=8000 ENV PATH="/.venv/bin:$PATH" +ENV UPDATE_CRON1="0 22 * * *" +ENV UPDATE_CRON2="0 10 * * *" WORKDIR $APP_WORKDIR @@ -42,8 +43,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends cron \ && rm -rf /var/lib/apt/lists/* RUN (crontab -l ; \ - echo "0 22 * * * cd $APP_WORKDIR && /.venv/bin/python main.py"; \ - echo "0 10 * * * cd $APP_WORKDIR && /.venv/bin/python main.py") | crontab - + if [ -n "$UPDATE_CRON1" ]; then echo "$UPDATE_CRON1 cd $APP_WORKDIR && /.venv/bin/python main.py"; fi; \ + if [ -n "$UPDATE_CRON2" ]; then echo "$UPDATE_CRON2 cd $APP_WORKDIR && /.venv/bin/python main.py"; fi) | crontab - EXPOSE $APP_PORT diff --git a/README.md b/README.md index 9154d5fea7e..cdaa79f765d 100644 --- a/README.md +++ b/README.md @@ -207,7 +207,7 @@ pipenv run ui 版本运行模式(推荐酒店源、组播源、关键字搜索使用此版本) - iptv-api:lite(精简版本):轻量级,性能要求低,更新速度快,稳定性不确定(推荐订阅源使用此版本) -1. 拉取镜像: +#### 1. 拉取镜像: - iptv-api: @@ -233,7 +233,7 @@ docker pull guovern/iptv-api:lite docker pull docker.1ms.run/guovern/iptv-api:lite ``` -2. 运行容器: +#### 2. 运行容器: - iptv-api: @@ -247,7 +247,8 @@ docker run -d -p 8000:8000 guovern/iptv-api docker run -d -p 8000:8000 guovern/iptv-api:lite ``` -卷挂载参数(可选): +##### 挂载(推荐): + 实现宿主机文件与容器文件同步,修改模板、配置、获取更新结果文件可直接在宿主机文件夹下操作 以宿主机路径/etc/docker 为例: @@ -264,13 +265,22 @@ docker run -v /etc/docker/config:/iptv-api/config -v /etc/docker/output:/iptv-ap docker run -v /etc/docker/config:/iptv-api-lite/config -v /etc/docker/output:/iptv-api-lite/output -d -p 8000:8000 guovern/iptv-api:lite ``` -端口环境变量: +##### 环境变量: + +- 端口 ```bash -e APP_PORT=8000 ``` -3. 更新结果: +- 定时执行时间 + +```bash +-e UPDATE_CRON1="0 22 * * *" +-e UPDATE_CRON2="0 10 * * *" +``` + +#### 3. 更新结果: - 接口地址:`ip:8000` - m3u 接口:`ip:8000/m3u` diff --git a/README_en.md b/README_en.md index 6b356dbbb63..82e32051e42 100644 --- a/README_en.md +++ b/README_en.md @@ -214,7 +214,7 @@ pipenv run ui It's recommended to try each one and choose the version that suits you -1. Pull the image: +#### 1. Pull the image: - iptv-api @@ -240,7 +240,7 @@ docker pull guovern/iptv-api:lite docker pull docker.1ms.run/guovern/iptv-api:lite ``` -2. Run the container: +#### 2. Run the container: - iptv-api @@ -254,7 +254,8 @@ docker run -d -p 8000:8000 guovern/iptv-api docker run -d -p 8000:8000 guovern/iptv-api:lite ``` -Volume Mount Parameter (Optional): +##### Mount(Recommended): + This allows synchronization of files between the host machine and the container. Modifying templates, configurations, and retrieving updated result files can be directly operated in the host machine's folder. @@ -272,13 +273,22 @@ docker run -v /etc/docker/config:/iptv-api/config -v /etc/docker/output:/iptv-ap docker run -v /etc/docker/config:/iptv-api-lite/config -v /etc/docker/output:/iptv-api-lite/output -d -p 8000:8000 guovern/iptv-api:lite ``` -Port environment variables: +##### Environment Variables: + +- Port ```bash -e APP_PORT=8000 ``` -3. Update results: +- Scheduled execution time + +```bash +-e UPDATE_CRON1="0 22 * * *" +-e UPDATE_CRON2="0 10 * * *" +``` + +#### 3. Update results: - API address: `ip:8000` - m3u api:`ip:8000/m3u` diff --git a/docs/tutorial.md b/docs/tutorial.md index 59e0d4389a3..b05e57045f6 100644 --- a/docs/tutorial.md +++ b/docs/tutorial.md @@ -301,7 +301,7 @@ docker run -d -p 8000:8000 guovern/iptv-api docker run -d -p 8000:8000 guovern/iptv-api:lite ``` -#### 卷挂载参数(可选): +#### 挂载(推荐): 实现宿主机文件与容器文件同步,修改模板、配置、获取更新结果文件可直接在宿主机文件夹下操作 @@ -321,12 +321,21 @@ docker run -v /etc/docker/config:/iptv-api-lite/config -v /etc/docker/output:/ip ##### 注意:如果重新拉取镜像进行更新版本后,涉及到配置文件变更或增加新配置时,务必覆盖主机的旧配置文件(config目录),因为主机的配置文件是无法自动更新的,否则容器还是以旧配置运行。 -#### 端口环境变量: +#### 环境变量: + +- 端口 ```bash -e APP_PORT=8000 ``` +- 定时执行时间 + +```bash +-e UPDATE_CRON1="0 22 * * *" +-e UPDATE_CRON2="0 10 * * *" +``` + ### 3.更新结果: - 接口地址:`ip:8000` diff --git a/docs/tutorial_en.md b/docs/tutorial_en.md index 92f35b94e86..02976e77425 100644 --- a/docs/tutorial_en.md +++ b/docs/tutorial_en.md @@ -328,7 +328,7 @@ docker run -d -p 8000:8000 guovern/iptv-api docker run -d -p 8000:8000 guovern/iptv-api:lite ``` -#### Volume mount parameters (optional): +#### Mount (recommended): To synchronize files between the host and the container, modify templates, configurations, and obtain update result files directly in the host folder. @@ -349,12 +349,21 @@ docker run -v /etc/docker/config:/iptv-api-lite/config -v /etc/docker/output:/ip ##### Note: If you pull the image again to update the version, and there are changes or additions to the configuration files, be sure to overwrite the old configuration files in the host (config directory), as the host configuration files cannot be updated automatically. Otherwise, the container will still run with the old configuration. -#### Port environment variables: +#### Environment Variables: + +- Port ```bash -e APP_PORT=8000 ``` +- Scheduled execution time + +```bash +-e UPDATE_CRON1="0 22 * * *" +-e UPDATE_CRON2="0 10 * * *" +``` + ### 3. Update results: ```