build-publish.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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:
  21. name: Build and publish image
  22. strategy:
  23. matrix:
  24. base: [alpine, debian]
  25. runs-on: ubuntu-latest
  26. if: (github.event_name == 'schedule' && github.repository == 'nginx-proxy/nginx-proxy') || (github.event_name != 'schedule')
  27. steps:
  28. - name: Checkout
  29. uses: actions/checkout@v4
  30. with:
  31. fetch-depth: 0
  32. - name: Retrieve nginx-proxy version
  33. id: nginx-proxy_version
  34. run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"
  35. - name: Retrieve docker-gen version
  36. id: docker-gen_version
  37. run: sed -n -e 's;^FROM docker.io/nginxproxy/docker-gen:\([0-9.]*\).*;VERSION=\1;p' Dockerfile.${{ matrix.base }} >> "$GITHUB_OUTPUT"
  38. - name: Get Docker tags
  39. id: docker_meta
  40. uses: docker/metadata-action@v5
  41. with:
  42. images: |
  43. ghcr.io/nginx-proxy/nginx-proxy
  44. nginxproxy/nginx-proxy
  45. jwilder/nginx-proxy
  46. tags: |
  47. type=semver,pattern={{version}},enable=${{ matrix.base == 'debian' }}
  48. type=semver,pattern={{major}}.{{minor}},enable=${{ matrix.base == 'debian' }}
  49. type=semver,suffix=-alpine,pattern={{version}},enable=${{ matrix.base == 'alpine' }}
  50. type=semver,suffix=-alpine,pattern={{major}}.{{minor}},enable=${{ matrix.base == 'alpine' }}
  51. type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && matrix.base == 'debian' }}
  52. type=raw,value=alpine,enable=${{ github.ref == 'refs/heads/main' && matrix.base == 'alpine' }}
  53. labels: |
  54. org.opencontainers.image.authors=Nicolas Duchon <nicolas.duchon@gmail.com> (@buchdag), Jason Wilder
  55. org.opencontainers.image.version=${{ steps.nginx-proxy_version.outputs.VERSION }}
  56. flavor: |
  57. latest=false
  58. - name: Set up QEMU
  59. uses: docker/setup-qemu-action@v3
  60. - name: Set up Docker Buildx
  61. uses: docker/setup-buildx-action@v3
  62. - name: Login to DockerHub
  63. uses: docker/login-action@v3
  64. with:
  65. username: ${{ secrets.DOCKERHUB_USERNAME }}
  66. password: ${{ secrets.DOCKERHUB_TOKEN }}
  67. - name: Log in to GitHub Container Registry
  68. uses: docker/login-action@v3
  69. with:
  70. registry: ghcr.io
  71. username: ${{ github.actor }}
  72. password: ${{ secrets.GITHUB_TOKEN }}
  73. - name: Build and push the image
  74. id: docker_build
  75. uses: docker/build-push-action@v6
  76. with:
  77. context: .
  78. file: Dockerfile.${{ matrix.base }}
  79. build-args: |
  80. NGINX_PROXY_VERSION=${{ steps.nginx-proxy_version.outputs.VERSION }}
  81. DOCKER_GEN_VERSION=${{ steps.docker-gen_version.outputs.VERSION }}
  82. platforms: linux/amd64,linux/arm64,linux/s390x,linux/arm/v7
  83. sbom: true
  84. push: true
  85. provenance: mode=max
  86. tags: ${{ steps.docker_meta.outputs.tags }}
  87. labels: ${{ steps.docker_meta.outputs.labels }}
  88. cache-from: type=gha
  89. cache-to: type=gha,mode=max
  90. - name: Images digests
  91. run: echo ${{ steps.docker_build.outputs.digest }}