Skip to content

Commit

Permalink
feat:APP_PORT(#619)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guovin committed Dec 12, 2024
1 parent 1ab7ca7 commit 907a358
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ 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 PATH="/.venv/bin:$PATH"

WORKDIR $APP_WORKDIR
Expand Down Expand Up @@ -47,7 +49,7 @@ 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 -

EXPOSE 8000
EXPOSE $APP_PORT

COPY entrypoint.sh /iptv-api-entrypoint.sh

Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ 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. 更新结果:

- 接口地址:ip:8000
Expand Down
6 changes: 6 additions & 0 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ 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:

```bash
-e APP_PORT=8000
```

3. Update results:

- API address: ip:8000
Expand Down
8 changes: 8 additions & 0 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@
1. 创建文件
2. 模板文件命名为 user_demo.txt
3.

模板文件需要按照(频道分类,#genre#),(频道名称,频道接口)进行编写,注意是英文逗号。如果需要将该接口设为白名单(不测速、保留在结果最前),可在地址后添加$!即可,例如http://xxx$!
。后面也可以添加额外说明信息,如:http://xxx$!白名单接口

4. 点击 Commit changes...进行保存

![创建user_demo.txt](./images/edit-user-demo.png '创建user_demo.txt')
Expand Down Expand Up @@ -263,6 +265,12 @@ 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. 更新结果:

- 接口地址:ip:8000
Expand Down
6 changes: 6 additions & 0 deletions docs/tutorial_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ 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:

```bash
-e APP_PORT=8000
```

3. Update results:

- API address: ip:8000
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ service cron start &

python $APP_WORKDIR/main.py &

python -m gunicorn service.app:app -b 0.0.0.0:8000 --timeout=1000
python -m gunicorn service.app:app -b 0.0.0.0:$APP_PORT --timeout=1000
2 changes: 1 addition & 1 deletion service/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def run_service():
print(f"🚀 M3u api: {ip_address}/m3u")
print(f"🚀 Txt api: {ip_address}/txt")
print(f"✅ You can use this url to watch IPTV 📺: {ip_address}")
app.run(host="0.0.0.0", port=8000)
app.run(host="0.0.0.0", port=os.environ.get("APP_PORT") or 8000)
except Exception as e:
print(f"❌ Service start failed: {e}")

Expand Down
2 changes: 1 addition & 1 deletion utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def get_ip_address():
IP = "127.0.0.1"
finally:
s.close()
return f"http://{IP}:8000"
return f"http://{IP}:{os.environ.get("APP_PORT") or 8000}"


def convert_to_m3u():
Expand Down

0 comments on commit 907a358

Please sign in to comment.