Skip to content

Commit 5835627

Browse files
committed
CPU/Cuda versions
1 parent 97fd1e2 commit 5835627

File tree

8 files changed

+185
-314
lines changed

8 files changed

+185
-314
lines changed

.github/workflows/cd.yaml

+27-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ env:
99
IMAGE_ID: ghcr.io/${{ github.repository_owner }}/docling-inference
1010

1111
jobs:
12-
push:
12+
push-cuda:
1313
runs-on: ubuntu-latest
1414

1515
steps:
@@ -23,6 +23,7 @@ jobs:
2323
- name: Set up Docker Buildx
2424
uses: docker/setup-buildx-action@v3
2525

26+
# Build and push cuda version
2627
- name: Build and push Docker image
2728
uses: docker/build-push-action@v6
2829
with:
@@ -31,3 +32,28 @@ jobs:
3132
tags: ${{ env.IMAGE_ID }}:latest,${{ env.IMAGE_ID }}:${{ github.sha }}
3233
cache-from: type=registry,ref=${{ env.IMAGE_ID }}:buildcache
3334
cache-to: type=registry,ref=${{ env.IMAGE_ID }}:buildcache,mode=max
35+
36+
push-cpu:
37+
runs-on: ubuntu-latest
38+
39+
steps:
40+
- name: Checkout Code
41+
uses: actions/checkout@v3
42+
43+
- name: Docker login
44+
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
45+
46+
# Use buildx which can cache docker layers between runs
47+
- name: Set up Docker Buildx
48+
uses: docker/setup-buildx-action@v3
49+
50+
# Build and push cpu version
51+
- name: Build and push Docker image
52+
uses: docker/build-push-action@v6
53+
with:
54+
context: .
55+
push: true
56+
file: Dockerfile.cpu
57+
tags: ${{ env.IMAGE_ID }}:cpu-latest,${{ env.IMAGE_ID }}:cpu-${{ github.sha }}
58+
cache-from: type=registry,ref=${{ env.IMAGE_ID }}:cpu-buildcache
59+
cache-to: type=registry,ref=${{ env.IMAGE_ID }}:cpu-buildcache,mode=max

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUN pip install --upgrade pip && \
66
poetry config virtualenvs.in-project true
77

88
COPY pyproject.toml poetry.lock /app/
9-
RUN poetry install --no-ansi
9+
RUN poetry install --no-ansi --with=cuda
1010

1111
FROM python:3.11-slim-bookworm
1212
WORKDIR /app

Dockerfile.cpu

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
FROM python:3.11-slim-bookworm AS builder
2+
WORKDIR /app
3+
4+
RUN pip install --upgrade pip && \
5+
pip install poetry && \
6+
poetry config virtualenvs.in-project true
7+
8+
COPY pyproject.toml poetry.lock /app/
9+
RUN poetry install --no-ansi --with=cpu
10+
11+
FROM python:3.11-slim-bookworm
12+
WORKDIR /app
13+
14+
COPY --from=builder /app /app
15+
COPY src /app/src
16+
17+
CMD [ "/app/.venv/bin/python", "-m", "src.main" ]

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ docker run -d \
2020
-e NUM_WORKERS=8 \
2121
-v hf_cache:/root/.cache/huggingface \
2222
-v ocr_cache:/root/.EasyOCR \
23-
docling-inference
23+
ghcr.io/aidotse/docling-inference:latest
2424
```
2525

2626
### Docker compose
2727

2828
```yaml
2929
services:
3030
docling-inference:
31-
image: docling-inference
31+
image: ghcr.io/aidotse/docling-inference:latest
3232
ports:
3333
- 8080:8080
3434
environment:

docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
docling-inference:
3-
image: docling-inference:dev
3+
image: ghcr.io/aidotse/docling-inference:dev
44
ports:
55
- 8080:8080
66
environment:

justfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
compose := "docker compose"
2-
image := "docling-inference"
2+
image := "ghcr.io/aidotse/docling-inference"
33
rev := shell("git rev-parse --short HEAD")
44

5-
65
default:
76
just --list
87

98
build:
109
docker build -t {{image}}:dev -t {{image}}:{{rev}} .
1110

11+
build-cpu:
12+
docker build -f Dockerfile.cpu -t {{image}}:cpu-dev -t {{image}}:cpu-{{rev}} .
13+
1214
up:
1315
{{compose}} up --remove-orphans
1416

poetry.lock

+118-306
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+15-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,28 @@ packages = [{include = "src"}]
1010

1111
[tool.poetry.dependencies]
1212
python = "^3.11"
13-
torch = "^2.5.1"
1413
docling = "^2.10.0"
1514
fastapi = "^0.115.6"
1615
uvicorn = "^0.32.1"
1716
python-multipart = "^0.0.19"
1817

1918

2019

20+
[[tool.poetry.source]]
21+
name = "pytorch_cpu"
22+
url = "https://download.pytorch.org/whl/cpu"
23+
priority = "explicit"
24+
25+
26+
[tool.poetry.group.cpu.dependencies]
27+
torch = {version = "^2.5.1+cpu", source = "pytorch_cpu"}
28+
torchvision = {version = "^0.20.1+cpu", source = "pytorch_cpu"}
29+
30+
31+
[tool.poetry.group.cuda.dependencies]
32+
torch = "^2.5.1"
33+
torchvision = "^0.20.1"
34+
2135
[build-system]
2236
requires = ["poetry-core"]
2337
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)