ci: Include build information in Docker image labels (#39047)
## Description Completion of https://github.com/appsmithorg/appsmith/pull/39025. We're able to see the labels with Docker API (script written by Cursor):  Implemented by these two Cursor prompts 🙂   <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Docker image builds now include added metadata (commit revision, source, and version details) to improve image traceability and version tracking. - **Chores** - CI workflows have been streamlined to consistently generate and apply metadata labels, ensuring reliable and automated image processing across all pipelines. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
parent
2b9299e2d3
commit
b442ca930e
10
.github/workflows/ad-hoc-docker-image.yml
vendored
10
.github/workflows/ad-hoc-docker-image.yml
vendored
|
|
@ -90,13 +90,11 @@ jobs:
|
||||||
rm app/client/packages/rts/dist/rts-dist.tar
|
rm app/client/packages/rts/dist/rts-dist.tar
|
||||||
|
|
||||||
- name: Generate info.json
|
- name: Generate info.json
|
||||||
|
id: info_json
|
||||||
run: |
|
run: |
|
||||||
if [[ -f scripts/generate_info_json.sh ]]; then
|
scripts/generate_info_json.sh "${{ inputs.tag }}"
|
||||||
scripts/generate_info_json.sh ${{ inputs.tag }}
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Place server artifacts-es
|
- name: Place server artifacts-es
|
||||||
run: |
|
|
||||||
run: |
|
run: |
|
||||||
if [[ -f scripts/prepare_server_artifacts.sh ]]; then
|
if [[ -f scripts/prepare_server_artifacts.sh ]]; then
|
||||||
PG_TAG=${{ inputs.pg_tag }} scripts/prepare_server_artifacts.sh
|
PG_TAG=${{ inputs.pg_tag }} scripts/prepare_server_artifacts.sh
|
||||||
|
|
@ -126,3 +124,7 @@ jobs:
|
||||||
BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:nightly
|
BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:nightly
|
||||||
tags: |
|
tags: |
|
||||||
${{ vars.DOCKER_HUB_ORGANIZATION }}/appsmith-${{ vars.EDITION }}:${{ inputs.tag }}
|
${{ vars.DOCKER_HUB_ORGANIZATION }}/appsmith-${{ vars.EDITION }}:${{ inputs.tag }}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.revision=${{ steps.info_json.outputs.commitSha }}
|
||||||
|
org.opencontainers.image.source=${{ steps.info_json.outputs.repo }}
|
||||||
|
org.opencontainers.image.version=${{ steps.info_json.outputs.version }}
|
||||||
|
|
|
||||||
6
.github/workflows/build-docker-image.yml
vendored
6
.github/workflows/build-docker-image.yml
vendored
|
|
@ -70,10 +70,9 @@ jobs:
|
||||||
rm app/client/packages/rts/dist/rts-dist.tar
|
rm app/client/packages/rts/dist/rts-dist.tar
|
||||||
|
|
||||||
- name: Generate info.json
|
- name: Generate info.json
|
||||||
|
id: info_json
|
||||||
run: |
|
run: |
|
||||||
if [[ -f scripts/generate_info_json.sh ]]; then
|
|
||||||
scripts/generate_info_json.sh
|
scripts/generate_info_json.sh
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Place server artifacts-es
|
- name: Place server artifacts-es
|
||||||
env:
|
env:
|
||||||
|
|
@ -105,6 +104,9 @@ jobs:
|
||||||
args+=(--build-arg "APPSMITH_CLOUD_SERVICES_BASE_URL=https://release-cs.appsmith.com")
|
args+=(--build-arg "APPSMITH_CLOUD_SERVICES_BASE_URL=https://release-cs.appsmith.com")
|
||||||
fi
|
fi
|
||||||
args+=(--build-arg "BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:$base_tag")
|
args+=(--build-arg "BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:$base_tag")
|
||||||
|
args+=(--label "org.opencontainers.image.revision=${{ steps.info_json.outputs.commitSha }}")
|
||||||
|
args+=(--label "org.opencontainers.image.source=${{ steps.info_json.outputs.repo }}")
|
||||||
|
args+=(--label "org.opencontainers.image.version=${{ steps.info_json.outputs.version }}")
|
||||||
docker build -t cicontainer "${args[@]}" .
|
docker build -t cicontainer "${args[@]}" .
|
||||||
|
|
||||||
# Saving the docker image to tar file
|
# Saving the docker image to tar file
|
||||||
|
|
|
||||||
7
.github/workflows/github-release.yml
vendored
7
.github/workflows/github-release.yml
vendored
|
|
@ -165,7 +165,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version-file: app/client/package.json
|
node-version-file: app/client/package.json
|
||||||
|
|
||||||
# actions/setup-node@v4 doesn’t work properly with Yarn 3
|
# actions/setup-node@v4 doesn't work properly with Yarn 3
|
||||||
# when the project lives in a subdirectory: https://github.com/actions/setup-node/issues/488
|
# when the project lives in a subdirectory: https://github.com/actions/setup-node/issues/488
|
||||||
# Restoring the cache manually instead
|
# Restoring the cache manually instead
|
||||||
- name: Restore Yarn cache
|
- name: Restore Yarn cache
|
||||||
|
|
@ -247,6 +247,7 @@ jobs:
|
||||||
rm app/client/packages/rts/dist/rts-dist.tar
|
rm app/client/packages/rts/dist/rts-dist.tar
|
||||||
|
|
||||||
- name: Generate info.json
|
- name: Generate info.json
|
||||||
|
id: info_json
|
||||||
run: |
|
run: |
|
||||||
scripts/generate_info_json.sh
|
scripts/generate_info_json.sh
|
||||||
|
|
||||||
|
|
@ -277,3 +278,7 @@ jobs:
|
||||||
BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:nightly
|
BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:nightly
|
||||||
tags: |
|
tags: |
|
||||||
${{ needs.prelude.outputs.docker_tags }}
|
${{ needs.prelude.outputs.docker_tags }}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.revision=${{ steps.info_json.outputs.commitSha }}
|
||||||
|
org.opencontainers.image.source=${{ steps.info_json.outputs.repo }}
|
||||||
|
org.opencontainers.image.version=${{ steps.info_json.outputs.version }}
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version-file: app/client/package.json
|
node-version-file: app/client/package.json
|
||||||
|
|
||||||
# actions/setup-node@v4 doesn’t work properly with Yarn 3
|
# actions/setup-node@v4 doesn't work properly with Yarn 3
|
||||||
# when the project lives in a subdirectory: https://github.com/actions/setup-node/issues/488
|
# when the project lives in a subdirectory: https://github.com/actions/setup-node/issues/488
|
||||||
# Restoring the cache manually instead
|
# Restoring the cache manually instead
|
||||||
- name: Restore Yarn cache
|
- name: Restore Yarn cache
|
||||||
|
|
@ -169,10 +169,9 @@ jobs:
|
||||||
rm app/client/packages/rts/dist/rts-dist.tar
|
rm app/client/packages/rts/dist/rts-dist.tar
|
||||||
|
|
||||||
- name: Generate info.json
|
- name: Generate info.json
|
||||||
|
id: info_json
|
||||||
run: |
|
run: |
|
||||||
if [[ -f scripts/generate_info_json.sh ]]; then
|
|
||||||
scripts/generate_info_json.sh
|
scripts/generate_info_json.sh
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Place server artifacts-es
|
- name: Place server artifacts-es
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -209,6 +208,10 @@ jobs:
|
||||||
cache-from: ${{ vars.DOCKER_HUB_ORGANIZATION }}/appsmith-${{ vars.EDITION }}:release
|
cache-from: ${{ vars.DOCKER_HUB_ORGANIZATION }}/appsmith-${{ vars.EDITION }}:release
|
||||||
tags: |
|
tags: |
|
||||||
${{ vars.DOCKER_HUB_ORGANIZATION }}/appsmith-dp:${{ vars.EDITION }}-${{ github.event.client_payload.pull_request.number }}
|
${{ vars.DOCKER_HUB_ORGANIZATION }}/appsmith-dp:${{ vars.EDITION }}-${{ github.event.client_payload.pull_request.number }}
|
||||||
|
labels: |
|
||||||
|
org.opencontainers.image.revision=${{ steps.info_json.outputs.commitSha }}
|
||||||
|
org.opencontainers.image.source=${{ steps.info_json.outputs.repo }}
|
||||||
|
org.opencontainers.image.version=${{ steps.info_json.outputs.version }}
|
||||||
build-args: |
|
build-args: |
|
||||||
APPSMITH_CLOUD_SERVICES_BASE_URL=https://release-cs.appsmith.com
|
APPSMITH_CLOUD_SERVICES_BASE_URL=https://release-cs.appsmith.com
|
||||||
BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:${{ steps.set_base_tag.outputs.base_tag }}
|
BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:${{ steps.set_base_tag.outputs.base_tag }}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,15 @@ jq -n \
|
||||||
--argjson isCI "${CI:-false}" \
|
--argjson isCI "${CI:-false}" \
|
||||||
'$ARGS.named' | tee "$(git rev-parse --show-toplevel)/deploy/docker/fs/opt/appsmith/info.json"
|
'$ARGS.named' | tee "$(git rev-parse --show-toplevel)/deploy/docker/fs/opt/appsmith/info.json"
|
||||||
|
|
||||||
|
# If running in GitHub Actions, also output the values to GITHUB_OUTPUT
|
||||||
|
if [[ -n "${GITHUB_OUTPUT-}" ]]; then
|
||||||
|
{
|
||||||
|
echo "commitSha=$commit_sha"
|
||||||
|
echo "repo=$base_url"
|
||||||
|
echo "version=$version"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
# ./scripts/generate_info_json.sh v0.0.1
|
# ./scripts/generate_info_json.sh v0.0.1
|
||||||
# ./scripts/generate_info_json.sh v0.1
|
# ./scripts/generate_info_json.sh v0.1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user