code-ubuntu #256
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: code-ubuntu | |
| on: | |
| schedule: | |
| - cron: "0 10 * * *" | |
| push: | |
| branches: ["**"] | |
| tags: ["v*.*.*"] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_PREFIX: ghcr.io/${{ github.repository }}/code | |
| KANIKO_EXTRA_ARGS: >- | |
| --snapshot-mode=redo --use-new-run --cache-run-layers --cache-copy-layers --cache-ttl=168h --compressed-caching=false --cleanup | |
| jobs: | |
| build-base: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| image: | |
| - name: ubuntu | |
| context: images/base | |
| - name: minimal | |
| context: images/minimal | |
| platform: | |
| - runner: ubuntu-latest | |
| arch: amd64 | |
| - runner: ubuntu-24.04-arm | |
| arch: arm64 | |
| runs-on: ${{ matrix.platform.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: coder/images | |
| submodules: recursive | |
| - uses: aevea/action-kaniko@master | |
| with: | |
| image: code/${{ matrix.image.name }} | |
| path: ${{ matrix.image.context }} | |
| build_file: ubuntu.Dockerfile | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| cache: true | |
| cache_registry: code/${{ matrix.image.name }}/cache | |
| extra_args: ${{ env.KANIKO_EXTRA_ARGS }} | |
| manifest-base: | |
| needs: build-base | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| image: [ubuntu, minimal] | |
| steps: | |
| - uses: imjasonh/setup-crane@v0.4 | |
| - name: Push manifest | |
| run: | | |
| crane auth login ${{ env.REGISTRY }} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} | |
| IMAGE="${{ env.IMAGE_PREFIX }}/${{ matrix.image }}" | |
| TAGS="latest ${{ github.sha }}" | |
| if [[ "${{ github.ref }}" == refs/tags/v* ]]; then | |
| TAGS="$TAGS ${{ github.ref_name }}" | |
| fi | |
| for TAG in $TAGS; do | |
| crane index append \ | |
| --tag "${IMAGE}:${TAG}" \ | |
| --manifest "${IMAGE}:latest-amd64" \ | |
| --manifest "${IMAGE}:latest-arm64" | |
| done | |
| build-derived: | |
| needs: manifest-base | |
| if: always() && !failure() && !cancelled() | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| image: | |
| - name: desktop | |
| context: images/desktop | |
| - name: golang | |
| context: images/golang | |
| - name: java | |
| context: images/java | |
| - name: node | |
| context: images/node | |
| platform: | |
| - runner: ubuntu-latest | |
| arch: amd64 | |
| - runner: ubuntu-24.04-arm | |
| arch: arm64 | |
| runs-on: ${{ matrix.platform.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| repository: coder/images | |
| submodules: recursive | |
| - name: Point to our base images | |
| run: | | |
| sed -i \ | |
| -e 's|codercom/enterprise-base:ubuntu|${{ env.IMAGE_PREFIX }}/ubuntu:latest|g' \ | |
| -e 's|codercom/enterprise-minimal:latest|${{ env.IMAGE_PREFIX }}/minimal:latest|g' \ | |
| ${{ matrix.image.context }}/ubuntu.Dockerfile | |
| - uses: aevea/action-kaniko@master | |
| with: | |
| image: code/${{ matrix.image.name }} | |
| path: ${{ matrix.image.context }} | |
| build_file: ubuntu.Dockerfile | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| cache: true | |
| cache_registry: code/${{ matrix.image.name }}/cache | |
| extra_args: ${{ env.KANIKO_EXTRA_ARGS }} | |
| manifest-derived: | |
| needs: build-derived | |
| if: github.event_name != 'pull_request' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| image: [desktop, golang, java, node] | |
| steps: | |
| - uses: imjasonh/setup-crane@v0.4 | |
| - name: Push manifest | |
| run: |- | |
| crane auth login ${{ env.REGISTRY }} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} | |
| IMAGE="${{ env.IMAGE_PREFIX }}/${{ matrix.image }}" | |
| TAGS="latest ${{ github.sha }}" | |
| if [[ "${{ github.ref }}" == refs/tags/v* ]]; then | |
| TAGS="$TAGS ${{ github.ref_name }}" | |
| fi | |
| for TAG in $TAGS; do | |
| crane index append \ | |
| --tag "${IMAGE}:${TAG}" \ | |
| --manifest "${IMAGE}:latest-amd64" \ | |
| --manifest "${IMAGE}:latest-arm64" | |
| done |