From 4545c0491e9e370ff731d73885b37ea03364a2ff Mon Sep 17 00:00:00 2001 From: Xavier Serrat Bordas Date: Sun, 13 Nov 2022 19:53:44 +0100 Subject: [PATCH] [#15] Add build-image.yaml workflow to build and publish to DockerHub the latest version --- .github/workflows/build-image.yaml | 43 ++++++++++++++++++++++++++++++ Dockerfile | 14 +++++----- 2 files changed, 51 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build-image.yaml diff --git a/.github/workflows/build-image.yaml b/.github/workflows/build-image.yaml new file mode 100644 index 0000000..0901e7c --- /dev/null +++ b/.github/workflows/build-image.yaml @@ -0,0 +1,43 @@ +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 + 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..8ce935e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,23 @@ -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 /lib/demucs 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