From 3ef78d5e09eba1698b36dd5676174a71ff1c7d38 Mon Sep 17 00:00:00 2001 From: Taiga Takano Date: Sun, 3 Nov 2024 10:08:53 +0900 Subject: [PATCH] Support New Docker Sysytem --- .github/workflows/docker.yml | 40 +++++++++++++ .github/workflows/docker_check.yml | 70 ---------------------- .github/workflows/docker_release.yml | 80 ------------------------- .gitignore | 1 + Dockerfile | 19 ++++++ gradio_web_ui.py => app.py | 0 docker/Dockerfile.x86 | 14 ----- docker/poetry.lock => poetry.lock | 0 poetylock.sh | 3 - docker/pyproject.toml => pyproject.toml | 0 run_dev_env.sh | 2 +- 11 files changed, 61 insertions(+), 168 deletions(-) create mode 100644 .github/workflows/docker.yml delete mode 100644 .github/workflows/docker_check.yml delete mode 100644 .github/workflows/docker_release.yml create mode 100644 Dockerfile rename gradio_web_ui.py => app.py (100%) delete mode 100644 docker/Dockerfile.x86 rename docker/poetry.lock => poetry.lock (100%) rename docker/pyproject.toml => pyproject.toml (100%) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..77533c6 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,40 @@ +name: Docker Build and Push to GHCR +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-push: + runs-on: ubuntu-22.04 + + steps: + - name: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + tool-cache: false + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to GitHub Container Registry + if: github.event_name == 'push' + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Docker image + run: | + docker build -t ghcr.io/${{ github.repository }}_dev:latest --target builder_image . + docker build -t ghcr.io/${{ github.repository }}:latest --target release_image . + + - name: Push Docker image + if: github.event_name == 'push' + run: | + docker push ghcr.io/${{ github.repository }}_dev:latest + docker push ghcr.io/${{ github.repository }}:latest diff --git a/.github/workflows/docker_check.yml b/.github/workflows/docker_check.yml deleted file mode 100644 index 1b41e96..0000000 --- a/.github/workflows/docker_check.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Docker Build -on: - pull_request: - branches: - - main - -jobs: - build-check: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Clean space as per https://github.com/actions/virtual-environments/issues/709 - run: | - docker images - sudo rm -rf "/opt/ghc" || true - sudo rm -rf "/usr/share/dotnet" || true - sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true - sudo rm -rf "/usr/local/lib/android" || true - sudo rm -rf "/usr/local/share/boost" || true - docker rmi $(docker image ls -q --filter "reference=node*") - docker rmi $(docker image ls -q --filter "reference=debian*") - docker rmi $(docker image ls -q --filter "reference=alpine*") - docker rmi $(docker image ls -q --filter "reference=ubuntu:20.04") - - name: apt-get remove cleanup - run: | - sudo apt purge -y \ - ansible* \ - aria2* \ - aspnetcore* \ - azure-cli* \ - cabal* \ - clang* \ - dotnet-* \ - firefox* \ - gfortran-* \ - ghc* \ - google-chrome-stable* \ - google-cloud-sdk* \ - heroku* \ - imagemagick* \ - javascript* \ - kubectl* \ - llvm* \ - mono* \ - mysql* \ - nginx* \ - node* \ - npm* \ - nuget* \ - php* \ - postgresql* \ - powershell* \ - rpm* \ - ruby* \ - sqlite3* \ - subversion \ - temurin* \ - tmux* \ - vim* \ - yarn* - sudo apt-get autoremove -y >/dev/null 2>&1 || true - sudo apt-get autoclean -y >/dev/null 2>&1 || true - - - name: Build Docker image - run: | - cd docker && docker build . -f ./Dockerfile.x86 -t ghcr.io/${{ github.repository }}:latest - diff --git a/.github/workflows/docker_release.yml b/.github/workflows/docker_release.yml deleted file mode 100644 index 9efac6c..0000000 --- a/.github/workflows/docker_release.yml +++ /dev/null @@ -1,80 +0,0 @@ -name: Docker Build and Push to GHCR -on: - push: - branches: - - main - -jobs: - build-and-push: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - - name: Log in to GitHub Container Registry - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Clean space as per https://github.com/actions/virtual-environments/issues/709 - run: | - docker images - sudo rm -rf "/opt/ghc" || true - sudo rm -rf "/usr/share/dotnet" || true - sudo rm -rf "$AGENT_TOOLSDIRECTORY" || true - sudo rm -rf "/usr/local/lib/android" || true - sudo rm -rf "/usr/local/share/boost" || true - docker rmi $(docker image ls -q --filter "reference=node*") - docker rmi $(docker image ls -q --filter "reference=debian*") - docker rmi $(docker image ls -q --filter "reference=alpine*") - docker rmi $(docker image ls -q --filter "reference=ubuntu:20.04") - - name: apt-get remove cleanup - run: | - sudo apt purge -y \ - ansible* \ - aria2* \ - aspnetcore* \ - azure-cli* \ - cabal* \ - clang* \ - dotnet-* \ - firefox* \ - gfortran-* \ - ghc* \ - google-chrome-stable* \ - google-cloud-sdk* \ - heroku* \ - imagemagick* \ - javascript* \ - kubectl* \ - llvm* \ - mono* \ - mysql* \ - nginx* \ - node* \ - npm* \ - nuget* \ - php* \ - postgresql* \ - powershell* \ - rpm* \ - ruby* \ - sqlite3* \ - subversion \ - temurin* \ - tmux* \ - vim* \ - yarn* - sudo apt-get autoremove -y >/dev/null 2>&1 || true - sudo apt-get autoclean -y >/dev/null 2>&1 || true - - - name: Build Docker image - run: | - cd docker && docker build . -f ./Dockerfile.x86 -t ghcr.io/${{ github.repository }}:latest - - - name: Push Docker image - run: | - docker push ghcr.io/${{ github.repository }}:latest diff --git a/.gitignore b/.gitignore index 5e2d2ba..12b6099 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,6 @@ *.png *.onnx *.engine +*.mcap flagged*/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..a7222f5 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,19 @@ +FROM ultralytics/ultralytics:8.2.63 AS builder_image + +RUN apt-get update && apt-get install -y git curl ffmpeg +RUN git config --global --add safe.directory /app +RUN python3 -m pip install --upgrade pip +RUN python3 -m pip install poetry \ + && poetry config virtualenvs.create false + +WORKDIR /app + +COPY pyproject.toml poetry.lock ./ +RUN poetry install --no-root + +FROM builder_image AS release_image + +COPY --from=builder_image /app /app +COPY . /app/ + +CMD [ "python3", "app.py" ] \ No newline at end of file diff --git a/gradio_web_ui.py b/app.py similarity index 100% rename from gradio_web_ui.py rename to app.py diff --git a/docker/Dockerfile.x86 b/docker/Dockerfile.x86 deleted file mode 100644 index e4039ee..0000000 --- a/docker/Dockerfile.x86 +++ /dev/null @@ -1,14 +0,0 @@ -FROM ultralytics/ultralytics:8.2.63 - -RUN apt-get update && apt-get install -y curl - -RUN git config --global --add safe.directory /app - -RUN python3 -m pip install --upgrade pip -RUN pip install poetry \ - && poetry config virtualenvs.create false - -WORKDIR /app -COPY pyproject.toml* poetry.lock* ./ - -RUN poetry install diff --git a/docker/poetry.lock b/poetry.lock similarity index 100% rename from docker/poetry.lock rename to poetry.lock diff --git a/poetylock.sh b/poetylock.sh index 2b6f548..dfdb25e 100755 --- a/poetylock.sh +++ b/poetylock.sh @@ -1,7 +1,4 @@ #!/bin/bash -cp /home/root/docker/pyproject.toml /app/pyproject.toml cd /app poetry lock --no-update -rm -rf /home/root/docker/poetry.lock -cp /app/poetry.lock /home/root/docker/poetry.lock \ No newline at end of file diff --git a/docker/pyproject.toml b/pyproject.toml similarity index 100% rename from docker/pyproject.toml rename to pyproject.toml diff --git a/run_dev_env.sh b/run_dev_env.sh index b8c869c..295d176 100755 --- a/run_dev_env.sh +++ b/run_dev_env.sh @@ -32,7 +32,7 @@ PLATFORM="$(uname -m)" if [ $PLATFORM = "x86_64" ]; then echo "x86" docker pull ghcr.io/moriyalab/horus_inference_server:latest - docker run -it --rm --gpus all --runtime nvidia --shm-size=32G -v $ROOT/datasets:/usr/src/datasets -v $ROOT:/home/root -w /home/root --network host ghcr.io/moriyalab/horus_inference_server:latest + docker run -it --rm --gpus all --runtime nvidia --shm-size=32G -v $ROOT/datasets:/usr/src/datasets -v $ROOT:/home/root -w /home/root --network host ghcr.io/moriyalab/horus_inference_server_dev:latest else echo "Not Support Platform. Only support x86." fi \ No newline at end of file