Merge pull request #82 from usnavy13/dev #3
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: Runtime Images | |
| on: | |
| push: | |
| branches: [main, dev] | |
| paths: | |
| - 'Dockerfile' | |
| - 'docker/requirements/**' | |
| - '.github/workflows/runtime.yml' | |
| workflow_dispatch: | |
| concurrency: | |
| group: runtime-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| packages: write | |
| env: | |
| REGISTRY_IMAGE: ghcr.io/usnavy13/librecodeinterpreter | |
| RUNTIME_CORE_IMAGE: ghcr.io/usnavy13/librecodeinterpreter/runtime-core | |
| RUNTIME_R_IMAGE: ghcr.io/usnavy13/librecodeinterpreter/runtime-r | |
| BUILDCACHE_IMAGE: ghcr.io/usnavy13/librecodeinterpreter/buildcache | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| runtime_hash: ${{ steps.runtime.outputs.runtime_hash }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: runtime | |
| run: echo "runtime_hash=$(scripts/ci/compute_runtime_hash.sh)" >> "${GITHUB_OUTPUT}" | |
| build-runtime-core: | |
| needs: [prepare] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| platform: linux/amd64 | |
| runner: ubuntu-24.04 | |
| - arch: arm64 | |
| platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and publish runtime-core | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| target: runtime-core | |
| push: true | |
| platforms: ${{ matrix.platform }} | |
| provenance: false | |
| tags: ${{ env.RUNTIME_CORE_IMAGE }}:${{ needs.prepare.outputs.runtime_hash }}-${{ matrix.arch }} | |
| cache-from: | | |
| type=registry,ref=${{ env.BUILDCACHE_IMAGE }}:runtime-core-${{ matrix.arch }} | |
| cache-to: type=registry,ref=${{ env.BUILDCACHE_IMAGE }}:runtime-core-${{ matrix.arch }},mode=max | |
| build-runtime-r: | |
| needs: [prepare, build-runtime-core] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - arch: amd64 | |
| platform: linux/amd64 | |
| runner: ubuntu-24.04 | |
| - arch: arm64 | |
| platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| runs-on: ${{ matrix.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build and publish runtime-r | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| target: runtime-r | |
| push: true | |
| platforms: ${{ matrix.platform }} | |
| provenance: false | |
| tags: ${{ env.RUNTIME_R_IMAGE }}:${{ needs.prepare.outputs.runtime_hash }}-${{ matrix.arch }} | |
| cache-from: | | |
| type=registry,ref=${{ env.BUILDCACHE_IMAGE }}:runtime-core-${{ matrix.arch }} | |
| type=registry,ref=${{ env.BUILDCACHE_IMAGE }}:runtime-r-${{ matrix.arch }} | |
| cache-to: type=registry,ref=${{ env.BUILDCACHE_IMAGE }}:runtime-r-${{ matrix.arch }},mode=max | |
| - name: Smoke test runtime-r | |
| run: | | |
| docker pull "${RUNTIME_R_IMAGE}:${{ needs.prepare.outputs.runtime_hash }}-${{ matrix.arch }}" | |
| docker run --rm "${RUNTIME_R_IMAGE}:${{ needs.prepare.outputs.runtime_hash }}-${{ matrix.arch }}" \ | |
| bash -lc "python3 --version && R --quiet -e 'cat(1 + 1)' && nsjail --help >/dev/null" | |
| publish-manifests: | |
| needs: [prepare, build-runtime-core, build-runtime-r] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish runtime manifests | |
| run: | | |
| docker buildx imagetools create \ | |
| -t "${RUNTIME_CORE_IMAGE}:${{ needs.prepare.outputs.runtime_hash }}" \ | |
| "${RUNTIME_CORE_IMAGE}:${{ needs.prepare.outputs.runtime_hash }}-amd64" \ | |
| "${RUNTIME_CORE_IMAGE}:${{ needs.prepare.outputs.runtime_hash }}-arm64" | |
| docker buildx imagetools create \ | |
| -t "${RUNTIME_R_IMAGE}:${{ needs.prepare.outputs.runtime_hash }}" \ | |
| "${RUNTIME_R_IMAGE}:${{ needs.prepare.outputs.runtime_hash }}-amd64" \ | |
| "${RUNTIME_R_IMAGE}:${{ needs.prepare.outputs.runtime_hash }}-arm64" |