diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml new file mode 100644 index 0000000..1c6ecd6 --- /dev/null +++ b/.github/workflows/build-image.yaml @@ -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/replace-string-action@v2.0 + 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 }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index c86c4c5..7c1a0f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,24 @@ -FROM python:3.8 +FROM python:3.8 as packages USER root ENV TORCH_HOME=/data/models -# Install Git -RUN apt install git +# Install needed packages +RUN apt update && apt install -y \ + git \ + ffmpeg # 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 sed -i 's/lameenc>=1.2/lameenc>=1.4.1/g' requirements.txt && cat requirements.txt RUN python3 -m pip install -e . -RUN python3 -m demucs.separate -d cpu test.mp3 # Trigger model download -RUN rm -r separated # cleanup +RUN python3 -m demucs.separate -d cpu --mp3 test.mp3 # Trigger model download \ + && rm -r separated # cleanup VOLUME /data/input VOLUME /data/output