Skip to content

Commit e83eb6c

Browse files
authoredOct 25, 2024··
feat: docker deploy (#2)
1 parent 013877c commit e83eb6c

10 files changed

+235
-41
lines changed
 

‎.dockerignore

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Include any files or directories that you don't want to be copied to your
2+
# container here (e.g., local build artifacts, temporary files, etc.).
3+
#
4+
# For more help, visit the .dockerignore file reference guide at
5+
# https://docs.docker.com/engine/reference/builder/#dockerignore-file
6+
7+
**/.DS_Store
8+
**/.classpath
9+
**/.dockerignore
10+
**/.env
11+
**/.git
12+
**/.gitignore
13+
**/.project
14+
**/.settings
15+
**/.toolstarget
16+
**/.vs
17+
**/.vscode
18+
**/*.*proj.user
19+
**/*.dbmdl
20+
**/*.jfm
21+
**/bin
22+
**/charts
23+
scripts/docker-compose-dev.yml
24+
**/compose*
25+
**/Dockerfile*
26+
**/node_modules
27+
**/npm-debug.log
28+
**/obj
29+
**/secrets.dev.yaml
30+
**/values.dev.yaml
31+
LICENSE
32+
README.md
33+
./deploy

‎.github/workflows/CI-docker.yml

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Docker Build CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
jobs:
10+
docker:
11+
runs-on: ubuntu-20.04
12+
steps:
13+
- uses: actions/checkout@v3
14+
with:
15+
submodules: recursive
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
19+
20+
- name: Login to Docker Hub
21+
uses: docker/login-action@v2
22+
with:
23+
username: lychee0
24+
password: ${{ secrets.DOCKERHUB_TOKEN }}
25+
26+
- name: Build and push
27+
uses: docker/build-push-action@v6
28+
with:
29+
platforms: linux/amd64
30+
push: true
31+
tags: lychee0/animepipeline:dev

‎.github/workflows/Release-pypi.yml

-34
This file was deleted.

‎.github/workflows/Release.yml

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
pypi:
11+
strategy:
12+
matrix:
13+
python-version: ["3.9"]
14+
poetry-version: ["1.8.3"]
15+
16+
runs-on: ubuntu-20.04
17+
steps:
18+
- uses: actions/checkout@v3
19+
with:
20+
submodules: recursive
21+
22+
- uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- uses: abatilo/actions-poetry@v2
27+
with:
28+
poetry-version: ${{ matrix.poetry-version }}
29+
30+
- name: Build package
31+
run: |
32+
make build
33+
34+
- name: Publish a Python distribution to PyPI
35+
uses: pypa/gh-action-pypi-publish@release/v1
36+
with:
37+
password: ${{ secrets.PYPI_API }}
38+
39+
docker:
40+
runs-on: ubuntu-20.04
41+
steps:
42+
- uses: actions/checkout@v3
43+
with:
44+
submodules: recursive
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v2
48+
49+
- name: Login to Docker Hub
50+
uses: docker/login-action@v2
51+
with:
52+
username: lychee0
53+
password: ${{ secrets.DOCKERHUB_TOKEN }}
54+
55+
- name: Docker meta
56+
id: meta
57+
uses: docker/metadata-action@v5
58+
with:
59+
images: |
60+
lychee0/animepipeline
61+
tags: |
62+
latest
63+
${{ github.ref_name }}
64+
65+
- name: Build and push
66+
uses: docker/build-push-action@v6
67+
with:
68+
platforms: linux/amd64
69+
push: true
70+
tags: ${{ steps.meta.outputs.tags }}
71+
72+
github:
73+
needs: [pypi, docker]
74+
runs-on: ubuntu-20.04
75+
steps:
76+
- uses: actions/checkout@v3
77+
with:
78+
submodules: recursive
79+
80+
- name: Release
81+
uses: softprops/action-gh-release@v2

‎Dockerfile

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
FROM python:3.11.10
2+
3+
RUN apt update && apt install -y \
4+
curl \
5+
make \
6+
iputils-ping \
7+
libmediainfo-dev \
8+
libgl1-mesa-glx
9+
10+
WORKDIR /app
11+
12+
COPY . .
13+
14+
ENV POETRY_HOME="/opt/poetry"
15+
ENV PATH="$POETRY_HOME/bin:$PATH"
16+
17+
RUN curl -sSL https://install.python-poetry.org | python3 -
18+
19+
RUN poetry install
20+
21+
CMD ["make", "run"]

‎Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ lint:
1212
.PHONY: build
1313
build:
1414
poetry build --format wheel
15+
16+
.PHONY: run
17+
run:
18+
poetry run python -m animepipeline
19+
20+
.PHONY: docker
21+
docker:
22+
docker buildx build -t lychee0/animepipeline .

‎animepipeline/loop.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,17 @@ async def pipeline_finalrip(self, task_info: TaskInfo) -> None:
199199
await self.finalrip_client.download_completed_task(video_key=bt_downloaded_path.name, save_path=temp_saved_path)
200200

201201
# rename temp file
202-
gen_name = gen_file_name(
203-
FileNameInfo(
204-
path=temp_saved_path, episode=task_info.episode, name=task_info.name, uploader=task_info.uploader
202+
try:
203+
gen_name = gen_file_name(
204+
FileNameInfo(
205+
path=temp_saved_path, episode=task_info.episode, name=task_info.name, uploader=task_info.uploader
206+
)
205207
)
206-
)
207-
finalrip_downloaded_path = bt_downloaded_path.parent / gen_name
208+
finalrip_downloaded_path = bt_downloaded_path.parent / gen_name
209+
except Exception as e:
210+
logger.error(f"Failed to generate file name: {e}")
211+
raise e
212+
208213
if finalrip_downloaded_path.exists():
209214
finalrip_downloaded_path.unlink()
210215
logger.warning(f"Encode File already exists, remove it: {finalrip_downloaded_path}")

‎deploy/docker-compose-dev.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: "3.8"
22

3-
name: animepipeline
3+
name: animepipeline-dev
44

55
networks:
66
backend:

‎deploy/docker-compose.yml

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
version: "3.8"
2+
3+
name: animepipeline
4+
5+
networks:
6+
backend:
7+
driver: bridge
8+
9+
services:
10+
animepipeline:
11+
image: lychee0/animepipeline:latest
12+
restart: always
13+
volumes:
14+
- ../conf:/app/conf
15+
- ./docker/downloads:/downloads
16+
networks:
17+
- backend
18+
19+
qb:
20+
image: superng6/qbittorrentee:4.4.5.10
21+
restart: always
22+
environment:
23+
- PUID=1026
24+
- PGID=100
25+
volumes:
26+
- ./docker/qb-config:/config
27+
- ./docker/downloads:/downloads
28+
ports:
29+
- "6881:6881"
30+
- "6881:6881/udp"
31+
- "8091:8080"
32+
33+
telegram-bot-api:
34+
image: aiogram/telegram-bot-api:latest
35+
restart: always
36+
environment:
37+
TELEGRAM_API_ID: "26"
38+
TELEGRAM_API_HASH: "4a"
39+
TELEGRAM_LOCAL: 1
40+
volumes:
41+
- telegram-bot-api-data:/var/lib/telegram-bot-api
42+
ports:
43+
- "8081:8081"
44+
45+
# !这可不能乱动,wsl2下不这么搞会报错,真他妈的坑
46+
# Note: Don't use -v option to mount volumes in WSL2!!!
47+
# Ref: https://github.com/tdlib/td/issues/1776
48+
volumes:
49+
telegram-bot-api-data:

‎pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ license = "MIT"
3939
name = "animepipeline"
4040
readme = "README.md"
4141
repository = "https://github.com/TensoRaws/AnimePipeline"
42-
version = "0.0.1"
42+
version = "0.0.2"
4343

4444
# Requirements
4545
[tool.poetry.dependencies]

0 commit comments

Comments
 (0)
Please sign in to comment.