Daily Docker Build #18
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: Daily Docker Build | |
| on: | |
| schedule: | |
| - cron: "0 16 * * *" # Run daily at 8:00am Pacific Time (UTC-8) | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| # Build AMD64 base image | |
| build-amd64-base: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set date | |
| id: date | |
| run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push AMD64 base image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| target: base | |
| platforms: linux/amd64 | |
| tags: | | |
| ghcr.io/${{ github.repository }}:base-amd64-${{ env.DATE }} | |
| ghcr.io/${{ github.repository }}:base-amd64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Prune Docker | |
| run: | | |
| docker system prune -af | |
| df -h | |
| # Build ARM64 base image | |
| build-arm64-base: | |
| runs-on: ubuntu-24.04-arm | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set date | |
| id: date | |
| run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push ARM64 base image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| target: base | |
| platforms: linux/arm64 | |
| tags: | | |
| ghcr.io/${{ github.repository }}:base-arm64-${{ env.DATE }} | |
| ghcr.io/${{ github.repository }}:base-arm64 | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Prune Docker | |
| run: | | |
| docker system prune -af | |
| df -h | |
| # Build AMD64 prebuilt image | |
| build-amd64-prebuilt: | |
| runs-on: ubuntu-latest | |
| needs: build-amd64-base | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set date | |
| id: date | |
| run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push AMD64 prebuilt image | |
| id: build-amd64 | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| target: prebuilt | |
| platforms: linux/amd64 | |
| tags: | | |
| ghcr.io/${{ github.repository }}:prebuilt-amd64-${{ env.DATE }} | |
| ghcr.io/${{ github.repository }}:prebuilt-amd64 | |
| cache-from: type=gha | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 | |
| - name: Build and extract AMD64 artifacts stage | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| target: artifacts | |
| platforms: linux/amd64 | |
| outputs: type=tar,dest=bun-build-amd64-${{ env.DATE }}.tar.gz | |
| cache-from: type=gha | |
| - name: Upload AMD64 build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bun-build-amd64-${{ env.DATE }} | |
| path: bun-build-amd64-${{ env.DATE }}.tar.gz | |
| retention-days: 7 | |
| - name: Build & Push Run image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| target: run | |
| platforms: linux/amd64 | |
| tags: | | |
| ghcr.io/${{ github.repository }}:run-amd64-${{ env.DATE }} | |
| ghcr.io/${{ github.repository }}:run-amd64 | |
| cache-from: type=gha | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 | |
| # Build ARM64 prebuilt image | |
| build-arm64-prebuilt: | |
| runs-on: ubuntu-24.04-arm | |
| needs: build-arm64-base | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set date | |
| id: date | |
| run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| - name: Free disk space | |
| run: | | |
| sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc /opt/hostedtoolcache/CodeQL | |
| df -h | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push ARM64 prebuilt image | |
| id: build-arm64 | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| target: prebuilt | |
| platforms: linux/arm64 | |
| tags: | | |
| ghcr.io/${{ github.repository }}:prebuilt-arm64-${{ env.DATE }} | |
| ghcr.io/${{ github.repository }}:prebuilt-arm64 | |
| cache-from: type=gha | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 | |
| - name: Build and extract ARM64 artifacts stage | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| target: artifacts | |
| platforms: linux/arm64 | |
| outputs: type=tar,dest=bun-build-arm64-${{ env.DATE }}.tar.gz | |
| cache-from: type=gha | |
| - name: Upload ARM64 build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: bun-build-arm64-${{ env.DATE }} | |
| path: bun-build-arm64-${{ env.DATE }}.tar.gz | |
| retention-days: 7 | |
| - name: Build & Push Run image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| target: run | |
| platforms: linux/arm64 | |
| tags: | | |
| ghcr.io/${{ github.repository }}:run-arm64-${{ env.DATE }} | |
| ghcr.io/${{ github.repository }}:run-arm64 | |
| cache-from: type=gha | |
| build-args: | | |
| BUILDKIT_INLINE_CACHE=1 | |
| # Create multi-platform images | |
| create-multiplatform-images: | |
| needs: | |
| [ | |
| build-amd64-base, | |
| build-arm64-base, | |
| build-amd64-prebuilt, | |
| build-arm64-prebuilt, | |
| ] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set date | |
| id: date | |
| run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Create multi-platform base images | |
| - name: Create and push multi-platform base image | |
| run: | | |
| docker buildx imagetools create \ | |
| -t ghcr.io/${{ github.repository }}:base-${{ env.DATE }} \ | |
| -t ghcr.io/${{ github.repository }}:base \ | |
| -t ghcr.io/${{ github.repository }}:latest \ | |
| ghcr.io/${{ github.repository }}:base-amd64 \ | |
| ghcr.io/${{ github.repository }}:base-arm64 | |
| # Create multi-platform prebuilt images | |
| - name: Create and push multi-platform prebuilt image | |
| run: | | |
| docker buildx imagetools create \ | |
| -t ghcr.io/${{ github.repository }}:prebuilt-${{ env.DATE }} \ | |
| -t ghcr.io/${{ github.repository }}:prebuilt \ | |
| ghcr.io/${{ github.repository }}:prebuilt-amd64 \ | |
| ghcr.io/${{ github.repository }}:prebuilt-arm64 | |
| - name: Create and push multi-platform run image | |
| run: | | |
| docker buildx imagetools create \ | |
| -t ghcr.io/${{ github.repository }}:run-${{ env.DATE }} \ | |
| -t ghcr.io/${{ github.repository }}:run \ | |
| -t ghcr.io/${{ github.repository }}:latest \ | |
| ghcr.io/${{ github.repository }}:run-amd64 \ | |
| ghcr.io/${{ github.repository }}:run-arm64 | |
| # Create GitHub release with build artifacts | |
| create-release: | |
| needs: [build-amd64-prebuilt, build-arm64-prebuilt, create-multiplatform-images] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: read | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set date | |
| id: date | |
| run: echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
| - name: Download AMD64 build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: bun-build-amd64-${{ env.DATE }} | |
| path: ${{ runner.temp }}/bun-build-amd64 | |
| - name: Download ARM64 build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: bun-build-arm64-${{ env.DATE }} | |
| path: ${{ runner.temp }}/bun-build-arm64 | |
| - name: Rename files | |
| run: | | |
| mv ${{ runner.temp }}/bun-build-amd64/bun-build-amd64-${{ env.DATE }}.tar.gz ${{ runner.temp }}/bun-build-linux-amd64.tar.gz | |
| mv ${{ runner.temp }}/bun-build-arm64/bun-build-arm64-${{ env.DATE }}.tar.gz ${{ runner.temp }}/bun-build-linux-arm64.tar.gz | |
| - name: Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: "autobuild-${{ github.sha }}" | |
| name: "Bun Development Build ${{ env.DATE }}" | |
| body: "Daily build of Bun development environment with precompiled binaries from ${{ env.DATE }}." | |
| generate_release_notes: true | |
| files: | | |
| ${{ runner.temp }}/bun-build-linux-amd64.tar.gz | |
| ${{ runner.temp }}/bun-build-linux-arm64.tar.gz |