build-publish.yml 3.2 KB

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