Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

docker.yaml 7.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  1. # Ultralytics YOLO 🚀, AGPL-3.0 license
  2. # Builds ultralytics/ultralytics:latest images on DockerHub https://hub.docker.com/r/ultralytics
  3. name: Publish Docker Images
  4. on:
  5. push:
  6. branches: [main]
  7. paths-ignore:
  8. - "docs/**"
  9. - "mkdocs.yml"
  10. workflow_dispatch:
  11. inputs:
  12. Dockerfile:
  13. type: boolean
  14. description: Use Dockerfile
  15. default: true
  16. Dockerfile-cpu:
  17. type: boolean
  18. description: Use Dockerfile-cpu
  19. default: true
  20. Dockerfile-arm64:
  21. type: boolean
  22. description: Use Dockerfile-arm64
  23. default: true
  24. Dockerfile-jetson-jetpack6:
  25. type: boolean
  26. description: Use Dockerfile-jetson-jetpack6
  27. default: true
  28. Dockerfile-jetson-jetpack5:
  29. type: boolean
  30. description: Use Dockerfile-jetson-jetpack5
  31. default: true
  32. Dockerfile-jetson-jetpack4:
  33. type: boolean
  34. description: Use Dockerfile-jetson-jetpack4
  35. default: true
  36. Dockerfile-python:
  37. type: boolean
  38. description: Use Dockerfile-python
  39. default: true
  40. Dockerfile-conda:
  41. type: boolean
  42. description: Use Dockerfile-conda
  43. default: true
  44. push:
  45. type: boolean
  46. description: Publish all Images to Docker Hub
  47. jobs:
  48. docker:
  49. if: github.repository == 'ultralytics/ultralytics'
  50. name: Push
  51. runs-on: ubuntu-latest
  52. strategy:
  53. fail-fast: false
  54. max-parallel: 10
  55. matrix:
  56. include:
  57. - dockerfile: "Dockerfile"
  58. tags: "latest"
  59. platforms: "linux/amd64"
  60. - dockerfile: "Dockerfile-cpu"
  61. tags: "latest-cpu"
  62. platforms: "linux/amd64"
  63. - dockerfile: "Dockerfile-arm64"
  64. tags: "latest-arm64"
  65. platforms: "linux/arm64"
  66. - dockerfile: "Dockerfile-jetson-jetpack6"
  67. tags: "latest-jetson-jetpack6"
  68. platforms: "linux/arm64"
  69. - dockerfile: "Dockerfile-jetson-jetpack5"
  70. tags: "latest-jetson-jetpack5"
  71. platforms: "linux/arm64"
  72. - dockerfile: "Dockerfile-jetson-jetpack4"
  73. tags: "latest-jetson-jetpack4"
  74. platforms: "linux/arm64"
  75. - dockerfile: "Dockerfile-python"
  76. tags: "latest-python"
  77. platforms: "linux/amd64"
  78. # - dockerfile: "Dockerfile-conda"
  79. # tags: "latest-conda"
  80. # platforms: "linux/amd64"
  81. steps:
  82. - name: Cleanup disk
  83. # Free up to 30GB of disk space per https://github.com/ultralytics/ultralytics/pull/15848
  84. uses: jlumbroso/free-disk-space@v1.3.1
  85. with:
  86. tool-cache: true
  87. - name: Checkout repo
  88. uses: actions/checkout@v4
  89. with:
  90. fetch-depth: 0 # copy full .git directory to access full git history in Docker images
  91. - name: Set up QEMU
  92. uses: docker/setup-qemu-action@v3
  93. - name: Set up Docker Buildx
  94. uses: docker/setup-buildx-action@v3
  95. - name: Login to Docker Hub
  96. uses: docker/login-action@v3
  97. with:
  98. username: ${{ secrets.DOCKERHUB_USERNAME }}
  99. password: ${{ secrets.DOCKERHUB_TOKEN }}
  100. - name: Retrieve Ultralytics version
  101. id: get_version
  102. run: |
  103. VERSION=$(grep "^__version__ =" ultralytics/__init__.py | awk -F'"' '{print $2}')
  104. echo "Retrieved Ultralytics version: $VERSION"
  105. echo "version=$VERSION" >> $GITHUB_OUTPUT
  106. VERSION_TAG=$(echo "${{ matrix.tags }}" | sed "s/latest/${VERSION}/")
  107. echo "Intended version tag: $VERSION_TAG"
  108. echo "version_tag=$VERSION_TAG" >> $GITHUB_OUTPUT
  109. - name: Check if version tag exists on DockerHub
  110. id: check_tag
  111. run: |
  112. RESPONSE=$(curl -s https://hub.docker.com/v2/repositories/ultralytics/ultralytics/tags/$VERSION_TAG)
  113. MESSAGE=$(echo $RESPONSE | jq -r '.message')
  114. if [[ "$MESSAGE" == "null" ]]; then
  115. echo "Tag $VERSION_TAG already exists on DockerHub."
  116. echo "exists=true" >> $GITHUB_OUTPUT
  117. elif [[ "$MESSAGE" == *"404"* ]]; then
  118. echo "Tag $VERSION_TAG does not exist on DockerHub."
  119. echo "exists=false" >> $GITHUB_OUTPUT
  120. else
  121. echo "Unexpected response from DockerHub. Please check manually."
  122. echo "exists=false" >> $GITHUB_OUTPUT
  123. fi
  124. env:
  125. VERSION_TAG: ${{ steps.get_version.outputs.version_tag }}
  126. - name: Build Image
  127. if: github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true'
  128. uses: nick-invision/retry@v3
  129. with:
  130. timeout_minutes: 120
  131. retry_wait_seconds: 60
  132. max_attempts: 3 # retry twice
  133. command: |
  134. docker build \
  135. --platform ${{ matrix.platforms }} \
  136. -f docker/${{ matrix.dockerfile }} \
  137. -t ultralytics/ultralytics:${{ matrix.tags }} \
  138. -t ultralytics/ultralytics:${{ steps.get_version.outputs.version_tag }} \
  139. .
  140. - name: Run Tests
  141. if: (github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true') && matrix.platforms == 'linux/amd64' && matrix.dockerfile != 'Dockerfile-conda' # arm64 images not supported on GitHub CI runners
  142. run: docker run ultralytics/ultralytics:${{ matrix.tags }} /bin/bash -c "pip install pytest && pytest tests"
  143. - name: Run Benchmarks
  144. # WARNING: Dockerfile (GPU) error on TF.js export 'module 'numpy' has no attribute 'object'.
  145. if: (github.event_name == 'push' || github.event.inputs[matrix.dockerfile] == 'true') && matrix.platforms == 'linux/amd64' && matrix.dockerfile != 'Dockerfile' && matrix.dockerfile != 'Dockerfile-conda' # arm64 images not supported on GitHub CI runners
  146. run: docker run ultralytics/ultralytics:${{ matrix.tags }} yolo benchmark model=yolo11n.pt imgsz=160 verbose=0.309
  147. - name: Push Docker Image with Ultralytics version tag
  148. if: (github.event_name == 'push' || (github.event.inputs[matrix.dockerfile] == 'true' && github.event.inputs.push == 'true')) && steps.check_tag.outputs.exists == 'false' && matrix.dockerfile != 'Dockerfile-conda'
  149. run: |
  150. docker push ultralytics/ultralytics:${{ steps.get_version.outputs.version_tag }}
  151. - name: Push Docker Image with latest tag
  152. if: github.event_name == 'push' || (github.event.inputs[matrix.dockerfile] == 'true' && github.event.inputs.push == 'true')
  153. run: |
  154. docker push ultralytics/ultralytics:${{ matrix.tags }}
  155. if [[ "${{ matrix.tags }}" == "latest" ]]; then
  156. t=ultralytics/ultralytics:latest-runner
  157. docker build -f docker/Dockerfile-runner -t $t .
  158. docker push $t
  159. fi
  160. notify:
  161. runs-on: ubuntu-latest
  162. needs: docker
  163. if: always() # This ensures the job always runs
  164. steps:
  165. - name: Check for failure and notify
  166. if: needs.docker.result == 'failure' && github.repository == 'ultralytics/ultralytics' && github.event_name == 'push'
  167. uses: slackapi/slack-github-action@v1.27.0
  168. with:
  169. payload: |
  170. {"text": "<!channel> GitHub Actions error for ${{ github.workflow }} ❌\n\n\n*Repository:* https://github.com/${{ github.repository }}\n*Action:* https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\n*Author:* ${{ github.actor }}\n*Event:* ${{ github.event_name }}\n"}
  171. env:
  172. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_YOLO }}
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...