Skip to content

Commit

Permalink
feat:docker update cron(#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guovin committed Jan 21, 2025
1 parent 4e7bacf commit 1275c7c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 18 deletions.
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pipenv run ui
版本运行模式(推荐酒店源、组播源、关键字搜索使用此版本)
- iptv-api:lite(精简版本):轻量级,性能要求低,更新速度快,稳定性不确定(推荐订阅源使用此版本)

1. 拉取镜像:
#### 1. 拉取镜像:

- iptv-api:

Expand All @@ -233,7 +233,7 @@ docker pull guovern/iptv-api:lite
docker pull docker.1ms.run/guovern/iptv-api:lite
```

2. 运行容器:
#### 2. 运行容器:

- iptv-api:

Expand All @@ -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 为例:
Expand All @@ -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`
Expand Down
20 changes: 15 additions & 5 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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.

Expand All @@ -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`
Expand Down
13 changes: 11 additions & 2 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ docker run -d -p 8000:8000 guovern/iptv-api
docker run -d -p 8000:8000 guovern/iptv-api:lite
```

#### 卷挂载参数(可选):
#### 挂载(推荐):

实现宿主机文件与容器文件同步,修改模板、配置、获取更新结果文件可直接在宿主机文件夹下操作

Expand All @@ -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`
Expand Down
13 changes: 11 additions & 2 deletions docs/tutorial_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
```
Expand Down

0 comments on commit 1275c7c

Please sign in to comment.