From 2bf5e003fbf9e1c7535c0237c3db1dacade4822d Mon Sep 17 00:00:00 2001 From: Kenn Zhang Date: Fri, 9 Feb 2024 13:54:02 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Dockerfile=E5=88=86=E5=B1=82?= =?UTF-8?q?=EF=BC=8C=E5=B0=BD=E5=8F=AF=E8=83=BD=E5=A4=8D=E7=94=A8=E7=BC=93?= =?UTF-8?q?=E5=AD=98=EF=BC=9B=E5=A2=9E=E5=8A=A0=E6=9D=A1=E4=BB=B6=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=EF=BC=8C=E5=8F=AF=E4=BB=A5=E7=94=A8IMAGE=5FTYPE?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=9E=84=E5=BB=BA=E4=B8=8D=E5=8C=85=E5=90=AB?= =?UTF-8?q?=E9=A2=9D=E5=A4=96=E6=A8=A1=E5=9E=8B=E7=9A=84Docker=E9=95=9C?= =?UTF-8?q?=E5=83=8F=E6=9D=A5=E5=87=8F=E5=B0=91=E9=95=9C=E5=83=8F=E5=A4=A7?= =?UTF-8?q?=E5=B0=8F=EF=BC=9B=E5=A2=9E=E5=8A=A0=E6=89=B9=E9=87=8F=E6=9E=84?= =?UTF-8?q?=E5=BB=BADocker=E9=95=9C=E5=83=8F=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 4 +++- Dockerfile | 43 ++++++++++++++++++++++++++----------------- dockerbuild.sh | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 18 deletions(-) create mode 100755 dockerbuild.sh diff --git a/.dockerignore b/.dockerignore index b8fec2a..dc39f76 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,6 @@ docs logs output -reference \ No newline at end of file +reference +SoVITS_weights +.git \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ac85a4b..1daaf6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM cnstark/pytorch:2.0.1-py3.9.17-cuda11.8.0-ubuntu20.04 LABEL maintainer="breakstring@hotmail.com" -LABEL version="dev-20240127" +LABEL version="dev-20240209" LABEL description="Docker image for GPT-SoVITS" @@ -11,25 +11,34 @@ ENV DEBIAN_FRONTEND=noninteractive ENV TZ=Etc/UTC RUN apt-get update && \ apt-get install -y --no-install-recommends tzdata ffmpeg libsox-dev parallel aria2 git git-lfs && \ - rm -rf /var/lib/apt/lists/* && \ - git lfs install + git lfs install && \ + rm -rf /var/lib/apt/lists/* -# Copy application +# Copy only requirements.txt initially to leverage Docker cache WORKDIR /workspace +COPY requirements.txt /workspace/ +RUN pip install --no-cache-dir -r requirements.txt + +# Define a build-time argument for image type +ARG IMAGE_TYPE=full + +# Conditional logic based on the IMAGE_TYPE argument +# Always copy the Docker directory, but only use it if IMAGE_TYPE is not "elite" +COPY ./Docker /workspace/Docker +# elite 类型的镜像里面不包含额外的模型 +RUN if [ "$IMAGE_TYPE" != "elite" ]; then \ + chmod +x /workspace/Docker/download.sh && \ + /workspace/Docker/download.sh && \ + python /workspace/Docker/download.py && \ + python -m nltk.downloader averaged_perceptron_tagger cmudict; \ + fi + + +# Copy the rest of the application COPY . /workspace -# install python packages -RUN pip install -r requirements.txt - -# Download models -RUN chmod +x /workspace/Docker/download.sh && /workspace/Docker/download.sh - -# Download moda ASR related -RUN python /workspace/Docker/download.py - -# Download nltk realted -RUN python -m nltk.downloader averaged_perceptron_tagger -RUN python -m nltk.downloader cmudict +# Copy the rest of the application +COPY . /workspace EXPOSE 9870 @@ -42,4 +51,4 @@ VOLUME /workspace/output VOLUME /workspace/logs VOLUME /workspace/SoVITS_weights -CMD ["python", "webui.py"] \ No newline at end of file +CMD ["python", "webui.py"] diff --git a/dockerbuild.sh b/dockerbuild.sh new file mode 100755 index 0000000..1b3dcee --- /dev/null +++ b/dockerbuild.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# 获取当前日期,格式为 YYYYMMDD +DATE=$(date +%Y%m%d) + +# 构建 full 版本的镜像 +docker build --build-arg IMAGE_TYPE=full -t breakstring/gpt-sovits:latest . +# 为同一个镜像添加带日期的标签 +docker tag breakstring/gpt-sovits:latest breakstring/gpt-sovits:dev-$DATE + +# 构建 elite 版本的镜像 +docker build --build-arg IMAGE_TYPE=elite -t breakstring/gpt-sovits:latest-elite . +# 为同一个镜像添加带日期的标签 +docker tag breakstring/gpt-sovits:latest-elite breakstring/gpt-sovits:dev-$DATE-elite