From bcac8c6ec6ee81f6e766a06aa9a9f3c18db464a1 Mon Sep 17 00:00:00 2001 From: roman mac Date: Sun, 14 Jan 2024 12:14:37 +0300 Subject: [PATCH 01/12] =?UTF-8?q?=F0=9F=90=B3=20build:=20add=20Dockerfile?= =?UTF-8?q?=20and=20.dockerignore=20for=20container=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 1 + Dockerfile | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a979ee7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +/venv \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7f108cf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3.11-slim +LABEL authors="sushka0 , BentoML Authors " + +COPY . . + +RUN pip install . + +ENV MODEL_NAME="ViT-B-32:openai" + +ENTRYPOINT ["clip-as-service", "serve", "--model-name=${MODEL_NAME}"] \ No newline at end of file From b79834e1c2a429eaf5d726e9b98b758275f74781 Mon Sep 17 00:00:00 2001 From: roman mac Date: Sun, 14 Jan 2024 12:18:10 +0300 Subject: [PATCH 02/12] =?UTF-8?q?=F0=9F=90=9B=20fix(docker):=20add=20missi?= =?UTF-8?q?ng=20system=20dependencies=20installation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile b/Dockerfile index 7f108cf..52b9c4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ FROM python:3.11-slim LABEL authors="sushka0 , BentoML Authors " +RUN apt update -y +RUN apt-get install gcc python3-dev -y + COPY . . RUN pip install . From 66176296d6d79794276b69247535463038476815 Mon Sep 17 00:00:00 2001 From: roman mac Date: Sun, 14 Jan 2024 12:22:42 +0300 Subject: [PATCH 03/12] =?UTF-8?q?=F0=9F=90=B3=20ci(docker):=20add=20workfl?= =?UTF-8?q?ow=20to=20build=20and=20publish=20Docker=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/build-publish-docker-image.yml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/build-publish-docker-image.yml diff --git a/.github/workflows/build-publish-docker-image.yml b/.github/workflows/build-publish-docker-image.yml new file mode 100644 index 0000000..3398473 --- /dev/null +++ b/.github/workflows/build-publish-docker-image.yml @@ -0,0 +1,37 @@ +name: Build and Publish Docker Image + +on: + push: + branches: + - main + +jobs: + build-and-publish-main: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check Out Repository + uses: actions/checkout@v2 + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/clip-as-service:latest + ghcr.io/${{ github.repository_owner }}/clip-as-service:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max From f340464bef00d954609b129716a487ca3c48d2e9 Mon Sep 17 00:00:00 2001 From: roman mac Date: Sun, 14 Jan 2024 12:24:50 +0300 Subject: [PATCH 04/12] =?UTF-8?q?=F0=9F=90=9B=20fix(ci):=20update=20docker?= =?UTF-8?q?=20image=20name=20in=20GitHub=20Actions=20workflow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-publish-docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-publish-docker-image.yml b/.github/workflows/build-publish-docker-image.yml index 3398473..5911fc0 100644 --- a/.github/workflows/build-publish-docker-image.yml +++ b/.github/workflows/build-publish-docker-image.yml @@ -31,7 +31,7 @@ jobs: context: . push: true tags: | - ghcr.io/${{ github.repository_owner }}/clip-as-service:latest - ghcr.io/${{ github.repository_owner }}/clip-as-service:${{ github.sha }} + ghcr.io/${{ github.repository_owner }}/clip-api-service:latest + ghcr.io/${{ github.repository_owner }}/clip-api-service:${{ github.sha }} cache-from: type=gha cache-to: type=gha,mode=max From 12528771f8dcb48439a2f50d0b256f9f9669ad50 Mon Sep 17 00:00:00 2001 From: roman mac Date: Sun, 14 Jan 2024 12:27:54 +0300 Subject: [PATCH 05/12] =?UTF-8?q?=F0=9F=9B=A0=EF=B8=8F=20fix(docker):=20in?= =?UTF-8?q?clude=20Dockerfile=20and=20compose=20file=20in=20ignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .dockerignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.dockerignore b/.dockerignore index a979ee7..1758b37 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,3 @@ -/venv \ No newline at end of file +/venv +Dockerfile +docker-compose-build.yml \ No newline at end of file From e806c12f30874798d03218db617957e967077861 Mon Sep 17 00:00:00 2001 From: roman mac Date: Sun, 14 Jan 2024 13:05:46 +0300 Subject: [PATCH 06/12] =?UTF-8?q?=F0=9F=90=B3=20fix(dockerfile):=20update?= =?UTF-8?q?=20model=20name=20and=20entrypoint=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 52b9c4d..16e5083 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,6 @@ COPY . . RUN pip install . -ENV MODEL_NAME="ViT-B-32:openai" +ENV MODEL_NAME=ViT-B-16:openai -ENTRYPOINT ["clip-as-service", "serve", "--model-name=${MODEL_NAME}"] \ No newline at end of file +ENTRYPOINT clip-api-service serve --model-name=${MODEL_NAME} \ No newline at end of file From c0ade0bba768ae6991c673c092383eecc8ffdae1 Mon Sep 17 00:00:00 2001 From: roman mac Date: Sun, 14 Jan 2024 13:36:03 +0300 Subject: [PATCH 07/12] =?UTF-8?q?=F0=9F=9A=80=20feat(docker):=20add=20dock?= =?UTF-8?q?er-compose=20for=20CLIP=20API=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose-build.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 docker-compose-build.yml diff --git a/docker-compose-build.yml b/docker-compose-build.yml new file mode 100644 index 0000000..4115bd0 --- /dev/null +++ b/docker-compose-build.yml @@ -0,0 +1,11 @@ +version: 'v1' + +services: + clip-api: + build: + . + ports: + - "3000:3000" + restart: unless-stopped + environment: + - MODEL_NAME=ViT-B-32:openai \ No newline at end of file From 4319c5d9965c59c5b0dc7fbc9b8e03130aef3cff Mon Sep 17 00:00:00 2001 From: roman mac Date: Sun, 14 Jan 2024 13:36:37 +0300 Subject: [PATCH 08/12] =?UTF-8?q?=F0=9F=90=B3=20ci(docker):=20remove=20wor?= =?UTF-8?q?kflow=20to=20build=20and=20publish=20Docker=20image?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/build-publish-docker-image.yml | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 .github/workflows/build-publish-docker-image.yml diff --git a/.github/workflows/build-publish-docker-image.yml b/.github/workflows/build-publish-docker-image.yml deleted file mode 100644 index 5911fc0..0000000 --- a/.github/workflows/build-publish-docker-image.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Build and Publish Docker Image - -on: - push: - branches: - - main - -jobs: - build-and-publish-main: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Check Out Repository - uses: actions/checkout@v2 - - - name: Setup Docker buildx - uses: docker/setup-buildx-action@v3 - - - name: Log in to GitHub Container Registry - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: . - push: true - tags: | - ghcr.io/${{ github.repository_owner }}/clip-api-service:latest - ghcr.io/${{ github.repository_owner }}/clip-api-service:${{ github.sha }} - cache-from: type=gha - cache-to: type=gha,mode=max From 9760a2c03f02bb55cf2da82ace2c0b9edf7998ae Mon Sep 17 00:00:00 2001 From: roman mac Date: Sun, 14 Jan 2024 13:41:56 +0300 Subject: [PATCH 09/12] =?UTF-8?q?=F0=9F=90=B3=20feat(docker):=20add=20Dock?= =?UTF-8?q?er=20Compose=20instructions=20to=20README.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 3f36b99..16deb86 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,24 @@ Your service is now running! Interact with it via the Swagger UI at `localhost:3 Or try this tutorial in Google Colab: [CLIP demo](https://colab.research.google.com/github/bentoml/CLIP-API-service/blob/main/example/clip_demo.ipynb). +## 🐳 Start using Docker Compose 🐳 +Also, you can start your CLIP-API using docker-compose by running these commands one-by-one: +```bash +git clone https://github.com/bentoml/CLIP-API-service +cd CLIP-API-service +docker compose -f docker-compose-build.yml up -d # or docker-compose ... +``` + +Your service is now running! Interact with it via the Swagger UI at `localhost:3000` + +_You can set another CLIP model inside `docker-compose-build.yml` file:_ +```yaml +... + environment: + - MODEL_NAME=ViT-B-32:openai +... +``` + ## 🎯 Use cases 🎯 Harness the capabilities of the CLIP API service across a range of applications: From 41fdb13be4d028b9f13b63b50c97f730170bb52e Mon Sep 17 00:00:00 2001 From: roman mac Date: Mon, 15 Jan 2024 19:21:17 +0300 Subject: [PATCH 10/12] =?UTF-8?q?Revert=20"=F0=9F=90=B3=20ci(docker):=20re?= =?UTF-8?q?move=20workflow=20to=20build=20and=20publish=20Docker=20image"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 4319c5d9965c59c5b0dc7fbc9b8e03130aef3cff. --- .../workflows/build-publish-docker-image.yml | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/build-publish-docker-image.yml diff --git a/.github/workflows/build-publish-docker-image.yml b/.github/workflows/build-publish-docker-image.yml new file mode 100644 index 0000000..5911fc0 --- /dev/null +++ b/.github/workflows/build-publish-docker-image.yml @@ -0,0 +1,37 @@ +name: Build and Publish Docker Image + +on: + push: + branches: + - main + +jobs: + build-and-publish-main: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Check Out Repository + uses: actions/checkout@v2 + + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: | + ghcr.io/${{ github.repository_owner }}/clip-api-service:latest + ghcr.io/${{ github.repository_owner }}/clip-api-service:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max From aab39d352aaec5d26cd3e6c6286582c0d1e70a4c Mon Sep 17 00:00:00 2001 From: roman mac Date: Mon, 15 Jan 2024 19:24:15 +0300 Subject: [PATCH 11/12] =?UTF-8?q?=F0=9F=93=A6=20feat:=20add=20docker-compo?= =?UTF-8?q?se=20for=20CLIP=20API=20service?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..30a1441 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: 'v1' + +services: + clip-api: + image: ghcr.io/bentoml/clip-api-service:latest + ports: + - "3000:3000" + restart: unless-stopped + environment: + - MODEL_NAME=ViT-B-32:openai \ No newline at end of file From 998c3db67531d9adf09c4c15f43c419db8779b4b Mon Sep 17 00:00:00 2001 From: roman mac Date: Mon, 15 Jan 2024 19:26:36 +0300 Subject: [PATCH 12/12] =?UTF-8?q?=F0=9F=94=A7=20fix(ci):=20trigger=20workf?= =?UTF-8?q?low=20on=20push=20to=20any=20branch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-publish-docker-image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-publish-docker-image.yml b/.github/workflows/build-publish-docker-image.yml index 5911fc0..6186136 100644 --- a/.github/workflows/build-publish-docker-image.yml +++ b/.github/workflows/build-publish-docker-image.yml @@ -3,7 +3,7 @@ name: Build and Publish Docker Image on: push: branches: - - main + - '**' jobs: build-and-publish-main: