Docker Build Web #17
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Docker Build Web" | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: "Tag for the Docker image" | |
| required: false | |
| default: "latest" | |
| type: string | |
| jobs: | |
| build: | |
| name: Build Docker Image (${{ matrix.platform }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| platform: [amd64, arm64] | |
| fail-fast: false | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Create .env file | |
| run: | | |
| echo "WEB_URL=http://localhost:3000" > .env | |
| echo "NEXT_PUBLIC_DOCKER_BUILD=true" >> .env | |
| echo "NEXT_PUBLIC_CAP_AWS_BUCKET=capso" >> .env | |
| echo "NEXT_PUBLIC_CAP_AWS_REGION=us-east-1" >> .env | |
| cat .env | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and Push Platform Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: apps/web/Dockerfile | |
| platforms: linux/${{ matrix.platform }} | |
| push: true | |
| tags: ghcr.io/capsoftware/cap-web:${{ inputs.tag || 'latest' }}-${{ matrix.platform }} | |
| cache-from: type=gha,scope=buildx-${{ matrix.platform }} | |
| cache-to: type=gha,mode=max,scope=buildx-${{ matrix.platform }} | |
| merge: | |
| name: Create Multi-Architecture Manifest | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create and Push Multi-Arch Manifest | |
| run: | | |
| docker buildx imagetools create \ | |
| --tag ghcr.io/capsoftware/cap-web:${{ inputs.tag || 'latest' }} \ | |
| ghcr.io/capsoftware/cap-web:${{ inputs.tag || 'latest' }}-amd64 \ | |
| ghcr.io/capsoftware/cap-web:${{ inputs.tag || 'latest' }}-arm64 |