1
0

docker-publish.yml 2.5 KB

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