vishnoianil commited on
Commit
39f6b87
·
unverified ·
1 Parent(s): b50fb0e

Enable concurrent running of the image generation jobs (#4)

Browse files

Group GPU image generate for GHCR and QUAY in one job,
and similarly group CPU only image generation for GHCR
and QUAY in another job. These two jobs can now run
concurrently.

By grouping the jobs for the same image type, it can
use the docker layer cache to run the second job faster.
If we separately build these images in four diffent and
concurrent jobs, they won't be able to use the cache.

If this still takes significantly long, we probably
have to generate image in it's own job, so that they can run
concurrently, without leveraging cache of docker layers.

Also added make file target to lint the github workflows.

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

Files changed (3) hide show
  1. .github/workflows/images.yml +81 -38
  2. .gitignore +3 -0
  3. Makefile +25 -1
.github/workflows/images.yml CHANGED
@@ -13,9 +13,13 @@ env:
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:
@@ -53,31 +57,13 @@ jobs:
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:
@@ -99,7 +85,73 @@ jobs:
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:
@@ -121,22 +173,13 @@ jobs:
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:
@@ -149,4 +192,4 @@ jobs:
149
  cache-to: type=gha,mode=max
150
  file: Containerfile
151
  build-args: |
152
- --build-arg CPU_ONLY=false
 
13
  QUAY_DOCLING_SERVE_CPU_IMAGE_NAME: ds4sd/docling-serve-cpu
14
  QUAY_DOCLING_SERVE_GPU_IMAGE_NAME: ds4sd/docling-serve
15
 
16
+ concurrency:
17
+ group: ${{ github.workflow }}-${{ github.ref }}
18
+ cancel-in-progress: true
19
+
20
  jobs:
21
+ build_and_publish_cpu_images:
22
+ name: Push docling-serve "CPU only" container image to GHCR and QUAY
23
  runs-on: ubuntu-latest
24
  environment: registry-creds
25
  permissions:
 
57
  restore-keys: |
58
  ${{ runner.os }}-buildx-
59
 
60
+ - name: Extract metadata (tags, labels) for docling-serve (CPU only) ghcr image
61
  id: ghcr_serve_cpu_meta
62
  uses: docker/metadata-action@v5
63
  with:
64
  images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_CPU_IMAGE_NAME }}
65
 
66
+ - name: Build and push docling-serve-cpu image to ghcr.io
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  id: push-serve-cpu-ghcr
68
  uses: docker/build-push-action@v5
69
  with:
 
85
  subject-digest: ${{ steps.push-serve-cpu-ghcr.outputs.digest }}
86
  push-to-registry: true
87
 
88
+ - name: Extract metadata (tags, labels) for docling-serve (CPU only) quay image
89
+ id: quay_serve_cpu_meta
90
+ uses: docker/metadata-action@v5
91
+ with:
92
+ images: ${{ env.QUAY_REGISTRY }}/${{ env.QUAY_DOCLING_SERVE_CPU_IMAGE_NAME }}
93
+
94
+ - name: Build and push docling-serve-cpu image to quay.io
95
+ id: push-serve-cpu-quay
96
+ uses: docker/build-push-action@v5
97
+ with:
98
+ context: .
99
+ push: true
100
+ tags: ${{ steps.quay_serve_cpu_meta.outputs.tags }}
101
+ labels: ${{ steps.quay_serve_cpu_meta.outputs.labels }}
102
+ platforms: linux/amd64
103
+ cache-from: type=gha
104
+ cache-to: type=gha,mode=max
105
+ file: Containerfile
106
+ build-args: |
107
+ --build-arg CPU_ONLY=true
108
+
109
+ build_and_publish_gpu_images:
110
+ name: Push docling-serve (with GPU support) container image to GHCR and QUAY
111
+ runs-on: ubuntu-latest
112
+ environment: registry-creds
113
+ permissions:
114
+ packages: write
115
+ contents: read
116
+ attestations: write
117
+ id-token: write
118
+
119
+ steps:
120
+ - name: Check out the repo
121
+ uses: actions/checkout@v4
122
+
123
+ - name: Log in to the GHCR container image registry
124
+ uses: docker/login-action@v3
125
+ with:
126
+ registry: ${{ env.GHCR_REGISTRY }}
127
+ username: ${{ github.actor }}
128
+ password: ${{ secrets.GITHUB_TOKEN }}
129
+
130
+ - name: Log in to the Quay container image registry
131
+ uses: docker/login-action@v3
132
+ with:
133
+ registry: ${{ env.QUAY_REGISTRY }}
134
+ username: ${{ secrets.QUAY_USERNAME }}
135
+ password: ${{ secrets.QUAY_TOKEN }}
136
+
137
+ - name: Set up Docker Buildx
138
+ uses: docker/setup-buildx-action@v3
139
+
140
+ - name: Cache Docker layers
141
+ uses: actions/cache@v4
142
+ with:
143
+ path: /tmp/.buildx-cache
144
+ key: ${{ runner.os }}-buildx-${{ github.sha }}
145
+ restore-keys: |
146
+ ${{ runner.os }}-buildx-
147
+
148
+ - name: Extract metadata (tags, labels) for docling-serve (GPU) ghcr image
149
+ id: ghcr_serve_gpu_meta
150
+ uses: docker/metadata-action@v5
151
+ with:
152
+ images: ${{ env.GHCR_REGISTRY }}/${{ env.GHCR_DOCLING_SERVE_GPU_IMAGE_NAME }}
153
+
154
+ - name: Build and push docling-serve (GPU) image to ghcr.io
155
  id: push-serve-gpu-ghcr
156
  uses: docker/build-push-action@v5
157
  with:
 
173
  subject-digest: ${{ steps.push-serve-gpu-ghcr.outputs.digest }}
174
  push-to-registry: true
175
 
176
+ - name: Extract metadata (tags, labels) for docling-serve (GPU) quay image
177
+ id: quay_serve_gpu_meta
178
+ uses: docker/metadata-action@v5
179
  with:
180
+ images: ${{ env.QUAY_REGISTRY }}/${{ env.QUAY_DOCLING_SERVE_GPU_IMAGE_NAME }}
 
 
 
 
 
 
 
 
 
181
 
182
+ - name: Build and push docling-serve (GPU) image to quay.io
183
  id: push-serve-gpu-quay
184
  uses: docker/build-push-action@v5
185
  with:
 
192
  cache-to: type=gha,mode=max
193
  file: Containerfile
194
  build-args: |
195
+ --build-arg CPU_ONLY=false
.gitignore CHANGED
@@ -438,3 +438,6 @@ pip-selfcheck.json
438
  # Docs
439
  # docs/**/*.png
440
  # docs/**/*.svg
 
 
 
 
438
  # Docs
439
  # docs/**/*.png
440
  # docs/**/*.svg
441
+
442
+ # Makefile
443
+ .action-lint
Makefile CHANGED
@@ -9,21 +9,45 @@ help:
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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  ifeq ($(NOISY_BUILD),)
10
  ECHO_PREFIX=@
11
  CMD_PREFIX=@
12
+ PIPE_DEV_NULL=> /dev/null 2> /dev/null
13
  else
14
  ECHO_PREFIX=@\#
15
+ CMD_PREFIX=
16
+ PIPE_DEV_NULL=
17
  endif
18
 
19
  TAG=$(shell git rev-parse HEAD)
20
 
21
+ lint:
22
+ $(CMD_PREFIX) touch .action-lint
23
+
24
+ .PHONY: docling-serve-cpu-image
25
  docling-serve-cpu-image: Containerfile ## Build docling-serve "cpu only" continaer image
26
  $(ECHO_PREFIX) printf " %-12s Containerfile\n" "[docling-serve CPU ONLY]"
27
  $(CMD_PREFIX) docker build --build-arg CPU_ONLY=true -f Containerfile --platform linux/amd64 -t ghcr.io/ds4sd/docling-serve-cpu:$(TAG) .
28
  $(CMD_PREFIX) docker tag ghcr.io/ds4sd/docling-serve-cpu:$(TAG) ghcr.io/ds4sd/docling-serve-cpu:main
29
  $(CMD_PREFIX) docker tag ghcr.io/ds4sd/docling-serve-cpu:$(TAG) quay.io/ds4sd/docling-serve-cpu:main
30
 
31
+ .PHONY: docling-serve-gpu-image
32
  docling-serve-gpu-image: Containerfile ## Build docling-serve continaer image with GPU support
33
  $(ECHO_PREFIX) printf " %-12s Containerfile\n" "[docling-serve with GPU]"
34
  $(CMD_PREFIX) docker build --build-arg CPU_ONLY=false -f Containerfile --platform linux/amd64 -t ghcr.io/ds4sd/docling-serve:$(TAG) .
35
  $(CMD_PREFIX) docker tag ghcr.io/ds4sd/docling-serve:$(TAG) ghcr.io/ds4sd/docling-serve:main
36
  $(CMD_PREFIX) docker tag ghcr.io/ds4sd/docling-serve:$(TAG) quay.io/ds4sd/docling-serve:main
37
+
38
+ .PHONY: action-lint
39
+ action-lint: .action-lint ## Lint GitHub Action workflows
40
+ .action-lint: $(shell find .github -type f) | lint
41
+ $(ECHO_PREFIX) printf " %-12s .github/...\n" "[ACTION LINT]"
42
+ $(CMD_PREFIX) if ! which actionlint $(PIPE_DEV_NULL) ; then \
43
+ echo "Please install actionlint." ; \
44
+ echo "go install github.com/rhysd/actionlint/cmd/actionlint@latest" ; \
45
+ exit 1 ; \
46
+ fi
47
+ $(CMD_PREFIX) if ! which shellcheck $(PIPE_DEV_NULL) ; then \
48
+ echo "Please install shellcheck." ; \
49
+ echo "https://github.com/koalaman/shellcheck#user-content-installing" ; \
50
+ exit 1 ; \
51
+ fi
52
+ $(CMD_PREFIX) actionlint -color
53
+ $(CMD_PREFIX) touch $@