Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

优化Dockerfile --- 新年快乐 #446

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
docs
logs
output
reference
reference
SoVITS_weights
.git
39 changes: 24 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"


Expand All @@ -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 . /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

# install python packages
RUN pip install -r requirements.txt
# 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

# Download models
RUN chmod +x /workspace/Docker/download.sh && /workspace/Docker/download.sh

# Download moda ASR related
RUN python /workspace/Docker/download.py
# Copy the rest of the application
COPY . /workspace

# 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
Expand All @@ -42,4 +51,4 @@ VOLUME /workspace/output
VOLUME /workspace/logs
VOLUME /workspace/SoVITS_weights

CMD ["python", "webui.py"]
CMD ["python", "webui.py"]
14 changes: 14 additions & 0 deletions dockerbuild.sh
Original file line number Diff line number Diff line change
@@ -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