vishnoianil dolfim-ibm commited on
Commit
6237d61
·
unverified ·
1 Parent(s): 44657b5

Publish docling-serve images to ghcr and quay container repositories (#1)

Browse files

* Publish docling-serve images to ghcr and quay container repositories

This commit:
- Creates container file to build the image for cpu only
and default "with gpu" images
- Adds workflow jobs to publish the images to ghcr.io and quay.io
- Makefile to build these images locally for linux/amd64 platform.

Signed-off-by: Anil Vishnoi <[email protected]>

* make cpu-only version with poetry

Signed-off-by: Michele Dolfi <[email protected]>

* Rename cpu/gpu image names and also update the supported platforms

Signed-off-by: Anil Vishnoi <[email protected]>

---------

Signed-off-by: Anil Vishnoi <[email protected]>
Signed-off-by: Michele Dolfi <[email protected]>
Co-authored-by: Michele Dolfi <[email protected]>

Files changed (5) hide show
  1. .github/workflow/images.yml +152 -0
  2. Containerfile +32 -1
  3. Makefile +29 -0
  4. poetry.lock +0 -0
  5. pyproject.toml +27 -4
.github/workflow/images.yml ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Publish docling-serve images
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ env:
9
+ GHCR_REGISTRY: ghcr.io
10
+ GHCR_DOCLING_SERVE_CPU_IMAGE_NAME: ${{ github.repository }}/ds4sd/docling-serve-cpu
11
+ GHCR_DOCLING_SERVE_GPU_IMAGE_NAME: ${{ github.repository }}/ds4sd/docling-serve
12
+ QUAY_REGISTRY: quay.io
13
+ QUAY_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu
14
+ QUAY_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve
15
+
16
+ jobs:
17
+ build_and_publish_ui_image:
18
+ name: Push docling-serve container images to GHCR and QUAY
19
+ runs-on: ubuntu-latest
20
+ environment: registry-creds
21
+ permissions:
22
+ packages: write
23
+ contents: read
24
+ attestations: write
25
+ id-token: write
26
+
27
+ steps:
28
+ - name: Check out the repo
29
+ uses: actions/checkout@v4
30
+
31
+ - name: Log in to the GHCR container image registry
32
+ uses: docker/login-action@v3
33
+ with:
34
+ registry: ${{ env.GHCR_REGISTRY }}
35
+ username: ${{ github.actor }}
36
+ password: ${{ secrets.GITHUB_TOKEN }}
37
+
38
+ - name: Log in to the Quay container image registry
39
+ uses: docker/login-action@v3
40
+ with:
41
+ registry: ${{ env.QUAY_REGISTRY }}
42
+ username: ${{ secrets.QUAY_USERNAME }}
43
+ password: ${{ secrets.QUAY_TOKEN }}
44
+
45
+ - name: Set up Docker Buildx
46
+ uses: docker/setup-buildx-action@v3
47
+
48
+ - name: Cache Docker layers
49
+ uses: actions/cache@v4
50
+ with:
51
+ path: /tmp/.buildx-cache
52
+ key: ${{ runner.os }}-buildx-${{ github.sha }}
53
+ restore-keys: |
54
+ ${{ runner.os }}-buildx-
55
+
56
+ - name: Extract metadata (tags, labels) for docling-serve/cpu ghcr image
57
+ id: ghcr_serve_cpu_meta
58
+ uses: docker/metadata-action@v5
59
+ with:
60
+ images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_CPU_IMAGE_NAME }}
61
+
62
+ - name: Extract metadata (tags, labels) for docling-serve/gpu ghcr image
63
+ id: ghcr_serve_gpu_meta
64
+ uses: docker/metadata-action@v5
65
+ with:
66
+ images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_GPU_IMAGE_NAME }}
67
+
68
+ - name: Extract metadata (tags, labels) for docling-serve/cpu quay image
69
+ id: quay_serve_cpu_meta
70
+ uses: docker/metadata-action@v5
71
+ with:
72
+ images: ${{ env.QUAY_REGISTRY }}/${{ env.QUAY_DOCLING_SERVE_CPU_IMAGE_NAME }}
73
+
74
+ - name: Extract metadata (tags, labels) for docking-serve/gpu quay image
75
+ id: quay_serve_gpu_meta
76
+ uses: docker/metadata-action@v5
77
+ with:
78
+ images: ${{ env.QUAY_REGISTRY }}/${{ env.QUAY_DOCLING_SERVE_GPU_IMAGE_NAME }}
79
+
80
+ - name: Build and push docling-serve/cpu image to ghcr.io
81
+ id: push-serve-cpu-ghcr
82
+ uses: docker/build-push-action@v5
83
+ with:
84
+ context: .
85
+ push: true
86
+ tags: ${{ steps.ghcr_serve_cpu_meta.outputs.tags }}
87
+ labels: ${{ steps.ghcr_serve_cpu_meta.outputs.labels }}
88
+ platforms: linux/amd64
89
+ cache-from: type=gha
90
+ cache-to: type=gha,mode=max
91
+ file: Containerfile
92
+ build-args: |
93
+ --build-arg CPU_ONLY=true
94
+
95
+ - name: Generate artifact attestation
96
+ uses: actions/attest-build-provenance@v1
97
+ with:
98
+ subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_CPU_IMAGE_NAME}}
99
+ subject-digest: ${{ steps.push-serve-cpu-ghcr.outputs.digest }}
100
+ push-to-registry: true
101
+
102
+ - name: Build and push docling-serve/gpu image to ghcr.io
103
+ id: push-serve-gpu-ghcr
104
+ uses: docker/build-push-action@v5
105
+ with:
106
+ context: .
107
+ push: true
108
+ tags: ${{ steps.ghcr_serve_gpu_meta.outputs.tags }}
109
+ labels: ${{ steps.ghcr_serve_gpu_meta.outputs.labels }}
110
+ platforms: linux/amd64,linux/arm64
111
+ cache-from: type=gha
112
+ cache-to: type=gha,mode=max
113
+ file: Containerfile
114
+ build-args: |
115
+ --build-arg CPU_ONLY=false
116
+
117
+ - name: Generate artifact attestation
118
+ uses: actions/attest-build-provenance@v1
119
+ with:
120
+ subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_GPU_IMAGE_NAME}}
121
+ subject-digest: ${{ steps.push-serve-gpu-ghcr.outputs.digest }}
122
+ push-to-registry: true
123
+
124
+ - name: Build and push docling-serve/cpu image to quay.io
125
+ id: push-serve-cpu-quay
126
+ uses: docker/build-push-action@v5
127
+ with:
128
+ context: .
129
+ push: true
130
+ tags: ${{ steps.quay_serve_cpu_meta.outputs.tags }}
131
+ labels: ${{ steps.quay_serve_cpu_meta.outputs.labels }}
132
+ platforms: linux/amd64
133
+ cache-from: type=gha
134
+ cache-to: type=gha,mode=max
135
+ file: Containerfile
136
+ build-args: |
137
+ --build-arg CPU_ONLY=true
138
+
139
+ - name: Build and push docling-serve/gpu image to quay.io
140
+ id: push-serve-gpu-quay
141
+ uses: docker/build-push-action@v5
142
+ with:
143
+ context: .
144
+ push: true
145
+ tags: ${{ steps.quay_serve_gpu_meta.outputs.tags }}
146
+ labels: ${{ steps.quay_serve_gpu_meta.outputs.labels }}
147
+ platforms: linux/amd64,linux/arm64
148
+ cache-from: type=gha
149
+ cache-to: type=gha,mode=max
150
+ file: Containerfile
151
+ build-args: |
152
+ --build-arg CPU_ONLY=false
Containerfile CHANGED
@@ -1 +1,32 @@
1
- # TODO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim-bookworm
2
+
3
+ ARG CPU_ONLY=false
4
+ WORKDIR /docling-serve
5
+
6
+ RUN apt-get update \
7
+ && apt-get install -y libgl1 libglib2.0-0 curl wget git \
8
+ && apt-get clean
9
+
10
+ RUN pip install --no-cache-dir poetry
11
+
12
+ COPY pyproject.toml poetry.lock README.md /docling-serve/
13
+
14
+ RUN if [ "$CPU_ONLY" = "true" ]; then \
15
+ poetry install --no-root --with cpu; \
16
+ else \
17
+ poetry install --no-root; \
18
+ fi
19
+
20
+ ENV HF_HOME=/tmp/
21
+ ENV TORCH_HOME=/tmp/
22
+
23
+ RUN poetry run python -c 'from docling.document_converter import DocumentConverter; artifacts_path = DocumentConverter.download_models_hf(force=True);'
24
+
25
+ # On container environments, always set a thread budget to avoid undesired thread congestion.
26
+ ENV OMP_NUM_THREADS=4
27
+
28
+ COPY ./docling_serve /docling-serve/docling_serve
29
+
30
+ EXPOSE 5000
31
+
32
+ CMD ["poetry", "run", "uvicorn", "--port", "5000", "docling_serve.app:app"]
Makefile ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .PHONY: help
2
+ help:
3
+ @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
4
+
5
+ #
6
+ # If you want to see the full commands, run:
7
+ # NOISY_BUILD=y make
8
+ #
9
+ ifeq ($(NOISY_BUILD),)
10
+ ECHO_PREFIX=@
11
+ CMD_PREFIX=@
12
+ else
13
+ ECHO_PREFIX=@\#
14
+ CMD_PREFIX= PIPE_DEV_NULL=
15
+ endif
16
+
17
+ TAG=$(shell git rev-parse HEAD)
18
+
19
+ docling-serve-cpu-image: Containerfile ## Build docling-serve "cpu only" continaer image
20
+ $(ECHO_PREFIX) printf " %-12s Containerfile\n" "[docling-serve CPU ONLY]"
21
+ $(CMD_PREFIX) docker build --build-arg CPU_ONLY=true -f Containerfile --platform linux/amd64 -t ghcr.io/ds4sd/docling-serve-cpu:$(TAG) .
22
+ $(CMD_PREFIX) docker tag ghcr.io/ds4sd/docling-serve-cpu:$(TAG) ghcr.io/ds4sd/docling-serve-cpu:main
23
+ $(CMD_PREFIX) docker tag ghcr.io/ds4sd/docling-serve-cpu:$(TAG) quay.io/ds4sd/docling-serve-cpu:main
24
+
25
+ docling-serve-gpu-image: Containerfile ## Build docling-serve continaer image with GPU support
26
+ $(ECHO_PREFIX) printf " %-12s Containerfile\n" "[docling-serve with GPU]"
27
+ $(CMD_PREFIX) docker build --build-arg CPU_ONLY=false -f Containerfile --platform linux/amd64 -t ghcr.io/ds4sd/docling-serve:$(TAG) .
28
+ $(CMD_PREFIX) docker tag ghcr.io/ds4sd/docling-serve:$(TAG) ghcr.io/ds4sd/docling-serve:main
29
+ $(CMD_PREFIX) docker tag ghcr.io/ds4sd/docling-serve:$(TAG) quay.io/ds4sd/docling-serve:main
poetry.lock CHANGED
The diff for this file is too large to render. See raw diff
 
pyproject.toml CHANGED
@@ -15,7 +15,7 @@ maintainers = [
15
  "Christoph Auer <[email protected]>",
16
  "Michele Dolfi <[email protected]>",
17
  "Cesar Berrospi Ramis <[email protected]>",
18
- "Panos Vagenas <[email protected]>",
19
  ]
20
  readme = "README.md"
21
  repository = "https://github.com/DS4SD/docling-serve"
@@ -29,15 +29,39 @@ classifiers = [
29
  "Programming Language :: Python :: 3"
30
  ]
31
 
32
-
33
  [tool.poetry.dependencies]
34
  python = "^3.10"
35
- docling = "^1.9.0"
36
  fastapi = {version = "^0.110.2", extras = ["standard"]}
37
  uvicorn = "^0.30.6"
38
  pydantic-settings = "^2.4.0"
39
  httpx = "^0.27.2"
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
  [tool.poetry.group.dev.dependencies]
43
  black = "^24.8.0"
@@ -52,7 +76,6 @@ mypy = "^1.11.2"
52
  requires = ["poetry-core"]
53
  build-backend = "poetry.core.masonry.api"
54
 
55
-
56
  [tool.black]
57
  line-length = 88
58
  target-version = ["py310"]
 
15
  "Christoph Auer <[email protected]>",
16
  "Michele Dolfi <[email protected]>",
17
  "Cesar Berrospi Ramis <[email protected]>",
18
+ "Panos Vagenas <[email protected]>",
19
  ]
20
  readme = "README.md"
21
  repository = "https://github.com/DS4SD/docling-serve"
 
29
  "Programming Language :: Python :: 3"
30
  ]
31
 
 
32
  [tool.poetry.dependencies]
33
  python = "^3.10"
34
+ docling = "^1.11.0"
35
  fastapi = {version = "^0.110.2", extras = ["standard"]}
36
  uvicorn = "^0.30.6"
37
  pydantic-settings = "^2.4.0"
38
  httpx = "^0.27.2"
39
 
40
+ [tool.poetry.group.pypi-torch]
41
+ optional = false
42
+
43
+ [tool.poetry.group.pypi-torch.dependencies]
44
+ torch = [
45
+ {version = "!=2.4.1+cpu" },
46
+ ]
47
+ torchvision = [
48
+ {version = "!=0.19.1+cpu" },
49
+ ]
50
+
51
+ [tool.poetry.group.cpu]
52
+ optional = true
53
+
54
+ [tool.poetry.group.cpu.dependencies]
55
+ torch = [
56
+ {markers = 'platform_machine=="x86_64" and sys_platform=="linux" and python_version == "3.10"', url="https://download.pytorch.org/whl/cpu/torch-2.4.1%2Bcpu-cp310-cp310-linux_x86_64.whl"},
57
+ {markers = 'platform_machine=="x86_64" and sys_platform=="linux" and python_version == "3.11"', url="https://download.pytorch.org/whl/cpu/torch-2.4.1%2Bcpu-cp311-cp311-linux_x86_64.whl"},
58
+ {markers = 'platform_machine=="x86_64" and sys_platform=="linux" and python_version == "3.12"', url="https://download.pytorch.org/whl/cpu/torch-2.4.1%2Bcpu-cp312-cp312-linux_x86_64.whl"},
59
+ ]
60
+ torchvision = [
61
+ {markers = 'platform_machine=="x86_64" and sys_platform=="linux" and python_version == "3.10"', url="https://download.pytorch.org/whl/cpu/torchvision-0.19.1%2Bcpu-cp310-cp310-linux_x86_64.whl"},
62
+ {markers = 'platform_machine=="x86_64" and sys_platform=="linux" and python_version == "3.11"', url="https://download.pytorch.org/whl/cpu/torchvision-0.19.1%2Bcpu-cp311-cp311-linux_x86_64.whl"},
63
+ {markers = 'platform_machine=="x86_64" and sys_platform=="linux" and python_version == "3.12"', url="https://download.pytorch.org/whl/cpu/torchvision-0.19.1%2Bcpu-cp312-cp312-linux_x86_64.whl"},
64
+ ]
65
 
66
  [tool.poetry.group.dev.dependencies]
67
  black = "^24.8.0"
 
76
  requires = ["poetry-core"]
77
  build-backend = "poetry.core.masonry.api"
78
 
 
79
  [tool.black]
80
  line-length = 88
81
  target-version = ["py310"]