Add exercise 03: building from scratch (practice + solution) #4
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: Build and Push Sandbox Images | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "docker/Dockerfile.base" | |
| - "docker/Dockerfile.agents" | |
| - "exercises/**" | |
| - ".github/workflows/build-images.yml" | |
| workflow_dispatch: | |
| inputs: | |
| reason: | |
| description: "Reason for manual rebuild" | |
| required: false | |
| default: "Manual trigger" | |
| env: | |
| REGISTRY: ghcr.io | |
| BASE_IMAGE: mmerrell/temporal-python-sandbox | |
| AGENTS_IMAGE: mmerrell/temporal-python-agents-sandbox | |
| jobs: | |
| build-base: | |
| name: Build temporal-python-sandbox (base) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.BASE_IMAGE }} | |
| tags: | | |
| type=sha,prefix=sha-,format=short | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push base image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: docker/Dockerfile.base | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.BASE_IMAGE }}:buildcache | |
| cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.BASE_IMAGE }}:buildcache,mode=max | |
| build-agents: | |
| name: Build temporal-python-agents-sandbox | |
| runs-on: ubuntu-latest | |
| needs: build-base | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.AGENTS_IMAGE }} | |
| tags: | | |
| type=sha,prefix=sha-,format=short | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push agents image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: docker/Dockerfile.agents | |
| platforms: linux/amd64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.AGENTS_IMAGE }}:buildcache | |
| cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.AGENTS_IMAGE }}:buildcache,mode=max |