diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml new file mode 100644 index 00000000..bd8a44fb --- /dev/null +++ b/.github/workflows/build_docker.yml @@ -0,0 +1,48 @@ +name: Build and push docker image + +on: + workflow_dispatch: + push: + tags: + - 'v*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + docker: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check out source code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + #if: startsWith(github.ref, 'refs/tags/') + uses: docker/build-push-action@v4 + with: + push: true + context: . + file: ./docker/Dockerfile.cpu + tags: ${{ steps.meta.outputs.tags }} + build-args: | + "GITHUB_ACTIONS=${GITHUB_ACTIONS}" diff --git a/build.sh b/build.sh index 19c1151e..c831231f 100755 --- a/build.sh +++ b/build.sh @@ -60,6 +60,10 @@ then then LOCAL_BUILD=0 fi + if [ "$1" = "disable_cuda" ] + then + CUDA_ENABLE=OFF + fi fi mkdir -p output diff --git a/docker/Dockerfile.cpu b/docker/Dockerfile.cpu new file mode 100644 index 00000000..c243f551 --- /dev/null +++ b/docker/Dockerfile.cpu @@ -0,0 +1,29 @@ +FROM ubuntu:20.04 + +ARG DEVICE=cpu +ARG GITHUB_ACTIONS + +ENV GITHUB_ACTIONS=${GITHUB_ACTIONS} +ENV DEBIAN_FRONTEND noninteractive + +# required +RUN apt update \ + && apt install -y make git pkg-config libssl-dev cmake python3 python3-dev python3-pip binutils-dev libgoogle-glog-dev gcc g++ + +# optional +RUN apt install -y libopencv-dev libomp-dev libtorch3-dev + +RUN pip install setuptools timeout_decorator + +COPY ./ /root/bmf/ +WORKDIR /root/bmf/ + +# ffmpeg installed via apt has no development libraries, so we build it from source +RUN scripts/build_ffmpeg.sh --device=$DEVICE nasm yasm x264 x265 fdk-aac opus \ + && rm -rf ffmpeg_source + +RUN ./build.sh disable_cuda && rm -rf .git && ./build.sh clean + +ENV LD_LIBRARY_PATH=/root/bmf/output/bmf/lib +ENV PATH=${PATH}:/root/bmf/output/bmf/bin +ENV PYTHONPATH=/root/bmf/output diff --git a/setup.py b/setup.py index dd3c1f79..a314011d 100644 --- a/setup.py +++ b/setup.py @@ -178,6 +178,8 @@ def build_extension(self, ext: CMakeExtension) -> None: author_email="", python_requires='>= 3.6', description="Babit Multimedia Framework", + long_description=open('README.md').read(), + long_description_content_type='text/markdown', readme='README.md', url="https://github.com/BabitMF/bmf", install_requires=[