-
Notifications
You must be signed in to change notification settings - Fork 14
Refactor image building to use committed source and a release workflow #62
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
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
31e31e3
Refactor image building to use committed source and a release workflow
TimHess cc28b7c
preserve gradlew execute permission, script polish
TimHess 88cf050
no jars in source, update .md files, polish
TimHess 98a6ba0
add tests for config-server, eureka and spring-boot-admin
TimHess 263ef98
pin builder and run image, lock dependencies for reproducible images
TimHess bdbd6da
build.ps1: verify wrapper checksum, pin createdDate, fix stale help
TimHess 7cdd145
preserve customizations and tests across regeneration, fix single-ima…
TimHess 895ccb0
smoke-test built images and set up JDK 25 in CI
TimHess 5b5ddcc
update README and AGENTS for the new build flow
TimHess 9dfeb38
Enable updating buildpack images, more smoke tests
TimHess 69025f6
PR feedback
TimHess 19a82b9
revert linguist-generated=true, shell before run
TimHess cc493db
Apply suggestions from code review
TimHess ab0e7c2
PR feedback
TimHess 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,23 @@ | ||
| # Patches are applied on files extracted from a downloaded zip file. All these files use LF line endings. | ||
| *.patch text eol=lf | ||
|
|
||
| # Spring Initializr generates source files with LF line endings (Linux server). | ||
| # Explicit rules here prevent unexpected diffs when update-project.ps1 regenerates source on Windows, | ||
| # where core.autocrlf would otherwise convert committed files to CRLF on checkout. | ||
| **/source/**/*.java text eol=lf | ||
| **/source/**/*.gradle text eol=lf | ||
| **/source/**/*.properties text eol=lf | ||
| **/source/**/*.md text eol=lf | ||
| **/source/**/*.txt text eol=lf | ||
| **/source/**/*.xml text eol=lf | ||
| **/source/**/gradlew text eol=lf | ||
| **/source/**/gradlew.bat text eol=crlf | ||
| **/source/**/*.jar binary | ||
|
|
||
| # Customizations are appended/overlaid onto the generated (LF) source by update-project.ps1, | ||
| # so keep them LF to avoid introducing CRLF when regenerating on Windows. | ||
| **/customizations/build.gradle.append text eol=lf | ||
| **/customizations/overlay/**/*.java text eol=lf | ||
|
|
||
| # Mark committed source as auto-generated so GitHub collapses it in PR diffs by default. | ||
| **/source/** linguist-generated=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,119 @@ | ||
| name: Build Image | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| image: | ||
| description: 'Image name (for example: config-server)' | ||
| required: true | ||
| type: string | ||
| description: | ||
| description: 'Human-readable image description for PR comments' | ||
| required: true | ||
| type: string | ||
|
|
||
| jobs: | ||
| build-push: | ||
| name: Build and push image | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || 'edge' }} | ||
| REGISTRY: ${{ vars.DOCKER_REGISTRY }} | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Read image config | ||
| id: config | ||
| shell: bash | ||
| run: | | ||
| echo "port=$(cat '${{ inputs.image }}/metadata/PORT' | tr -d '[:space:]')" >> $GITHUB_OUTPUT | ||
| echo "health_path=$(cat '${{ inputs.image }}/metadata/HEALTH_PATH' 2>/dev/null | tr -d '[:space:]' || echo '/actuator/health')" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Set up JDK 25 | ||
| if: inputs.image != 'uaa-server' | ||
| uses: actions/setup-java@v5 | ||
| with: | ||
| distribution: temurin | ||
| java-version: '25' | ||
| cache: gradle | ||
|
|
||
| - name: Build image | ||
| run: ./build.ps1 -Name '${{ inputs.image }}' -Registry '${{ env.REGISTRY }}' -Tag '${{ env.TAG }}' | ||
| shell: pwsh | ||
|
|
||
| - name: Smoke test image | ||
| run: | | ||
| set -uo pipefail | ||
| image="${REGISTRY}/${{ inputs.image }}:${TAG}" | ||
| echo "Starting container from ${image}" | ||
| cid=$(docker run -d -p '${{ steps.config.outputs.port }}:${{ steps.config.outputs.port }}' "${image}") | ||
| url="http://localhost:${{ steps.config.outputs.port }}${{ steps.config.outputs.health_path }}" | ||
| echo "Polling ${url}" | ||
| ok=false | ||
| for i in $(seq 1 60); do | ||
| code=$(curl -s -o /dev/null -w '%{http_code}' "${url}" || true) | ||
| echo "attempt ${i}: HTTP ${code}" | ||
| if [ "${code}" = "200" ]; then ok=true; break; fi | ||
| sleep 3 | ||
| done | ||
| echo "----- container logs -----" | ||
| docker logs "${cid}" || true | ||
| docker rm -f "${cid}" >/dev/null 2>&1 || true | ||
| if [ "${ok}" != "true" ]; then | ||
| echo "Smoke test FAILED: ${url} did not return HTTP 200" | ||
| exit 1 | ||
| fi | ||
| echo "Smoke test passed" | ||
| shell: bash | ||
|
|
||
| - name: Login to container registry | ||
| uses: docker/login-action@v4 | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ secrets.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
|
||
| - name: Push image | ||
| run: docker push ${{ env.REGISTRY }}/${{ inputs.image }}:${{ env.TAG }} | ||
|
|
||
| - name: Post or update PR comment with image run instructions | ||
| uses: actions/github-script@v9 | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| with: | ||
| script: | | ||
| const marker = '<!-- IMAGE_INSTRUCTIONS_${{ inputs.image }} -->'; | ||
| const body = `${marker} | ||
| To run the ${{ inputs.description }} image built for this pull request: | ||
| \`\`\`bash | ||
| docker run --rm -d --pull=always -p ${{ steps.config.outputs.port }}:${{ steps.config.outputs.port }} --name ${{ inputs.image }}-pr ${{ env.REGISTRY }}/${{ inputs.image }}:${{ env.TAG }} | ||
| \`\`\``; | ||
|
|
||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| per_page: 100, | ||
| }); | ||
|
|
||
| const existingComment = comments.find(comment => | ||
| comment.user.login === 'github-actions[bot]' && comment.body.startsWith(marker) | ||
| ); | ||
|
|
||
| if (existingComment) { | ||
| await github.rest.issues.updateComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| comment_id: existingComment.id, | ||
| body: body, | ||
| }); | ||
| } else { | ||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: context.issue.number, | ||
| body: body, | ||
| }); | ||
| } | ||
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
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.