Skip to content

Commit

Permalink
feat: Docker support
Browse files Browse the repository at this point in the history
  • Loading branch information
nfe-w committed Oct 26, 2023
1 parent 529a6e4 commit c48cd48
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Build and Push Docker Image

on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:

env:
IMAGE_NAME: nfew/bili_dynamic_push

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Login to Docker Hub
uses: docker/login-action@v3.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}

- name: Build and Push Docker Image
run: |
docker build -t ${{ env.IMAGE_NAME }}:latest .
docker push ${{ env.IMAGE_NAME }}:latest
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM python:3.9-slim

# 设置容器的时区为中国北京时间
ENV TZ=Asia/Shanghai

WORKDIR /app

COPY . /app/

RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# 在容器启动时检查配置文件的存在,并运行main.py
CMD ["sh", "-c", "\
if [ -f /mnt/config_bili.ini ]; then \
cp -f /mnt/config_bili.ini /app/config_bili.ini; \
python -u main.py; \
else \
echo 'Error: /mnt/config_bili.ini file not found. Please mount the /mnt/config_bili.ini file and try again.'; \
exit 1; \
fi"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@

定时检测指定up的动态,如果发生变化进行推送

## Docker

```sh
# 构建镜像
docker build -t nfew/bili_dynamic_push:latest .

# 启动容器
docker run -d -v ~/config_bili.ini:/mnt/config_bili.ini --name bili_dynamic_push nfew/bili_dynamic_push:latest
```

## 运行环境

- [Python 3](https://www.python.org/)
Expand Down

0 comments on commit c48cd48

Please sign in to comment.