docker.yml 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. ---
  2. name: Docker
  3. on:
  4. push:
  5. branches:
  6. - master
  7. pull_request:
  8. paths: # This MUST be kept in-sync with the paths-ignore key for the docker-dummy.yml workflow.
  9. - '**.c'
  10. - '**.cc'
  11. - '**.h'
  12. - '**.hh'
  13. - '**.in'
  14. - '!netdata.spec.in'
  15. - '.dockerignore'
  16. - 'configure.ac'
  17. - 'netdata-installer.sh'
  18. - '**/Makefile*'
  19. - 'Makefile*'
  20. - '.github/workflows/docker.yml'
  21. - '.github/scripts/docker-test.sh'
  22. - 'build/**'
  23. - 'packaging/docker/**'
  24. - 'packaging/installer/**'
  25. - 'aclk/aclk-schemas/'
  26. - 'ml/dlib/'
  27. - 'mqtt_websockets'
  28. - 'web/server/h2o/libh2o'
  29. - '!**.md'
  30. workflow_dispatch:
  31. inputs:
  32. version:
  33. description: Version Tag
  34. default: nightly
  35. required: true
  36. env:
  37. DISABLE_TELEMETRY: 1
  38. concurrency:
  39. group: docker-${{ github.ref }}-${{ github.event_name }}
  40. cancel-in-progress: true
  41. jobs:
  42. docker-test:
  43. name: Docker Runtime Test
  44. runs-on: ubuntu-latest
  45. steps:
  46. - name: Checkout
  47. id: checkout
  48. uses: actions/checkout@v3
  49. with:
  50. submodules: recursive
  51. - name: Setup Buildx
  52. id: prepare
  53. uses: docker/setup-buildx-action@v2
  54. - name: Test Build
  55. id: build
  56. uses: docker/build-push-action@v4
  57. with:
  58. load: true
  59. push: false
  60. tags: netdata/netdata:test
  61. - name: Test Image
  62. id: test
  63. run: .github/scripts/docker-test.sh
  64. - name: Failure Notification
  65. uses: rtCamp/action-slack-notify@v2
  66. env:
  67. SLACK_COLOR: 'danger'
  68. SLACK_FOOTER: ''
  69. SLACK_ICON_EMOJI: ':github-actions:'
  70. SLACK_TITLE: 'Docker runtime testing failed:'
  71. SLACK_USERNAME: 'GitHub Actions'
  72. SLACK_MESSAGE: |-
  73. ${{ github.repository }}: Building or testing Docker image for linux/amd64 failed.
  74. CHeckout: ${{ steps.checkout.outcome }}
  75. Setup buildx: ${{ steps.prepare.outcome }}
  76. Build image: ${{ steps.build.outcome }}
  77. Test image: ${{ steps.test.outcome }}
  78. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  79. if: >-
  80. ${{
  81. failure()
  82. && github.event_name != 'pull_request'
  83. && startsWith(github.ref, 'refs/heads/master')
  84. && github.repository == 'netdata/netdata'
  85. }}
  86. docker-ci:
  87. if: github.event_name != 'workflow_dispatch'
  88. name: Docker Alt Arch Builds
  89. needs: docker-test
  90. runs-on: ubuntu-latest
  91. strategy:
  92. matrix:
  93. platforms:
  94. - linux/i386
  95. - linux/arm/v7
  96. - linux/arm64
  97. - linux/ppc64le
  98. steps:
  99. - name: Checkout
  100. id: checkout
  101. uses: actions/checkout@v3
  102. with:
  103. submodules: recursive
  104. - name: Setup QEMU
  105. id: qemu
  106. if: matrix.platforms != 'linux/i386'
  107. uses: docker/setup-qemu-action@v2
  108. - name: Setup Buildx
  109. id: buildx
  110. uses: docker/setup-buildx-action@v2
  111. - name: Build
  112. id: build
  113. uses: docker/build-push-action@v4
  114. with:
  115. platforms: ${{ matrix.platforms }}
  116. load: false
  117. push: false
  118. tags: netdata/netdata:test
  119. - name: Failure Notification
  120. uses: rtCamp/action-slack-notify@v2
  121. env:
  122. SLACK_COLOR: 'danger'
  123. SLACK_FOOTER: ''
  124. SLACK_ICON_EMOJI: ':github-actions:'
  125. SLACK_TITLE: 'Docker build testing failed:'
  126. SLACK_USERNAME: 'GitHub Actions'
  127. SLACK_MESSAGE: |-
  128. ${{ github.repository }}: Building Docker image for ${{ matrix.platforms }} failed.
  129. CHeckout: ${{ steps.checkout.outcome }}
  130. Setup QEMU: ${{ steps.qemu.outcome }}
  131. Setup buildx: ${{ steps.buildx.outcome }}
  132. Build image: ${{ steps.build.outcome }}
  133. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  134. if: >-
  135. ${{
  136. failure()
  137. && github.event_name != 'pull_request'
  138. && startsWith(github.ref, 'refs/heads/master')
  139. && github.repository == 'netdata/netdata'
  140. }}
  141. normalize-tag: # Fix the release tag if needed
  142. name: Normalize Release Tag
  143. runs-on: ubuntu-latest
  144. if: github.event_name == 'workflow_dispatch'
  145. outputs:
  146. tag: ${{ steps.tag.outputs.tag }}
  147. steps:
  148. - name: Normalize Tag
  149. id: tag
  150. run: |
  151. if echo ${{ github.event.inputs.version }} | grep -qE '^[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$'; then
  152. echo "tag=v${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  153. else
  154. echo "tag=${{ github.event.inputs.version }}" >> "${GITHUB_OUTPUT}"
  155. fi
  156. docker-publish:
  157. if: github.event_name == 'workflow_dispatch'
  158. name: Docker Build and Publish
  159. needs:
  160. - docker-test
  161. - normalize-tag
  162. runs-on: ubuntu-latest
  163. steps:
  164. - name: Checkout
  165. id: checkout
  166. uses: actions/checkout@v3
  167. with:
  168. submodules: recursive
  169. - name: Determine which tags to use
  170. id: release-tags
  171. if: github.event.inputs.version != 'nightly'
  172. run: |
  173. echo "tags=netdata/netdata:latest,netdata/netdata:stable,ghcr.io/netdata/netdata:latest,ghcr.io/netdata/netdata:stable,quay.io/netdata/netdata:latest,quay.io/netdata/netdata:stable,$(.github/scripts/gen-docker-tags.py ${{ needs.normalize-tag.outputs.tag }} '')" \
  174. >> "${GITHUB_ENV}"
  175. - name: Determine which tags to use
  176. id: nightly-tags
  177. if: github.event.inputs.version == 'nightly'
  178. run: |
  179. echo "tags=netdata/netdata:latest,netdata/netdata:edge,ghcr.io/netdata/netdata:latest,ghcr.io/netdata/netdata:edge,quay.io/netdata/netdata:latest,quay.io/netdata/netdata:edge" >> "${GITHUB_ENV}"
  180. - name: Mark image as official
  181. id: env
  182. if: github.repository == 'netdata/netdata'
  183. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  184. - name: Setup QEMU
  185. id: qemu
  186. uses: docker/setup-qemu-action@v2
  187. - name: Setup Buildx
  188. id: buildx
  189. uses: docker/setup-buildx-action@v2
  190. - name: Docker Hub Login
  191. id: docker-hub-login
  192. if: github.repository == 'netdata/netdata'
  193. uses: docker/login-action@v2
  194. with:
  195. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  196. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  197. - name: GitHub Container Registry Login
  198. id: ghcr-login
  199. if: github.repository == 'netdata/netdata'
  200. uses: docker/login-action@v2
  201. with:
  202. registry: ghcr.io
  203. username: ${{ github.repository_owner }}
  204. password: ${{ secrets.GITHUB_TOKEN }}
  205. - name: Quay.io Login
  206. id: quay-login
  207. if: github.repository == 'netdata/netdata'
  208. uses: docker/login-action@v2
  209. with:
  210. registry: quay.io
  211. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  212. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  213. - name: Docker Build
  214. id: build
  215. uses: docker/build-push-action@v4
  216. with:
  217. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
  218. push: ${{ github.repository == 'netdata/netdata' }}
  219. tags: ${{ env.tags }}
  220. build-args: OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  221. - name: Failure Notification
  222. uses: rtCamp/action-slack-notify@v2
  223. env:
  224. SLACK_COLOR: 'danger'
  225. SLACK_FOOTER: ''
  226. SLACK_ICON_EMOJI: ':github-actions:'
  227. SLACK_TITLE: 'Docker Build failed:'
  228. SLACK_USERNAME: 'GitHub Actions'
  229. SLACK_MESSAGE: |-
  230. ${{ github.repository }}: Failed to build or publish Docker images.
  231. CHeckout: ${{ steps.checkout.outcome }}
  232. Generate release tags: ${{ steps.release-tags.outcome }}
  233. Generate nightly tags: ${{ steps.nightly-tags.outcome }}
  234. Setup environment: ${{ steps.env.outcome }}
  235. Setup QEMU: ${{ steps.qemu.outcome }}
  236. Setup buildx: ${{ steps.buildx.outcome }}
  237. Login to DockerHub: ${{ steps.docker-hub-login.outcome }}
  238. Login to GHCR: ${{ steps.ghcr-login.outcome }}
  239. Login to Quay: ${{ steps.quay-login.outcome }}
  240. Build and publish images: ${{ steps.build.outcome }}
  241. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  242. if: >-
  243. ${{
  244. failure()
  245. && github.event_name != 'pull_request'
  246. && startsWith(github.ref, 'refs/heads/master')
  247. && github.repository == 'netdata/netdata'
  248. }}
  249. - name: Trigger Helmchart PR
  250. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  251. uses: benc-uk/workflow-dispatch@v1
  252. with:
  253. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  254. repo: netdata/helmchart
  255. workflow: Agent Version PR
  256. ref: refs/heads/master
  257. inputs: '{"agent_version": "${{ needs.normalize-tag.outputs.tag }}"}'
  258. - name: Trigger MSI build
  259. if: github.event_name == 'workflow_dispatch' && github.event.inputs.version != 'nightly' && github.repository == 'netdata/netdata'
  260. uses: benc-uk/workflow-dispatch@v1
  261. with:
  262. token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
  263. repo: netdata/msi-installer
  264. workflow: Build
  265. ref: refs/heads/master
  266. inputs: '{"tag": "${{ needs.normalize-tag.outputs.tag }}", "pwd": "${{ secrets.MSI_CODE_SIGNING_PASSWORD }}"}'
  267. docker-dbg-publish:
  268. if: github.event_name == 'workflow_dispatch'
  269. name: Docker Build and Publish (Debugging Image)
  270. needs:
  271. - docker-test
  272. - normalize-tag
  273. runs-on: ubuntu-latest
  274. steps:
  275. - name: Checkout
  276. id: checkout
  277. uses: actions/checkout@v3
  278. with:
  279. submodules: recursive
  280. - name: Determine which tags to use
  281. id: release-tags
  282. if: github.event.inputs.version != 'nightly'
  283. run: |
  284. echo "tags=netdata/netdata-debug:latest,netdata/netdata-debug:stable,ghcr.io/netdata/netdata-debug:latest,ghcr.io/netdata/netdata-debug:stable,quay.io/netdata/netdata-debug:latest,quay.io/netdata/netdata-debug:stable,$(.github/scripts/gen-docker-tags.py ${{ needs.normalize-tag.outputs.tag }} '-debug')" \
  285. >> "${GITHUB_ENV}"
  286. - name: Determine which tags to use
  287. id: nightly-tags
  288. if: github.event.inputs.version == 'nightly'
  289. run: |
  290. echo "tags=netdata/netdata-debug:latest,netdata/netdata-debug:edge,ghcr.io/netdata/netdata-debug:latest,ghcr.io/netdata/netdata-debug:edge,quay.io/netdata/netdata-debug:latest,quay.io/netdata/netdata-debug:edge" >> "${GITHUB_ENV}"
  291. - name: Mark image as official
  292. id: env
  293. if: github.repository == 'netdata/netdata'
  294. run: echo "OFFICIAL_IMAGE=true" >> "${GITHUB_ENV}"
  295. - name: Setup QEMU
  296. id: qemu
  297. uses: docker/setup-qemu-action@v2
  298. - name: Setup Buildx
  299. id: buildx
  300. uses: docker/setup-buildx-action@v2
  301. - name: Docker Hub Login
  302. id: docker-hub-login
  303. if: github.repository == 'netdata/netdata'
  304. uses: docker/login-action@v2
  305. with:
  306. username: ${{ secrets.DOCKER_HUB_USERNAME }}
  307. password: ${{ secrets.DOCKER_HUB_PASSWORD }}
  308. - name: GitHub Container Registry Login
  309. id: ghcr-login
  310. if: github.repository == 'netdata/netdata'
  311. uses: docker/login-action@v2
  312. with:
  313. registry: ghcr.io
  314. username: ${{ github.repository_owner }}
  315. password: ${{ secrets.GITHUB_TOKEN }}
  316. - name: Quay.io Login
  317. id: quay-login
  318. if: github.repository == 'netdata/netdata'
  319. uses: docker/login-action@v2
  320. with:
  321. registry: quay.io
  322. username: ${{ secrets.NETDATABOT_QUAY_USERNAME }}
  323. password: ${{ secrets.NETDATABOT_QUAY_TOKEN }}
  324. - name: Docker Build
  325. id: build
  326. uses: docker/build-push-action@v4
  327. with:
  328. platforms: linux/amd64,linux/i386,linux/arm/v7,linux/arm64,linux/ppc64le
  329. push: ${{ github.repository == 'netdata/netdata' }}
  330. tags: ${{ env.tags }}
  331. build-args: |
  332. OFFICIAL_IMAGE=${{ env.OFFICIAL_IMAGE }}
  333. DEBUG_BUILD=1
  334. - name: Failure Notification
  335. uses: rtCamp/action-slack-notify@v2
  336. env:
  337. SLACK_COLOR: 'danger'
  338. SLACK_FOOTER: ''
  339. SLACK_ICON_EMOJI: ':github-actions:'
  340. SLACK_TITLE: 'Docker Debug Build failed:'
  341. SLACK_USERNAME: 'GitHub Actions'
  342. SLACK_MESSAGE: |-
  343. ${{ github.repository }}: Failed to build or publish Docker debug images.
  344. Checkout: ${{ steps.checkout.outcome }}
  345. Generate release tags: ${{ steps.release-tags.outcome }}
  346. Generate nightly tags: ${{ steps.nightly-tags.outcome }}
  347. Setup environment: ${{ steps.env.outcome }}
  348. Setup QEMU: ${{ steps.qemu.outcome }}
  349. Setup buildx: ${{ steps.buildx.outcome }}
  350. Login to DockerHub: ${{ steps.docker-hub-login.outcome }}
  351. Login to GHCR: ${{ steps.ghcr-login.outcome }}
  352. Login to Quay: ${{ steps.quay-login.outcome }}
  353. Build and publish images: ${{ steps.build.outcome }}
  354. SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
  355. if: >-
  356. ${{
  357. failure()
  358. && github.event_name != 'pull_request'
  359. && startsWith(github.ref, 'refs/heads/master')
  360. && github.repository == 'netdata/netdata'
  361. }}