From 495c7241b52649443dc12f39f3f5a27dfc0cbb1e Mon Sep 17 00:00:00 2001 From: eisaichen Date: Thu, 22 Aug 2024 04:12:54 -0500 Subject: [PATCH 1/8] Docker for linux --- .github/workflows/docker-image.yml | 40 ++++++++++++++++++++++++++++++ Dockerfile | 30 ++++++++++++++++++++++ docker-compose.yaml | 16 ++++++++++++ entry.sh | 9 +++++++ 4 files changed, 95 insertions(+) create mode 100644 .github/workflows/docker-image.yml create mode 100644 Dockerfile create mode 100644 docker-compose.yaml create mode 100644 entry.sh diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 0000000..2396291 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,40 @@ +name: Docker Image CI + +on: + pull_request: + branches: [ main ] + types: [ closed ] + push: + branches: [ main ] + +jobs: + docker: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + platforms: linux/amd64,linux/arm64 + pull: true + push: true + tags: chenyme/chenyme-AAVT:${{ github.sha }} + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0e17175 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,30 @@ +FROM python:3.11 + +EXPOSE 8501 +ENV DEBIAN_FRONTEND=noninteractive + +COPY . /app + +RUN apt update && \ + apt install ffmpeg rsync fonts-wqy-zenhei fonts-wqy-microhei -y && \ + apt clean && \ + addgroup --gid 1000 chenymeaavt && \ + adduser --uid 1000 --ingroup chenymeaavt --disabled-password chenymeaavt && \ + pip cache purge && \ + chown 1000:1000 /app -R && \ + chmod +x /app/entry.sh + +USER chenymeaavt +WORKDIR /app + +RUN python -m venv . && \ + . ./bin/activate && \ + pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121 && \ + pip install -r /app/requirements.txt && \ + pip cache purge && \ + mv config _config && \ + mv cache _cache && \ + mv model _model && \ + mkdir config cache model + +ENTRYPOINT ["./entry.sh"] diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..f93b005 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,16 @@ +networks: + chenyme-aavt: + +services: + chenyme-aavt: + container_name: chenyme-aavt + image: chenymeaavt:test + restart: unless-stopped + networks: + - chenyme-aavt + ports: + - "8501:8501" # Web GUI + volumes: + - './conf:/app/config' + - './model:/app/model' + - './output:/app/cache' # Output \ No newline at end of file diff --git a/entry.sh b/entry.sh new file mode 100644 index 0000000..1b4d433 --- /dev/null +++ b/entry.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +rsync -a --ignore-existing /app/_config/ /app/config/ > /dev/null +rsync -a --ignore-existing /app/_model/ /app/model/ > /dev/null +rsync -a --ignore-existing /app/_cache/ /app/cache/ > /dev/null + +. ./bin/activate +python ./styles/info.py +streamlit run Chenyme-AAVT.py From 41167cb826b14a26693f3e935d28a2489c5414cb Mon Sep 17 00:00:00 2001 From: Eisai <12467320+Eisaichen@users.noreply.github.com> Date: Thu, 22 Aug 2024 04:15:42 -0500 Subject: [PATCH 2/8] Update docker-image.yml --- .github/workflows/docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 2396291..31f5b08 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -36,5 +36,5 @@ jobs: platforms: linux/amd64,linux/arm64 pull: true push: true - tags: chenyme/chenyme-AAVT:${{ github.sha }} + tags: chenyme/chenyme-aavt:latest,chenyme/chenyme-aavt:${{ github.sha }} From 5b147bcbfd9e4efbca35dfaa7542355e82fda739 Mon Sep 17 00:00:00 2001 From: Eisai <12467320+Eisaichen@users.noreply.github.com> Date: Thu, 22 Aug 2024 04:16:09 -0500 Subject: [PATCH 3/8] Update docker-compose.yaml --- docker-compose.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f93b005..a05c1f3 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -4,7 +4,7 @@ networks: services: chenyme-aavt: container_name: chenyme-aavt - image: chenymeaavt:test + image: chenyme/chenyme-aavt:latest restart: unless-stopped networks: - chenyme-aavt @@ -13,4 +13,4 @@ services: volumes: - './conf:/app/config' - './model:/app/model' - - './output:/app/cache' # Output \ No newline at end of file + - './output:/app/cache' # Output From f3f85a12c8ca0f1f4e81ed0ed693621cfb6a8875 Mon Sep 17 00:00:00 2001 From: Eisai <12467320+Eisaichen@users.noreply.github.com> Date: Thu, 22 Aug 2024 04:16:45 -0500 Subject: [PATCH 4/8] Update docker-image.yml --- .github/workflows/docker-image.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 31f5b08..7d62913 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,13 +3,11 @@ name: Docker Image CI on: pull_request: branches: [ main ] - types: [ closed ] push: branches: [ main ] jobs: docker: - if: github.event.pull_request.merged == true runs-on: ubuntu-latest steps: From b3298bc8a228817ff960ff54dff2be60793a6617 Mon Sep 17 00:00:00 2001 From: Eisai <12467320+Eisaichen@users.noreply.github.com> Date: Thu, 22 Aug 2024 04:19:06 -0500 Subject: [PATCH 5/8] Update entry.sh --- entry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entry.sh b/entry.sh index 1b4d433..7f052f6 100644 --- a/entry.sh +++ b/entry.sh @@ -6,4 +6,4 @@ rsync -a --ignore-existing /app/_cache/ /app/cache/ > /dev/null . ./bin/activate python ./styles/info.py -streamlit run Chenyme-AAVT.py +streamlit run Chenyme-AAVT.py --browser.gatherUsageStats false From d4e99033bc68acbc9f0838f6c7a80caa78c767f9 Mon Sep 17 00:00:00 2001 From: Eisai <12467320+Eisaichen@users.noreply.github.com> Date: Thu, 22 Aug 2024 04:42:51 -0500 Subject: [PATCH 6/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02efdb5..3274f70 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ > ``` > ### 3. 运行项目Web > ``` -> streamlit run Chenyme-AAVT +> streamlit run Chenyme-AAVT.py > ``` > - 输入 `chenymeaavt` 进入项目(此为新版本的保护功能,可关闭) > From 652ac994b53b2a2e13e36d3b1516e0d6b8870a57 Mon Sep 17 00:00:00 2001 From: Eisai <12467320+Eisaichen@users.noreply.github.com> Date: Thu, 22 Aug 2024 04:43:32 -0500 Subject: [PATCH 7/8] Update README-EN.md --- README-EN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-EN.md b/README-EN.md index 1553397..b10839d 100644 --- a/README-EN.md +++ b/README-EN.md @@ -156,7 +156,7 @@ Basic supported features, not all features: > ``` > ### 3. Run the Project Web > ``` -> streamlit run Chenyme-AAVT +> streamlit run Chenyme-AAVT.py > ``` > - Enter `chenymeaavt` to access the project (this is a protection feature of the new version, can be turned off) > From 9de6554916755d60ffe626424faceca36855f89b Mon Sep 17 00:00:00 2001 From: Eisai <12467320+Eisaichen@users.noreply.github.com> Date: Thu, 22 Aug 2024 05:01:44 -0500 Subject: [PATCH 8/8] Fix crash when launching on Linux "system_profiler" is not something in Linux. --- utils/get_font.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/utils/get_font.py b/utils/get_font.py index e71195c..dbba631 100644 --- a/utils/get_font.py +++ b/utils/get_font.py @@ -23,7 +23,7 @@ def get_font_data(): for font in fonts: file.write(font + "\n") - elif system_type in ["Linux", "Darwin"]: + elif system_type in ["Darwin"]: import subprocess import re @@ -34,6 +34,18 @@ def get_font_data(): with open(path, 'w', encoding='utf-8') as file: for font in fonts: file.write(font + "\n") + + elif system_type in ["Linux"]: + import subprocess + + result = subprocess.run(['fc-list', ':', 'family'], capture_output=True, text=True) + output = result.stdout + fonts = output.split('\n') + path = os.path.join(os.getcwd().replace("utils", ""), 'config', 'font.txt') + with open(path, 'w', encoding='utf-8') as file: + for font in fonts: + if font: + file.write(font + "\n") else: print(f"获取字体失败!尚未支持的操作系统: {system_type}")