build-publish.yml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. name: Build and publish Docker images
  2. on:
  3. workflow_dispatch:
  4. schedule:
  5. - cron: "0 0 * * 1"
  6. push:
  7. branches:
  8. - main
  9. tags:
  10. - "*.*.*"
  11. paths-ignore:
  12. - "test/*"
  13. - ".gitignore"
  14. - "docker-compose-separate-containers.yml"
  15. - "docker-compose.yml"
  16. - "LICENSE"
  17. - "Makefile"
  18. - "*.md"
  19. jobs:
  20. multiarch-build-debian:
  21. name: Build and publish Debian image
  22. runs-on: ubuntu-latest
  23. steps:
  24. - name: Checkout
  25. uses: actions/checkout@v3
  26. with:
  27. fetch-depth: 0
  28. - name: Retrieve nginx-proxy version
  29. id: nginx-proxy_version
  30. run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"
  31. - name: Get Docker tags for Debian based image
  32. id: docker_meta_debian
  33. uses: docker/metadata-action@v4
  34. with:
  35. images: |
  36. ghcr.io/nginx-proxy/nginx-proxy
  37. nginxproxy/nginx-proxy
  38. jwilder/nginx-proxy
  39. tags: |
  40. type=semver,pattern={{version}}
  41. type=semver,pattern={{major}}.{{minor}}
  42. type=raw,value=latest,enable={{is_default_branch}}
  43. labels: |
  44. org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
  45. org.opencontainers.image.version=${{ steps.nginx-proxy_version.outputs.VERSION }}
  46. - name: Set up QEMU
  47. uses: docker/setup-qemu-action@v2
  48. - name: Set up Docker Buildx
  49. uses: docker/setup-buildx-action@v2
  50. - name: Login to DockerHub
  51. uses: docker/login-action@v2
  52. with:
  53. username: ${{ secrets.DOCKERHUB_USERNAME }}
  54. password: ${{ secrets.DOCKERHUB_TOKEN }}
  55. - name: Log in to GitHub Container Registry
  56. uses: docker/login-action@v2
  57. with:
  58. registry: ghcr.io
  59. username: ${{ github.actor }}
  60. password: ${{ secrets.GITHUB_TOKEN }}
  61. - name: Retrieve docker-gen version
  62. id: docker-gen_version
  63. run: sed -n -e 's;^FROM nginxproxy/docker-gen:\([0-9.]*\).*;VERSION=\1;p' Dockerfile >> "$GITHUB_OUTPUT"
  64. - name: Build and push the Debian based image
  65. id: docker_build_debian
  66. uses: docker/build-push-action@v4
  67. with:
  68. context: .
  69. file: Dockerfile
  70. build-args: |
  71. NGINX_PROXY_VERSION=${{ steps.nginx-proxy_version.outputs.VERSION }}
  72. DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }}
  73. platforms: linux/amd64,linux/arm64,linux/arm/v7
  74. push: true
  75. tags: ${{ steps.docker_meta_debian.outputs.tags }}
  76. labels: ${{ steps.docker_meta_debian.outputs.labels }}
  77. - name: Images digests
  78. run: echo ${{ steps.docker_build_debian.outputs.digest }}
  79. multiarch-build-alpine:
  80. name: Build and publish Alpine image
  81. runs-on: ubuntu-latest
  82. steps:
  83. - name: Checkout
  84. uses: actions/checkout@v3
  85. with:
  86. fetch-depth: 0
  87. - name: Retrieve nginx-proxy version
  88. id: nginx-proxy_version
  89. run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"
  90. - name: Get Docker tags for Alpine based image
  91. id: docker_meta_alpine
  92. uses: docker/metadata-action@v4
  93. with:
  94. images: |
  95. ghcr.io/nginx-proxy/nginx-proxy
  96. nginxproxy/nginx-proxy
  97. jwilder/nginx-proxy
  98. tags: |
  99. type=semver,suffix=-alpine,pattern={{version}}
  100. type=semver,suffix=-alpine,pattern={{major}}.{{minor}}
  101. type=raw,value=alpine,enable={{is_default_branch}}
  102. labels: |
  103. org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
  104. org.opencontainers.image.version=${{ steps.nginx-proxy_version.outputs.VERSION }}
  105. flavor: latest=false
  106. - name: Set up QEMU
  107. uses: docker/setup-qemu-action@v2
  108. - name: Set up Docker Buildx
  109. uses: docker/setup-buildx-action@v2
  110. - name: Login to DockerHub
  111. uses: docker/login-action@v2
  112. with:
  113. username: ${{ secrets.DOCKERHUB_USERNAME }}
  114. password: ${{ secrets.DOCKERHUB_TOKEN }}
  115. - name: Log in to GitHub Container Registry
  116. uses: docker/login-action@v2
  117. with:
  118. registry: ghcr.io
  119. username: ${{ github.actor }}
  120. password: ${{ secrets.GITHUB_TOKEN }}
  121. - name: Retrieve docker-gen version
  122. id: docker-gen_version
  123. run: sed -n -e 's;^FROM nginxproxy/docker-gen:\([0-9.]*\).*;VERSION=\1;p' Dockerfile >> "$GITHUB_OUTPUT"
  124. - name: Build and push the Alpine based image
  125. id: docker_build_alpine
  126. uses: docker/build-push-action@v4
  127. with:
  128. context: .
  129. file: Dockerfile.alpine
  130. build-args: |
  131. NGINX_PROXY_VERSION=${{ steps.nginx-proxy_version.outputs.VERSION }}
  132. DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }}
  133. platforms: linux/amd64,linux/arm64,linux/arm/v7
  134. push: true
  135. tags: ${{ steps.docker_meta_alpine.outputs.tags }}
  136. labels: ${{ steps.docker_meta_alpine.outputs.labels }}
  137. - name: Images digests
  138. run: echo ${{ steps.docker_build_alpine.outputs.digest }}