-
Notifications
You must be signed in to change notification settings - Fork 71
Automate Docker Image Build and Publish #877
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 all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
bc4f485
Automate Docker image builds
chaptersix 42cc84f
move the docker ignore file to the correct location
chaptersix 04e92b6
fix a few bugs
chaptersix 0e9929e
support building on pr and upgrade goreleaser
chaptersix 4667b5c
Fix semgrep issues and wf permission
chaptersix 15163e4
remove write perm from re-usable wf
chaptersix 062c9b7
update go releaser to use formats instead of format and gh wf to stop…
chaptersix 2155012
turn on caching and upload build artifacts.
chaptersix 5ecf25a
remove makefile that is not longer needed
chaptersix 8918ee7
correct alpine update command
chaptersix f6d0470
Modernize Docker build with parameterization and registry flexibility
chaptersix 363f893
Address PR feedback: simplify Docker build and fix workflow issues
chaptersix 41f7f4d
Update Dockerfile
chaptersix 98cfaff
Add explicit permissions to trigger-docs workflow
chaptersix 24bbfb8
Restore Makefile from upstream
chaptersix 5aa5d9d
remoe support for ghcr, simplify script, action version update
chaptersix 4274740
a few minor fixes
chaptersix fa17267
update action versions
chaptersix ef83ff2
simplify script again
chaptersix 4864813
fix syntax and corrections for lint issues
chaptersix 05b0021
add namespace default
chaptersix b7bda83
correct image name
chaptersix 0388341
refactor update tag workflow
chaptersix 2098e5c
remove comments and checks that are no longer needed
chaptersix a096c92
security fixes
chaptersix 90577f9
add tzdata to dockerfile
chaptersix 7b1df2e
update tag latest workflow and remove latest tagging from other code
chaptersix 4249db7
refactor to build docker images only in a manually triggered workflow.
chaptersix c31c2f9
add option to publish a docker image
chaptersix c19e100
remove go releaser builds on pr and main
chaptersix 0f2c204
fix bug. collect proper cli sha
chaptersix 7c6e522
Merge branch 'main' into alex/docker-image-re
chaptersix 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 |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| name: Build and Publish Docker Image | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version tag for the Docker image (e.g., 1.2.3 or v1.2.3)' | ||
| required: true | ||
| type: string | ||
| publish: | ||
| description: 'Push the image to Docker Hub' | ||
| required: false | ||
| type: boolean | ||
| default: true | ||
| tag_latest: | ||
| description: 'Also tag this image as latest' | ||
| required: false | ||
| type: boolean | ||
| default: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build-and-publish: | ||
| name: Build and Publish Docker Image | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| - name: Get build metadata from release | ||
| id: meta | ||
| env: | ||
| INPUT_VERSION: ${{ inputs.version }} | ||
| INPUT_TAG_LATEST: ${{ inputs.tag_latest }} | ||
| uses: actions/github-script@v8 | ||
| with: | ||
| script: | | ||
| const inputVersion = process.env.INPUT_VERSION; | ||
| const inputTagLatest = process.env.INPUT_TAG_LATEST; | ||
| const version = inputVersion.startsWith('v') ? inputVersion.slice(1) : inputVersion; | ||
| const releaseTag = inputVersion.startsWith('v') ? inputVersion : `v${inputVersion}`; | ||
| const { data: release } = await github.rest.repos.getReleaseByTag({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| tag: releaseTag | ||
| }); | ||
| const cliSha = release.target_commitish; | ||
| const imageShaTag = cliSha.substring(0, 7); | ||
| core.setOutput('cli_sha', cliSha); | ||
| core.setOutput('image_sha_tag', imageShaTag); | ||
| core.setOutput('version', version); | ||
| core.setOutput('release_tag', releaseTag); | ||
| core.setOutput('tag_latest', inputTagLatest === 'true'); | ||
| - name: Download release assets | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| RELEASE_TAG: ${{ steps.meta.outputs.release_tag }} | ||
| run: | | ||
| echo "Downloading assets from release ${RELEASE_TAG}..." | ||
| gh release download "${RELEASE_TAG}" --pattern "temporal_*_linux_*.tar.gz" | ||
| echo "Extracting and organizing binaries..." | ||
| mkdir -p dist/amd64 dist/arm64 | ||
| tar -xzf temporal_*_linux_amd64.tar.gz | ||
| mv temporal dist/amd64/temporal | ||
| tar -xzf temporal_*_linux_arm64.tar.gz | ||
| mv temporal dist/arm64/temporal | ||
| echo "Verifying binaries..." | ||
| ls -lh dist/amd64/temporal | ||
| ls -lh dist/arm64/temporal | ||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v3 | ||
|
|
||
| - name: Log in to Docker Hub | ||
| if: inputs.publish | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
|
||
| - name: Build and push Docker image | ||
| if: inputs.publish | ||
| run: | | ||
| docker buildx bake \ | ||
| --file docker-bake.hcl \ | ||
| --push \ | ||
| cli | ||
| env: | ||
| CLI_SHA: ${{ steps.meta.outputs.cli_sha }} | ||
| IMAGE_SHA_TAG: ${{ steps.meta.outputs.image_sha_tag }} | ||
| VERSION: ${{ steps.meta.outputs.version }} | ||
| TAG_LATEST: ${{ steps.meta.outputs.tag_latest }} | ||
| IMAGE_NAMESPACE: temporalio | ||
| IMAGE_NAME: temporal | ||
| GITHUB_REPOSITORY: ${{ github.repository }} | ||
|
|
||
| - name: Build Docker image (no push) | ||
| if: ${{ !inputs.publish }} | ||
| run: | | ||
| docker buildx bake \ | ||
| --file docker-bake.hcl \ | ||
| cli | ||
| env: | ||
| CLI_SHA: ${{ steps.meta.outputs.cli_sha }} | ||
| IMAGE_SHA_TAG: ${{ steps.meta.outputs.image_sha_tag }} | ||
| VERSION: ${{ steps.meta.outputs.version }} | ||
| TAG_LATEST: ${{ steps.meta.outputs.tag_latest }} | ||
| IMAGE_NAMESPACE: temporalio | ||
| IMAGE_NAME: temporal | ||
| GITHUB_REPOSITORY: ${{ github.repository }} | ||
27 changes: 16 additions & 11 deletions
27
.github/workflows/goreleaser.yml → .github/workflows/release.yml
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
This file was deleted.
Oops, something went wrong.
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
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,45 @@ | ||
| variable "IMAGE_NAMESPACE" { | ||
| default = "" | ||
| } | ||
|
|
||
| variable "IMAGE_NAME" { | ||
| default = "temporal" | ||
| } | ||
|
|
||
| variable "GITHUB_REPOSITORY" { | ||
| default = "temporalio/cli" | ||
| } | ||
|
|
||
| variable "IMAGE_SHA_TAG" {} | ||
|
|
||
| variable "CLI_SHA" { | ||
| default = "" | ||
| } | ||
|
|
||
| variable "VERSION" { | ||
| default = "dev" | ||
| } | ||
|
|
||
| variable "TAG_LATEST" { | ||
| default = false | ||
| } | ||
|
|
||
| target "cli" { | ||
| dockerfile = "Dockerfile" | ||
| context = "." | ||
| tags = compact([ | ||
| "${IMAGE_NAMESPACE}/${IMAGE_NAME}:${IMAGE_SHA_TAG}", | ||
| "${IMAGE_NAMESPACE}/${IMAGE_NAME}:${VERSION}", | ||
| TAG_LATEST ? "${IMAGE_NAMESPACE}/${IMAGE_NAME}:latest" : "", | ||
| ]) | ||
| platforms = ["linux/amd64", "linux/arm64"] | ||
| labels = { | ||
| "org.opencontainers.image.title" = "temporal" | ||
| "org.opencontainers.image.description" = "Temporal CLI" | ||
| "org.opencontainers.image.url" = "https://github.com/${GITHUB_REPOSITORY}" | ||
| "org.opencontainers.image.source" = "https://github.com/${GITHUB_REPOSITORY}" | ||
| "org.opencontainers.image.licenses" = "MIT" | ||
| "org.opencontainers.image.revision" = "${CLI_SHA}" | ||
| "org.opencontainers.image.created" = timestamp() | ||
| } | ||
| } |
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.