Skip to content

Commit

Permalink
feat: docker deploy (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tohrusky authored Oct 25, 2024
1 parent 013877c commit e83eb6c
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 41 deletions.
33 changes: 33 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Include any files or directories that you don't want to be copied to your
# container here (e.g., local build artifacts, temporary files, etc.).
#
# For more help, visit the .dockerignore file reference guide at
# https://docs.docker.com/engine/reference/builder/#dockerignore-file

**/.DS_Store
**/.classpath
**/.dockerignore
**/.env
**/.git
**/.gitignore
**/.project
**/.settings
**/.toolstarget
**/.vs
**/.vscode
**/*.*proj.user
**/*.dbmdl
**/*.jfm
**/bin
**/charts
scripts/docker-compose-dev.yml
**/compose*
**/Dockerfile*
**/node_modules
**/npm-debug.log
**/obj
**/secrets.dev.yaml
**/values.dev.yaml
LICENSE
README.md
./deploy
31 changes: 31 additions & 0 deletions .github/workflows/CI-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Docker Build CI

on:
push:
branches:
- main
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: lychee0
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: true
tags: lychee0/animepipeline:dev
34 changes: 0 additions & 34 deletions .github/workflows/Release-pypi.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Release

on:
workflow_dispatch:
push:
tags:
- "v*"

jobs:
pypi:
strategy:
matrix:
python-version: ["3.9"]
poetry-version: ["1.8.3"]

runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ matrix.poetry-version }}

- name: Build package
run: |
make build
- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API }}

docker:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: lychee0
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
lychee0/animepipeline
tags: |
latest
${{ github.ref_name }}
- name: Build and push
uses: docker/build-push-action@v6
with:
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}

github:
needs: [pypi, docker]
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Release
uses: softprops/action-gh-release@v2
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.11.10

RUN apt update && apt install -y \
curl \
make \
iputils-ping \
libmediainfo-dev \
libgl1-mesa-glx

WORKDIR /app

COPY . .

ENV POETRY_HOME="/opt/poetry"
ENV PATH="$POETRY_HOME/bin:$PATH"

RUN curl -sSL https://install.python-poetry.org | python3 -

RUN poetry install

CMD ["make", "run"]
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,11 @@ lint:
.PHONY: build
build:
poetry build --format wheel

.PHONY: run
run:
poetry run python -m animepipeline

.PHONY: docker
docker:
docker buildx build -t lychee0/animepipeline .
15 changes: 10 additions & 5 deletions animepipeline/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,17 @@ async def pipeline_finalrip(self, task_info: TaskInfo) -> None:
await self.finalrip_client.download_completed_task(video_key=bt_downloaded_path.name, save_path=temp_saved_path)

# rename temp file
gen_name = gen_file_name(
FileNameInfo(
path=temp_saved_path, episode=task_info.episode, name=task_info.name, uploader=task_info.uploader
try:
gen_name = gen_file_name(
FileNameInfo(
path=temp_saved_path, episode=task_info.episode, name=task_info.name, uploader=task_info.uploader
)
)
)
finalrip_downloaded_path = bt_downloaded_path.parent / gen_name
finalrip_downloaded_path = bt_downloaded_path.parent / gen_name
except Exception as e:
logger.error(f"Failed to generate file name: {e}")
raise e

if finalrip_downloaded_path.exists():
finalrip_downloaded_path.unlink()
logger.warning(f"Encode File already exists, remove it: {finalrip_downloaded_path}")
Expand Down
2 changes: 1 addition & 1 deletion deploy/docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: "3.8"

name: animepipeline
name: animepipeline-dev

networks:
backend:
Expand Down
49 changes: 49 additions & 0 deletions deploy/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: "3.8"

name: animepipeline

networks:
backend:
driver: bridge

services:
animepipeline:
image: lychee0/animepipeline:latest
restart: always
volumes:
- ../conf:/app/conf
- ./docker/downloads:/downloads
networks:
- backend

qb:
image: superng6/qbittorrentee:4.4.5.10
restart: always
environment:
- PUID=1026
- PGID=100
volumes:
- ./docker/qb-config:/config
- ./docker/downloads:/downloads
ports:
- "6881:6881"
- "6881:6881/udp"
- "8091:8080"

telegram-bot-api:
image: aiogram/telegram-bot-api:latest
restart: always
environment:
TELEGRAM_API_ID: "26"
TELEGRAM_API_HASH: "4a"
TELEGRAM_LOCAL: 1
volumes:
- telegram-bot-api-data:/var/lib/telegram-bot-api
ports:
- "8081:8081"

# !这可不能乱动,wsl2下不这么搞会报错,真他妈的坑
# Note: Don't use -v option to mount volumes in WSL2!!!
# Ref: https://github.com/tdlib/td/issues/1776
volumes:
telegram-bot-api-data:
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ license = "MIT"
name = "animepipeline"
readme = "README.md"
repository = "https://github.com/TensoRaws/AnimePipeline"
version = "0.0.1"
version = "0.0.2"

# Requirements
[tool.poetry.dependencies]
Expand Down

0 comments on commit e83eb6c

Please sign in to comment.