docker-publish.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. name: Docker
  2. on:
  3. push:
  4. branches: [ "main" ]
  5. paths:
  6. - 'Dockerfile'
  7. - 'frontend/Dockerfile'
  8. - 'frontend/**'
  9. - 'requirements.txt'
  10. - 'VERSION'
  11. - '**.py'
  12. pull_request:
  13. branches: [ "main" ]
  14. paths:
  15. - 'Dockerfile'
  16. - 'frontend/Dockerfile'
  17. - 'frontend/**'
  18. - 'requirements.txt'
  19. - 'VERSION'
  20. - '**.py'
  21. # Allow manual trigger on any branch
  22. workflow_dispatch:
  23. inputs:
  24. branch:
  25. description: 'Branch to build from'
  26. required: false
  27. default: ''
  28. env:
  29. REGISTRY: ghcr.io
  30. jobs:
  31. build-backend:
  32. runs-on: ubuntu-latest
  33. permissions:
  34. contents: read
  35. packages: write
  36. id-token: write
  37. steps:
  38. - name: Checkout repository
  39. uses: actions/checkout@v4
  40. - name: Set up Docker Buildx
  41. uses: docker/setup-buildx-action@v3
  42. - name: Log into registry ${{ env.REGISTRY }}
  43. uses: docker/login-action@v3
  44. with:
  45. registry: ${{ env.REGISTRY }}
  46. username: ${{ github.actor }}
  47. password: ${{ secrets.GITHUB_TOKEN }}
  48. - name: Extract Docker metadata
  49. id: meta
  50. uses: docker/metadata-action@v5
  51. with:
  52. images: ${{ env.REGISTRY }}/${{ github.repository }}
  53. - name: Build and push backend image
  54. uses: docker/build-push-action@v5
  55. with:
  56. context: .
  57. push: ${{ github.event_name != 'pull_request' }}
  58. tags: ${{ steps.meta.outputs.tags }}
  59. labels: ${{ steps.meta.outputs.labels }}
  60. platforms: linux/amd64,linux/arm64
  61. cache-from: type=gha,scope=backend
  62. cache-to: type=gha,mode=max,scope=backend
  63. build-frontend:
  64. runs-on: ubuntu-latest
  65. permissions:
  66. contents: read
  67. packages: write
  68. id-token: write
  69. steps:
  70. - name: Checkout repository
  71. uses: actions/checkout@v4
  72. - name: Set up Docker Buildx
  73. uses: docker/setup-buildx-action@v3
  74. - name: Log into registry ${{ env.REGISTRY }}
  75. uses: docker/login-action@v3
  76. with:
  77. registry: ${{ env.REGISTRY }}
  78. username: ${{ github.actor }}
  79. password: ${{ secrets.GITHUB_TOKEN }}
  80. - name: Extract Docker metadata
  81. id: meta
  82. uses: docker/metadata-action@v5
  83. with:
  84. images: ${{ env.REGISTRY }}/${{ github.repository }}-frontend
  85. - name: Build and push frontend image
  86. uses: docker/build-push-action@v5
  87. with:
  88. context: ./frontend
  89. file: ./frontend/Dockerfile
  90. push: ${{ github.event_name != 'pull_request' }}
  91. tags: ${{ steps.meta.outputs.tags }}
  92. labels: ${{ steps.meta.outputs.labels }}
  93. platforms: linux/amd64,linux/arm64
  94. cache-from: type=gha,scope=frontend
  95. cache-to: type=gha,mode=max,scope=frontend