Skip to content

Add Docker & Docker Compose #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/venv
Dockerfile
docker-compose-build.yml
37 changes: 37 additions & 0 deletions .github/workflows/build-publish-docker-image.yml
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM python:3.11-slim
LABEL authors="sushka0 <[email protected]>, BentoML Authors <[email protected]>"

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}
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
11 changes: 11 additions & 0 deletions docker-compose-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 'v1'

services:
clip-api:
build:
.
ports:
- "3000:3000"
restart: unless-stopped
environment:
- MODEL_NAME=ViT-B-32:openai
10 changes: 10 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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