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

[#15] Add Github workflow to test the execution of the docker with demucs #16

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
44 changes: 44 additions & 0 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: ci

on:
push:
branches:
- 'issue#15-github-action'

jobs:
Build-Docker-Image:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
platforms: linux/amd64,linux/arm64
-
name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Replace char '#' to '_' from GITHUB_REF_NAME env variable
id: github_ref_name_replacement_step
uses: frabert/[email protected]
with:
pattern: '#'
string: ${{ github.ref_name }}
replace-with: '_'
-
name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: xserrat/facebook-demucs:${{ steps.github_ref_name_replacement_step.outputs.replaced }}
10 changes: 10 additions & 0 deletions .github/workflows/run-demucs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Run Demucs
on: [push]
jobs:
Run-Demucs:
runs-on: macos-11
steps:
- name: Check out repository code
uses: actions/checkout@v2
- name: Generate docker image
run: make build
45 changes: 38 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,52 @@
FROM python:3.8
FROM python:3.11-alpine3.15 as lameenc-build

ENV PATH="/opt/venv/bin:$PATH"

RUN apk update && apk add git cmake build-base gcc py3-setuptools

RUN python3 -m pip install --user wheel

RUN mkdir -p /lib/lameenc
WORKDIR /lib/lameenc

RUN git clone --branch v1.3.1 --single-branch https://github.com/chrisstaite/lameenc /lib/lameenc

RUN mkdir -p /lib/lameenc/build
WORKDIR /lib/lameenc/build
RUN cmake ..
RUN make

RUN python3 -m venv /opt/venv
RUN python3 -m pip install /lib/lameenc/build/lameenc-1.3.1-cp38-cp38-linux_x86_64.whl

# syntax=docker/dockerfile:1
FROM python:3.11-alpine3.15
USER root
ENV PATH="/opt/venv/bin:$PATH"
ENV TORCH_HOME=/data/models
ENV REQUIREMENTS_FILE=requirements_minimal.txt

# Install Git
RUN apt install git
COPY --from=lameenc-build /opt/venv /opt/venv

# Install needed packages
RUN apk update && apk add \
git \
ffmpeg
RUN python3 -m pip install --upgrade pip

# Install Facebook Demucs
RUN mkdir -p /lib/demucs

WORKDIR /lib/demucs

RUN git clone -b main --single-branch https://github.com/facebookresearch/demucs /lib/demucs
RUN git clone --depth 1 --branch main https://github.com/facebookresearch/demucs .

RUN python3 -m venv /opt/venv

RUN python3 -m pip install -e .
RUN python3 -m demucs.separate -d cpu test.mp3 # Trigger model download
RUN rm -r separated # cleanup
RUN sed -i '/lameenc>=1.2/d' ${REQUIREMENTS_FILE}
RUN python3 -m pip install -r ${REQUIREMENTS_FILE}
RUN python3 -m demucs.separate -d cpu --mp3 test.mp3 # Trigger model download \
&& rm -r separated # cleanup

VOLUME /data/input
VOLUME /data/output
Expand Down