Docker Build and Publish #2
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 and Publish | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get app name from package.json | |
| id: package | |
| run: | | |
| APP_NAME=$(node -p "require('./package.json').name") | |
| echo "APP_NAME=$APP_NAME" >> $GITHUB_ENV | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - 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: Build and Push Local Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ghcr.io/${{ github.repository }}/${{ env.APP_NAME }}:local | |
| build-args: | | |
| VITE_API_URL=http://localhost:8000 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Build and Push Production Image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| platforms: linux/amd64,linux/arm64 | |
| tags: ghcr.io/${{ github.repository }}/${{ env.APP_NAME }}:prod | |
| build-args: | | |
| VITE_API_URL=https://w2025-demo.deployed.space/api | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |