|
| 1 | +name: Build and Push Docker Images |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [use_uv] |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY: ghcr.io |
| 9 | + IMAGE_NAME: ${{ github.repository }}-${{ github.ref_name }} |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-and-push-client: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + permissions: |
| 15 | + contents: read |
| 16 | + packages: write |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Set up Docker Buildx |
| 23 | + uses: docker/setup-buildx-action@v3 |
| 24 | + |
| 25 | + - name: Log in to Container Registry |
| 26 | + uses: docker/login-action@v3 |
| 27 | + with: |
| 28 | + registry: ${{ env.REGISTRY }} |
| 29 | + username: ${{ github.actor }} |
| 30 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + |
| 32 | + - name: Build and push client image |
| 33 | + uses: docker/build-push-action@v5 |
| 34 | + with: |
| 35 | + context: . |
| 36 | + file: ./docker/client/Dockerfile |
| 37 | + push: ${{ github.event_name != 'pull_request' }} |
| 38 | + tags: | |
| 39 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-client:latest |
| 40 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-client:${{ github.sha }} |
| 41 | + cache-from: type=gha |
| 42 | + cache-to: type=gha,mode=max |
| 43 | + platforms: linux/amd64,linux/arm64 |
| 44 | + build-args: | |
| 45 | + NEXT_PUBLIC_BACKEND_URL=http://localhost:8000 |
| 46 | + - name: Output client image name |
| 47 | + if: github.event_name != 'pull_request' |
| 48 | + run: | |
| 49 | + echo "Client image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-client:latest" |
| 50 | +
|
| 51 | + build-and-push-server: |
| 52 | + runs-on: ubuntu-latest |
| 53 | + permissions: |
| 54 | + contents: read |
| 55 | + packages: write |
| 56 | + |
| 57 | + steps: |
| 58 | + - name: Checkout repository |
| 59 | + uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Set up Docker Buildx |
| 62 | + uses: docker/setup-buildx-action@v3 |
| 63 | + |
| 64 | + - name: Log in to Container Registry |
| 65 | + uses: docker/login-action@v3 |
| 66 | + with: |
| 67 | + registry: ${{ env.REGISTRY }} |
| 68 | + username: ${{ github.actor }} |
| 69 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + |
| 71 | + - name: Build and push server image |
| 72 | + uses: docker/build-push-action@v5 |
| 73 | + with: |
| 74 | + context: . |
| 75 | + file: ./docker/server/Dockerfile |
| 76 | + push: ${{ github.event_name != 'pull_request' }} |
| 77 | + tags: | |
| 78 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-server:latest |
| 79 | + ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-server:${{ github.sha }} |
| 80 | + cache-from: type=gha |
| 81 | + cache-to: type=gha,mode=max |
| 82 | + platforms: linux/amd64,linux/arm64 |
| 83 | + |
| 84 | + - name: Output server image name |
| 85 | + if: github.event_name != 'pull_request' |
| 86 | + run: | |
| 87 | + echo "Server image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-prod-server:latest" |
0 commit comments