Skip to content

Commit

Permalink
Added dockerfiles and github actions workflow to publish for both CPU…
Browse files Browse the repository at this point in the history
… and GPU with arm64 and amd64 architecture
  • Loading branch information
beveradb committed Dec 21, 2023
1 parent 36f28de commit a9f119f
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 2 deletions.
51 changes: 50 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [push, workflow_dispatch]

jobs:
# Auto-publish when version is increased
publish-job:
publish-pypi:
# Only publish on `main` branch
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
Expand All @@ -17,3 +17,52 @@ jobs:
pypi-token: ${{ secrets.PYPI_API_TOKEN }}
gh-token: ${{ secrets.GITHUB_TOKEN }}
parse-changelog: false

build-and-push-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get version from pyproject.toml
id: get_version
run: |
VERSION=$(python -c "import toml; print(toml.load('pyproject.toml')['tool']['poetry']['version'])")
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- 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 Docker image for CPU
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v5
with:
file: Dockerfile.cpu
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
beveradb/audio-separator:cpu-${{ env.VERSION }}
beveradb/audio-separator:cpu-latest
beveradb/audio-separator:latest
- name: Build and push Docker image for GPU
if: ${{ github.ref == 'refs/heads/main' }}
uses: docker/build-push-action@v5
with:
file: Dockerfile.gpu
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: |
beveradb/audio-separator:gpu-${{ env.VERSION }}
beveradb/audio-separator:gpu-latest
14 changes: 14 additions & 0 deletions Dockerfile.cpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Use an official Python runtime as a parent image
FROM python:3.11-slim

# Set the working directory in the container
WORKDIR /usr/src/app

RUN apt-get update; apt-get install -y ffmpeg
RUN python -m pip install --upgrade pip

RUN --mount=type=cache,target=/root/.cache \
pip install "audio-separator[cpu]"

# Run audio-separator when the container launches
ENTRYPOINT ["audio-separator"]
19 changes: 19 additions & 0 deletions Dockerfile.gpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Use an official Python runtime as a parent image
FROM nvidia/cuda:11.8.0-base-ubuntu22.04

# Set the working directory in the container
WORKDIR /usr/src/app

RUN apt-get update && apt-get install -y \
ffmpeg \
python3-pip \
&& rm -rf /var/lib/apt/lists/*

RUN python -m pip install --upgrade pip

# Install the GPU version of audio-separator
RUN --mount=type=cache,target=/root/.cache \
pip install "audio-separator[gpu]"

# Run audio-separator when the container launches
ENTRYPOINT ["audio-separator"]
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "audio-separator"
version = "0.9.4"
version = "0.9.5"
description = "Easy to use vocal separation on CLI or as a python package, using the amazing MDX-Net models from UVR trained by @Anjok07"
authors = ["Andrew Beveridge <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit a9f119f

Please sign in to comment.