-
-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #531 from Paladinium/alltalkbeta
Adding Github actions for building the docker images
- Loading branch information
Showing
9 changed files
with
248 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: 'Setting up docker' | ||
|
||
inputs: | ||
DOCKERHUB_USERNAME: | ||
required: true | ||
DOCKERHUB_REPO_NAME: | ||
required: true | ||
DOCKERHUB_TOKEN: | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Free Disk Space (Ubuntu) | ||
uses: jlumbroso/[email protected] | ||
with: | ||
tool-cache: true | ||
swap-storage: false | ||
large-packages: false | ||
- name: Read variables | ||
shell: bash | ||
run: | | ||
source ./docker/variables.sh | ||
for key in "${!ALLTALK_VARS[@]}" | ||
do | ||
echo "${key}=${ALLTALK_VARS[${key}]}" | ||
echo "${key}=${ALLTALK_VARS[${key}]}" >> $GITHUB_ENV | ||
done | ||
- name: Extract version from Git Tag | ||
shell: bash {0} | ||
run: | | ||
# Use the git tag if existing, otherwise 'latest': | ||
DOCKER_TAG=$( echo "${{ github.ref }}" | grep -q tags | cut -d'/' -f 3 ) | ||
if [ -z "${DOCKER_TAG}" ]; then | ||
DOCKER_TAG="latest" | ||
fi | ||
echo "Using DOCKER_TAG=${DOCKER_TAG}" | ||
echo "DOCKER_TAG=${DOCKER_TAG}" >> $GITHUB_ENV | ||
- name: Extract Docker Hub User and Repo Name | ||
shell: bash | ||
env: | ||
DOCKERHUB_USERNAME: ${{ inputs.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_REPO_NAME: ${{ inputs.DOCKERHUB_REPO_NAME }} | ||
run: | | ||
if [ -n "${DOCKERHUB_USERNAME}" ]; then | ||
echo "Using Github repository variable 'DOCKERHUB_USERNAME' as Docker hub username with value: '${DOCKERHUB_USERNAME}'" | ||
echo "DOCKERHUB_USERNAME=${DOCKERHUB_USERNAME}" >> $GITHUB_ENV | ||
else | ||
echo "Using Github repository name as Docker hub username" | ||
echo "DOCKERHUB_USERNAME=$(echo ${{ github.repository }} | cut -d'/' -f 1)" >> $GITHUB_ENV | ||
fi | ||
if [ -n "${DOCKERHUB_REPO_NAME}" ]; then | ||
echo "Using Github repository variable 'DOCKERHUB_REPO_NAME' as Docker hub repo name with value: '${DOCKERHUB_REPO_NAME}'" | ||
echo "DOCKERHUB_REPO_NAME=${DOCKERHUB_REPO_NAME}" >> $GITHUB_ENV | ||
else | ||
echo "Using Github repository name as Docker hub repo name" | ||
echo "DOCKERHUB_REPO_NAME=$(echo ${{ github.repository }} | cut -d'/' -f 2)" >> $GITHUB_ENV | ||
fi | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ inputs.DOCKERHUB_USERNAME }} | ||
password: ${{ inputs.DOCKERHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
name: Publish Docker v2 | ||
|
||
on: | ||
workflow_dispatch: | ||
release: | ||
types: [ published ] | ||
push: | ||
branches: | ||
- 'alltalkbeta' | ||
tags: | ||
- 'v*' | ||
|
||
# Limit the concurrency of entire workflow runs for a specific branch: | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build_base_environment_docker_image: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup docker | ||
uses: ./.github/actions/docker-setup | ||
with: | ||
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_REPO_NAME: ${{ vars.DOCKERHUB_REPO_NAME }} | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}_environment | ||
tags: | | ||
# Use sematic versioning on push tag event: | ||
type=semver,pattern={{version}} | ||
# set latest tag for main and alltalkbeta branch: | ||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.ref == format('refs/heads/{0}', 'alltalkbeta') }} | ||
- uses: dorny/paths-filter@v3 | ||
id: changes | ||
with: | ||
filters: | | ||
docker-base: | ||
- 'docker/variables.sh' | ||
- 'docker/base/Dockerfile' | ||
docker-workflow: | ||
- '.github/workflows/publish-docker*.yml' | ||
- name: Build and push base Docker image | ||
if: | | ||
steps.changes.outputs.docker-base == 'true' || | ||
steps.changes.outputs.docker-workflow == 'true' || | ||
github.event_name == 'release' || | ||
(github.event_name == 'push' && contains(github.ref, 'refs/tags/')) | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: ./docker/base | ||
file: ./docker/base/Dockerfile | ||
platforms: "linux/amd64" | ||
push: true | ||
build-args: | | ||
CUDA_VERSION=${{ env.CUDA_VERSION }} | ||
PYTHON_VERSION=${{ env.PYTHON_VERSION }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}_environment:buildcache | ||
cache-to: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}_environment:buildcache,mode=max | ||
|
||
build_main_docker_image: | ||
needs: build_base_environment_docker_image | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
tts: [ xtts, vits, piper ] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup docker | ||
uses: ./.github/actions/docker-setup | ||
with: | ||
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_REPO_NAME: ${{ vars.DOCKERHUB_REPO_NAME }} | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }} | ||
flavor: | | ||
suffix=-${{ matrix.tts }},onlatest=true | ||
tags: | | ||
# Use sematic versioning on push tag event: | ||
type=semver,pattern={{version}} | ||
# set latest tag for main and alltalkbeta branch: | ||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') || github.ref == format('refs/heads/{0}', 'alltalkbeta') }} | ||
- name: Build and push base Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
platforms: "linux/amd64" | ||
push: true | ||
build-args: | | ||
TTS_MODEL=${{ matrix.tts }} | ||
ALLTALK_DIR=${{ env.ALLTALK_DIR }} | ||
DEEPSPEED_VERSION=${{ env.DEEPSPEED_VERSION }} | ||
DOCKER_TAG=${{ env.DOCKER_TAG }} | ||
GITHUB_REPOSITORY=${{ env.DOCKERHUB_USERNAME }}/ | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}:buildcache-${{ matrix.tts }} | ||
cache-to: type=registry,ref=${{ env.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO_NAME }}:buildcache-${{ matrix.tts }},mode=max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
export CUDA_VERSION=12.6.0 | ||
export PYTHON_VERSION=3.11.11 | ||
export DEEPSPEED_VERSION=0.16.2 | ||
export ALLTALK_DIR=/opt/alltalk | ||
export GITHUB_REPOSITORY= | ||
declare -A ALLTALK_VARS | ||
ALLTALK_VARS["CUDA_VERSION"]=12.6.0 | ||
ALLTALK_VARS["PYTHON_VERSION"]=3.11.11 | ||
ALLTALK_VARS["DEEPSPEED_VERSION"]=0.16.2 | ||
ALLTALK_VARS["ALLTALK_DIR"]=/opt/alltalk | ||
ALLTALK_VARS["GITHUB_REPOSITORY"]= | ||
|
||
# Export single variables (needed by Docker locally) | ||
for key in "${!ALLTALK_VARS[@]}" | ||
do | ||
export "${key}=${ALLTALK_VARS[${key}]}" | ||
done | ||
|
||
# Export the entire associative array (needed by Github action) | ||
export ALLTALK_VARS |