-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add multi arch support #28
Changes from 26 commits
5032c57
0664dda
ca44e1f
0c36b58
85a637d
686e76b
d85b19b
463de30
eb876da
e855aad
30e298c
2cd826b
67cb346
f6b0cfc
e035f4a
8515f63
1609699
483b25b
e7b7fab
27e6eeb
b709112
5138652
2c4dfe9
f386295
f510a92
5f2f680
d503643
2efd76f
51836e6
0e64d58
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,39 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
file: | ||
required: true | ||
type: string | ||
image: | ||
required: true | ||
type: string | ||
outputs: | ||
tags: | ||
description: "Image tags with all java versions appended to image input" | ||
value: ${{ jobs.parse.outputs.tags }} | ||
args: | ||
description: "Build args content read from input file" | ||
value: ${{ jobs.parse.outputs.args }} | ||
|
||
jobs: | ||
parse: | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
tags: ${{ steps.extract.outputs.tags }} | ||
args: ${{ steps.extract.outputs.args }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- shell: bash | ||
id: extract | ||
run: | | ||
TOTAL_JAVA_VERSION=$(cat ${{ inputs.file }} | grep "JAVA_VERSION" | cut -d'=' -f2) | ||
BASE_JAVA_VERSION=$(echo $TOTAL_JAVA_VERSION | cut -d'-' -f1) | ||
MAJOR_JAVA_VERSION=$(echo $BASE_JAVA_VERSION | cut -d'.' -f1) | ||
echo "tags=${{ inputs.image }}:$MAJOR_JAVA_VERSION,${{ inputs.image }}:$BASE_JAVA_VERSION,${{ inputs.image }}:$TOTAL_JAVA_VERSION" >> $GITHUB_OUTPUT | ||
{ | ||
echo "args<<nEOFn" | ||
echo "$(cat ${{ inputs.file }})" | ||
echo "nEOFn" | ||
} >> $GITHUB_OUTPUT |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,43 +3,77 @@ on: | |
push: | ||
branches: | ||
- main | ||
pull_request_target: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
extract-args-java-11: | ||
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. This seems like excessive complexity for a simple task. In the build case, we don't even need to generate all the individual tags anyway. In the publish version, since that's the only spot we need them, you can just inline the couple 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. Yes it is a bit complex, but since we wouldn't want to store build args hidden in github actions yamls rather in repo source I thought this is required Can we inline reading data from a file and doing cut to pass as a variable to an action? I couldn't think of a way to do it and built a reusable workflow. I reused the same in build too even if isn't strictly required 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. Could you do something like this? basically just an inline form of the same code. I also moved the build arg name from inside the file to outside. - name: Read Java Version
shell: bash
id: versions
run: |
ZULU_JDK_VERSION=`cat ${{ matrix.java-major-version}}/java.version}}`
echo ZULU_JDK_VERSION=${ZULU_JDK_VERSION} >> $GITHUB_OUTPUT
echo JAVA_MAJOR_VERSION=$(echo $ZULU_JDK_VERSION | cut -d'.' -f1)" >> $GITHUB_OUTPUT
echo JAVA_FULL_VERSION=$(echo $ZULU_JDK_VERSION | cut -d'-' -f1) >> $GITHUB_OUTPUT Then, for build args just declare it like build-args: |
JAVA_VERSION=${{steps.versions.output.ZULU_JDK_VERSION}} 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 also wouldn't bother publishing the zulu version tag - it should be treated as an impl detail since we're not making any guarantees about the specific distro of java we're using. 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. This is fine by me, I wanted to leave scope for any more build args being added in future without need to touch gha Not a strong opinion, but would prefer to have the current args.env file version as:
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'm not sure why we'd add any more args, and if we did, it's likely we'd be changing the build too. If the arg was statically defined, there'd be no point in passing it in in the first place. If it were dynamic, we'd likely be using a matrix or some other way of calculating the value for it in CI then need to pass them in like above anyway. The java version is actually bit of a strange case as it's static, but kept outside the dockerfile so it can be consumed to tag as well. A common counter example would be something like the current commit SHA. So in other words, the more likely future case is we'd need to calculate a build arg in the build and then pass it to the build command which would be more difficult to do if merging it with the static env file. Not positive if that makes sense, or if I'm missing your point though. 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.
Ah, got it. I thought it was done as a good practice whatever things are not required to be static, make them as args and pass it during build. Hence I was thinking of multiple build args as a possibility. Makes sense to me now, updating |
||
uses: ./.github/workflows/extract-args.yml | ||
with: | ||
file: java-11/args.env | ||
image: hypertrace/java-build | ||
|
||
extract-args-java-21: | ||
uses: ./.github/workflows/extract-args.yml | ||
with: | ||
file: java-21/args.env | ||
image: hypertrace/java-build | ||
|
||
build: | ||
runs-on: ubuntu-22.04 | ||
strategy: | ||
matrix: | ||
aaron-steinfeld marked this conversation as resolved.
Show resolved
Hide resolved
|
||
platform: [linux/amd64, linux/arm64] | ||
needs: | ||
- extract-args-java-11 | ||
- extract-args-java-21 | ||
steps: | ||
# Set fetch-depth: 0 to fetch commit history and tags for use in version calculation | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_READ_USER }} | ||
password: ${{ secrets.DOCKERHUB_READ_TOKEN }} | ||
|
||
- name: Build with Gradle | ||
uses: hypertrace/github-actions/gradle@main | ||
- name: Build java-11 | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: java-11 | ||
platforms: ${{ matrix.platform }} | ||
build-args: | | ||
${{ needs.extract-args-java-11.outputs.args }} | ||
tags: ${{ needs.extract-args-java-11.outputs.tags }} | ||
load: true | ||
|
||
- name: Build java-21 | ||
uses: docker/build-push-action@v5 | ||
with: | ||
args: dockerBuildImages | ||
context: java-21 | ||
platforms: ${{ matrix.platform }} | ||
build-args: | | ||
${{ needs.extract-args-java-21.outputs.args }} | ||
tags: ${{ needs.extract-args-java-21.outputs.tags }} | ||
load: true | ||
|
||
- name: Scan java-11 image | ||
uses: hypertrace/github-actions/trivy-image-scan@main | ||
with: | ||
image: hypertrace/java | ||
image: hypertrace/java-build | ||
tag: 11 | ||
category: java-11 | ||
output-mode: github | ||
|
||
- name: Scan java-21 image | ||
uses: hypertrace/github-actions/trivy-image-scan@main | ||
with: | ||
image: hypertrace/java | ||
image: hypertrace/java-build | ||
tag: 21 | ||
category: java-21 | ||
output-mode: github |
This file was deleted.
This file was deleted.
This file was deleted.
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.
wasted too much time here because of not wrapping this in echo not creating new line as it is not in file and leading to EOF not found 😔