Skip to content

Commit

Permalink
Merge pull request Chenyme#52 from Eisaichen/main
Browse files Browse the repository at this point in the history
New docker image for Linux and actions for auto push
  • Loading branch information
Chenyme authored Aug 22, 2024
2 parents 9b33815 + 9de6554 commit 44f35c9
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 3 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Docker Image CI

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]

jobs:
docker:
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:latest,chenyme/chenyme-aavt:${{ github.sha }}

30 changes: 30 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
2 changes: 1 addition & 1 deletion README-EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@
> ```
> ### 3. 运行项目Web
> ```
> streamlit run Chenyme-AAVT
> streamlit run Chenyme-AAVT.py
> ```
> - 输入 `chenymeaavt` 进入项目(此为新版本的保护功能,可关闭)
>
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
networks:
chenyme-aavt:

services:
chenyme-aavt:
container_name: chenyme-aavt
image: chenyme/chenyme-aavt:latest
restart: unless-stopped
networks:
- chenyme-aavt
ports:
- "8501:8501" # Web GUI
volumes:
- './conf:/app/config'
- './model:/app/model'
- './output:/app/cache' # Output
9 changes: 9 additions & 0 deletions entry.sh
Original file line number Diff line number Diff line change
@@ -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 --browser.gatherUsageStats false
14 changes: 13 additions & 1 deletion utils/get_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}")

0 comments on commit 44f35c9

Please sign in to comment.