-
Notifications
You must be signed in to change notification settings - Fork 150
Self-contained docker build with ARM64 publishing #3962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
4d9fdec
b9b37b3
5a2da94
9307961
2d07268
2b30965
ff819ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ./out | ||
| .bloop | ||
| .bsp | ||
| .metals | ||
| .scala-build | ||
| .scala | ||
| gifs | ||
| website | ||
| .github | ||
| Dockerfile |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,133 @@ | ||||||||||
| name: Create and publish a Docker image | ||||||||||
|
|
||||||||||
| concurrency: | ||||||||||
| group: ${{ github.workflow }}-${{ github.ref }} | ||||||||||
| cancel-in-progress: true | ||||||||||
|
|
||||||||||
| # Configures this workflow to run every time a change is pushed to the branch called `release`. | ||||||||||
| on: | ||||||||||
| push: | ||||||||||
| branches: ["main"] | ||||||||||
| tags: ["v*"] | ||||||||||
|
|
||||||||||
| env: | ||||||||||
| REGISTRY: ghcr.io | ||||||||||
| IMAGE_NAME: ${{ github.repository }} | ||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't the name of the image have to be in lowercase letters? Currently
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @keynmol bump
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, missed this - I will amend soon, apparently github actions have no built in (without shelling out) ways to lowercase - so I will hardcode it for now |
||||||||||
| DOCKERFILE: ./Dockerfile | ||||||||||
| REGISTRY_LOGIN: ${{ github.actor }} | ||||||||||
| REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
|
|
||||||||||
| jobs: | ||||||||||
| docker_build: | ||||||||||
| strategy: | ||||||||||
| fail-fast: true | ||||||||||
| matrix: | ||||||||||
| os: ["ubuntu-22.04", "ubuntu-22.04-arm"] | ||||||||||
Gedochao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| runs-on: ${{ matrix.os }} | ||||||||||
| # Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job. | ||||||||||
| permissions: | ||||||||||
| contents: read | ||||||||||
| packages: write | ||||||||||
| attestations: write | ||||||||||
| id-token: write | ||||||||||
| # | ||||||||||
| steps: | ||||||||||
| - name: Checkout repository | ||||||||||
| uses: actions/checkout@v4 | ||||||||||
|
|
||||||||||
| - name: Log in to the Container registry | ||||||||||
| uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||||||||||
Gedochao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| with: | ||||||||||
| registry: ${{ env.REGISTRY }} | ||||||||||
| username: ${{ github.actor }} | ||||||||||
| password: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
keynmol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
|
|
||||||||||
| # This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels. | ||||||||||
| - name: Extract metadata (tags, labels) for Docker | ||||||||||
| id: meta | ||||||||||
| uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 | ||||||||||
keynmol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| with: | ||||||||||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||||||||||
|
|
||||||||||
| - name: Set up Docker Buildx | ||||||||||
| uses: docker/setup-buildx-action@v3 | ||||||||||
|
|
||||||||||
| # This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages. | ||||||||||
| # It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository. | ||||||||||
| # It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step. | ||||||||||
| - name: Build and push Docker image | ||||||||||
| id: push | ||||||||||
| uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||||||||||
keynmol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| with: | ||||||||||
| context: . | ||||||||||
| file: ${{ env.DOCKERFILE }} | ||||||||||
| cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.os }} | ||||||||||
| cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache-${{ matrix.os }},mode=max | ||||||||||
| push: true | ||||||||||
| tags: ${{ steps.meta.outputs.tags }} | ||||||||||
| labels: ${{ steps.meta.outputs.labels }} | ||||||||||
|
|
||||||||||
| # This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)." | ||||||||||
| - name: Generate artifact attestation | ||||||||||
| uses: actions/attest-build-provenance@v1 | ||||||||||
keynmol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| with: | ||||||||||
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | ||||||||||
| subject-digest: ${{ steps.push.outputs.digest }} | ||||||||||
| push-to-registry: true | ||||||||||
|
|
||||||||||
| - name: Export digest | ||||||||||
| run: | | ||||||||||
| mkdir -p /tmp/digests | ||||||||||
| digest="${{ steps.push.outputs.digest }}" | ||||||||||
| touch "/tmp/digests/${digest#sha256:}" | ||||||||||
|
|
||||||||||
| - name: Upload digest | ||||||||||
| uses: actions/upload-artifact@v4 | ||||||||||
| with: | ||||||||||
| name: digests-${{ matrix.os }} | ||||||||||
| path: /tmp/digests/* | ||||||||||
| if-no-files-found: error | ||||||||||
| retention-days: 1 | ||||||||||
|
|
||||||||||
| docker_release_merge: | ||||||||||
| runs-on: ubuntu-22.04 | ||||||||||
Gedochao marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| permissions: | ||||||||||
| contents: read | ||||||||||
| packages: write | ||||||||||
| attestations: write | ||||||||||
| id-token: write | ||||||||||
| needs: [docker_build] | ||||||||||
| if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main') | ||||||||||
| steps: | ||||||||||
| - name: Download digests | ||||||||||
| uses: actions/download-artifact@v4 | ||||||||||
| with: | ||||||||||
| pattern: digests-* | ||||||||||
| path: /tmp/digests | ||||||||||
| merge-multiple: true | ||||||||||
|
|
||||||||||
| - name: Set up Docker Buildx | ||||||||||
| uses: docker/setup-buildx-action@v2 | ||||||||||
|
|
||||||||||
| - name: Log in to the Container registry | ||||||||||
| uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||||||||||
keynmol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||
| with: | ||||||||||
| registry: ${{ env.REGISTRY }} | ||||||||||
| username: ${{ github.actor }} | ||||||||||
| password: ${{ secrets.GITHUB_TOKEN }} | ||||||||||
|
||||||||||
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| username: ${{ env.REGISTRY_LOGIN }} | |
| password: ${{ env.REGISTRY_PASSWORD }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@keynmol I reverted to unresolved, you changed it in only one place
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| FROM eclipse-temurin:17 as build | ||
| RUN apt update && apt install build-essential libz-dev clang procps git -y | ||
| WORKDIR /workdir | ||
| COPY . . | ||
| RUN ./mill -i copyTo --task 'cli[].base-image.nativeImage' --dest "./docker-out/scala-cli" 1>&2 | ||
|
|
||
| FROM debian:stable-slim | ||
| RUN apt update && apt install build-essential libz-dev clang procps -y | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean, we definitely want Scala Native to build nicely with it, so |
||
| COPY --from=build /workdir/docker-out/scala-cli /usr/bin/scala-cli | ||
| RUN \ | ||
| echo "println(1)" | scala-cli -S 3 - -v -v -v && \ | ||
| echo "println(1)" | scala-cli -S 2.13 - -v -v -v && \ | ||
| echo "println(1)" | scala-cli -S 2.12 - -v -v -v | ||
| RUN \ | ||
| echo "println(1)" | scala-cli --power package --native _.sc --force && \ | ||
| echo "println(1)" | scala-cli --power package --native-image _.sc --force | ||
|
|
||
| ENTRYPOINT ["scala-cli"] | ||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...you mean like,
v*tags andmain, right?