Add GitHub Actions workflow for Docker image (#32)
* Add GitHub Actions workflow for pushing Docker images
* Fix invalid case of Docker image tag
* Optimize storage memory consumed by LFS layer
* Force workflow to run `ubuntu-22.04`
* Copy `README.md` to be included in installation with `poetry`
* Fix installation with `poetry`
* Try to optimize runner disk space consumption during build
* Optimize image building on source code changed
* Add verbose logging for downloading assets
* Add logging for disk space at GitHub Actions workflow
* Clean up some disk space usage on Docker image build
* Optimize running `poetry` on Docker image build
* Optimize `pip` taking disk space on Dociker image build
* Try to fix call of clearing `poetry` cache
* Optimize more `poetry` disk space usage
* Try to use Docker image from registry as cache
* Fix `cache-from` and `cache-to` parameters indentation
* Clean up excess workflow steps
* Fix image tag for caching of building Docker image in GitHub Actions workflow
* Disable build image caching for a while
* Remove `docker system prune` step from Docker push workflow
* Revert "Remove `docker system prune` step from Docker push workflow"
This reverts commit 7497fa35b2.
* Hardcode Docker image name
Prevent different naming for the same thing in forks.
This commit is contained in:
42
.github/workflows/docker-push.yml
vendored
Normal file
42
.github/workflows/docker-push.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
name: Push Docker image to GitHub Container Registry
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Prune Docker System
|
||||
run: docker system prune -af
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets._GITHUB_PAT }}
|
||||
|
||||
- name: Git lowercase repository owner
|
||||
id: repository-owner-lowercase
|
||||
uses: ASzc/change-string-case-action@v6
|
||||
with:
|
||||
string: ${{ github.repository_owner }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ steps.repository-owner-lowercase.outputs.lowercase }}/rvc-api:${{ github.ref_name }}
|
||||
ghcr.io/${{ steps.repository-owner-lowercase.outputs.lowercase }}/rvc-api:latest
|
||||
26
Dockerfile
26
Dockerfile
@@ -1,9 +1,11 @@
|
||||
FROM alpine:3.19.1 as assets
|
||||
|
||||
RUN apk add --update \
|
||||
bash \
|
||||
git \
|
||||
git-lfs
|
||||
RUN apk add \
|
||||
--update \
|
||||
--no-cache \
|
||||
bash \
|
||||
git \
|
||||
git-lfs
|
||||
|
||||
COPY --chmod=755 ./assets-download.sh /assets-download.sh
|
||||
|
||||
@@ -16,20 +18,26 @@ SHELL [ "/bin/bash", "-c" ]
|
||||
RUN apt update && \
|
||||
apt install -y \
|
||||
libsndfile1 \
|
||||
libsndfile1-dev
|
||||
libsndfile1-dev && \
|
||||
apt clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY --from=assets /assets /assets
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN pip install "poetry==1.7.1"
|
||||
|
||||
COPY ./pyproject.toml .
|
||||
|
||||
RUN poetry install
|
||||
RUN pip install \
|
||||
--no-cache-dir \
|
||||
"poetry==1.7.1" && \
|
||||
poetry config virtualenvs.create false && \
|
||||
poetry install \
|
||||
--no-interaction \
|
||||
--no-root && \
|
||||
poetry cache clear --all .
|
||||
|
||||
COPY ./rvc ./rvc
|
||||
|
||||
COPY ./.env-docker ./.env
|
||||
|
||||
CMD [ "poetry", "run", "poe", "rvc-api" ]
|
||||
|
||||
@@ -2,6 +2,12 @@
|
||||
#
|
||||
# Downloads required large files for RVC.
|
||||
|
||||
function download() {
|
||||
local path="$1"
|
||||
echo "Downloading ${path}"
|
||||
git lfs pull --include="${path}"
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
REPO_FOLDER="VoiceConversionWebUI"
|
||||
@@ -16,27 +22,31 @@ git clone https://huggingface.co/lj1995/VoiceConversionWebUI "${REPO_FOLDER}"
|
||||
|
||||
pushd "${REPO_FOLDER}"
|
||||
|
||||
git config advice.detachedHead false
|
||||
|
||||
git checkout "${assets_commit_hash}"
|
||||
|
||||
unset GIT_LFS_SKIP_SMUDGE
|
||||
unset GIT_CLONE_PROTECTION_ACTIVE
|
||||
|
||||
git lfs pull --include="hubert_base.pt"
|
||||
git lfs pull --include="pretrained"
|
||||
git lfs pull --include="uvr5_weights"
|
||||
git lfs pull --include="rmvpe.pt"
|
||||
git lfs pull --include="rmvpe.onnx"
|
||||
download "hubert_base.pt"
|
||||
download "pretrained"
|
||||
download "uvr5_weights"
|
||||
download "rmvpe.pt"
|
||||
download "rmvpe.onnx"
|
||||
|
||||
rm -rf .git
|
||||
|
||||
popd
|
||||
|
||||
mkdir -p "${assets_dir}"
|
||||
|
||||
cp "${REPO_FOLDER}/hubert_base.pt" "${assets_dir}/hubert_base.pt"
|
||||
mv "${REPO_FOLDER}/hubert_base.pt" "${assets_dir}/hubert_base.pt"
|
||||
|
||||
mkdir -p "${assets_dir}/rmvpe"
|
||||
|
||||
cp "${REPO_FOLDER}/rmvpe.pt" "${assets_dir}/rmvpe/rmvpe.pt"
|
||||
cp "${REPO_FOLDER}/rmvpe.onnx" "${assets_dir}/rmvpe/rmvpe.onnx"
|
||||
mv "${REPO_FOLDER}/rmvpe.pt" "${assets_dir}/rmvpe/rmvpe.pt"
|
||||
mv "${REPO_FOLDER}/rmvpe.onnx" "${assets_dir}/rmvpe/rmvpe.onnx"
|
||||
|
||||
cp -r "${REPO_FOLDER}/pretrained" "${assets_dir}/pretrained"
|
||||
cp -r "${REPO_FOLDER}/uvr5_weights" "${assets_dir}/uvr5_weights"
|
||||
mv "${REPO_FOLDER}/pretrained" "${assets_dir}/pretrained"
|
||||
mv "${REPO_FOLDER}/uvr5_weights" "${assets_dir}/uvr5_weights"
|
||||
|
||||
Reference in New Issue
Block a user