-
Notifications
You must be signed in to change notification settings - Fork 5
Publish OCI image #562
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
Merged
Merged
Publish OCI image #562
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
103eac9
Add Dockerfiles for CI-based pre-built zip and full inline build
aj-stein 102010b
Add container build workflow before piping into build one
aj-stein d68433b
Bring it altogether, plumb into build workflow
aj-stein 1c2d296
Adjust paths for CLI package target subdir, not top-level dir
aj-stein 93c1c4e
Add docs for CLI install methods, docker and all
aj-stein 75a1f81
Address @coderabbitai feedback, remove excess workflow job perms
aj-stein 45c5ad5
Correct OCI image user oscalcli->metaschema
aj-stein f8f607f
Align README docs and OCI image build commands per @coderabbitai feed…
aj-stein 404d729
Revert "Address @coderabbitai feedback, remove excess workflow job pe…
aj-stein 70ba8eb
Yet more path tuning recs from @coderabbitai
aj-stein bad2c00
Don't overgeneralize glob, correct bad tmp file subs
aj-stein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| name: Build and Publish Container | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| push: | ||
| description: 'Whether to push the container image to the registry' | ||
| required: false | ||
| default: false | ||
| type: boolean | ||
| env: | ||
| REGISTRY: ghcr.io | ||
| IMAGE_NAME: metaschema-framework/metaschema-cli | ||
| # Docs: github.com/docker/metadata-action/?tab=readme-ov-file#typesha | ||
| DOCKER_METADATA_PR_HEAD_SHA: true | ||
| # https://github.com/docker/metadata-action?tab=readme-ov-file#annotations | ||
| DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,index | ||
| jobs: | ||
| build-container: | ||
| name: Build Image | ||
| runs-on: ubuntu-24.04 | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| attestations: write | ||
| id-token: write | ||
| steps: | ||
| - uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 | ||
| with: | ||
| submodules: recursive | ||
| filter: tree:0 | ||
| - name: Download build zip | ||
| uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 | ||
| with: | ||
| name: build_zip | ||
| path: ./metaschema-cli/target | ||
| - name: Container image QEMU setup for cross-arch builds | ||
| id: image_setup_qemu | ||
| uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf | ||
| - name: Container image buildx setup for cross-arch builds | ||
| id: image_setup_buildx | ||
| uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db | ||
| with: | ||
| platforms: linux/amd64,linux/arm64/v8 | ||
| - name: Container image login | ||
| id: image_login | ||
| uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ github.actor }} | ||
| password: ${{ secrets.GITHUB_TOKEN }} | ||
| - name: Container image metadata and tag generation | ||
| id: image_metadata | ||
| uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 | ||
| with: | ||
| images: | ||
| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=sha,prefix=,suffix=,format=long | ||
| type=ref,event=branch | ||
| type=ref,event=tag | ||
| type=ref,event=pr | ||
| flavor: | | ||
| latest=${{ github.ref == 'refs/heads/main' }} | ||
| annotations: | | ||
| maintainers="Metaschema Community Admin <admin@metaschema.dev>" | ||
| org.opencontainers.image.authors="Metaschema Community Admin <admin@metaschema.dev>" | ||
| org.opencontainers.image.documentation="https://metaschema.dev" | ||
| org.opencontainers.image.source="https://github.com/metaschema-framework/metaschema-java" | ||
| org.opencontainers.image.vendor="Metaschema Community" | ||
| org.opencontainers.image.title="metaschema-cli" | ||
| org.opencontainers.image.description="Metaschema-powered CLI tool" | ||
| org.opencontainers.image.licenses="CC0-1.0" | ||
| - if: inputs.push | ||
| name: Container image registry push | ||
| id: image_registry_push | ||
| uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile.ci | ||
| push: true | ||
| tags: ${{ steps.image_metadata.outputs.tags }} | ||
| labels: ${{ steps.image_metadata.outputs.labels }} | ||
| platforms: linux/amd64,linux/arm64/v8 | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| - if: inputs.push | ||
| name: Container image push attestations | ||
| uses: actions/attest-build-provenance@1c608d11d69870c2092266b3f9a6f3abbf17002c | ||
| with: | ||
| subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | ||
| subject-digest: ${{ steps.image_registry_push.outputs.digest }} | ||
| push-to-registry: true |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # syntax=docker/dockerfile:1 | ||
| ARG BUILDER_IMAGE=maven:3.9.9-eclipse-temurin-17 | ||
| ARG RUNNER_IMAGE=eclipse-temurin:17 | ||
|
|
||
| FROM ${BUILDER_IMAGE} AS builder | ||
| RUN apt-get update && apt-get install -y unzip | ||
| COPY ./metaschema-cli/target/*metaschema-cli.zip /tmp/metaschema-cli.zip | ||
| WORKDIR /tmp | ||
| RUN unzip /tmp/metaschema-cli.zip -d /opt/metaschema-cli | ||
| RUN chmod +x /opt/metaschema-cli/bin/metaschema-cli | ||
|
|
||
| FROM ${RUNNER_IMAGE} AS runner | ||
| COPY --from=builder /opt/metaschema-cli /opt/metaschema-cli | ||
| RUN groupadd -r metaschema && \ | ||
| useradd -r -g metaschema -s /bin/false metaschema && \ | ||
| chown -R metaschema:metaschema /opt/metaschema-cli && \ | ||
| mkdir -p /app && \ | ||
| chown metaschema:metaschema /app | ||
| WORKDIR /app | ||
| USER metaschema | ||
| RUN /opt/metaschema-cli/bin/metaschema-cli --version | ||
| ENTRYPOINT [ "/opt/metaschema-cli/bin/metaschema-cli" ] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| # syntax=docker/dockerfile:1 | ||
| ARG BUILDER_IMAGE=maven:3.9.9-eclipse-temurin-17 | ||
| ARG RUNNER_IMAGE=eclipse-temurin:17 | ||
|
|
||
| FROM ${BUILDER_IMAGE} AS builder | ||
| ARG BUILDER_JDK_VENDOR=temurin | ||
| ARG BUILDER_JDK_MAJOR_VERSION=17 | ||
| ARG BUILDER_JDK_HOME_PATH=/opt/java/openjdk | ||
| ADD . /usr/local/src | ||
| WORKDIR /usr/local/src | ||
| RUN apt-get update && apt-get install -y unzip | ||
| RUN <<EOF | ||
| mkdir -p /root/.m2 | ||
| cat > /root/.m2/toolchains.xml << XMLEOF | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <toolchains> | ||
| <toolchain> | ||
| <type>jdk</type> | ||
| <provides> | ||
| <vendor>${BUILDER_JDK_VENDOR}</vendor> | ||
| <version>${BUILDER_JDK_MAJOR_VERSION}</version> | ||
| </provides> | ||
| <configuration> | ||
| <jdkHome>${BUILDER_JDK_HOME_PATH}</jdkHome> | ||
| </configuration> | ||
| </toolchain> | ||
| </toolchains> | ||
| XMLEOF | ||
| EOF | ||
| RUN mvn -B -e -Prelease package | ||
| RUN find /usr/local/src/metaschema-cli/target \ | ||
| -iname 'metaschema-cli-*metaschema-cli.zip' \ | ||
| -exec cp {} /tmp/metaschema-cli.zip \; | ||
| RUN mkdir -p /opt/metaschema-cli | ||
| RUN unzip /tmp/metaschema-cli.zip -d /opt/metaschema-cli | ||
| RUN chmod +x /opt/metaschema-cli/bin/metaschema-cli | ||
aj-stein marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| FROM ${RUNNER_IMAGE} AS runner | ||
| COPY --from=builder /opt/metaschema-cli /opt/metaschema-cli | ||
| RUN groupadd -r metaschema && \ | ||
| useradd -r -g metaschema -s /bin/false metaschema && \ | ||
| chown -R metaschema:metaschema /opt/metaschema-cli && \ | ||
| mkdir -p /app && \ | ||
| chown metaschema:metaschema /app | ||
| WORKDIR /app | ||
| USER metaschema | ||
| RUN /opt/metaschema-cli/bin/metaschema-cli --version | ||
| ENTRYPOINT [ "/opt/metaschema-cli/bin/metaschema-cli" ] | ||
|
|
||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.