diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..1758b37 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +/venv +Dockerfile +docker-compose-build.yml \ No newline at end of file diff --git a/.github/workflows/build-publish-docker-image.yml b/.github/workflows/build-publish-docker-image.yml new file mode 100644 index 0000000..6186136 --- /dev/null +++ b/.github/workflows/build-publish-docker-image.yml @@ -0,0 +1,37 @@ +name: Build and Publish Docker Image + +on: + push: + branches: + - '**' + +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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..16e5083 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +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 . + +ENV MODEL_NAME=ViT-B-16:openai + +ENTRYPOINT clip-api-service serve --model-name=${MODEL_NAME} \ No newline at end of file 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: 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 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