Skip to content

Commit

Permalink
ci: Include build information in Docker image labels
Browse files Browse the repository at this point in the history
  • Loading branch information
sharat87 committed Feb 6, 2025
1 parent 6604f36 commit 648dc85
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 15 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/ad-hoc-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,12 @@ jobs:
rm app/client/packages/rts/dist/rts-dist.tar
- name: Generate info.json
id: info_json
run: |
if [[ -f scripts/generate_info_json.sh ]]; then
scripts/generate_info_json.sh ${{ inputs.tag }}
fi
scripts/generate_info_json.sh "${{ inputs.tag }}"
- name: Place server artifacts-es
run: |
run: |
if [[ -f scripts/prepare_server_artifacts.sh ]]; then
PG_TAG=${{ inputs.pg_tag }} scripts/prepare_server_artifacts.sh
else
Expand Down Expand Up @@ -126,3 +124,7 @@ jobs:
BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:nightly
tags: |
${{ 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 }}
10 changes: 6 additions & 4 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ jobs:
rm app/client/packages/rts/dist/rts-dist.tar
- name: Generate info.json
id: info_json
run: |
if [[ -f scripts/generate_info_json.sh ]]; then
scripts/generate_info_json.sh
fi
scripts/generate_info_json.sh
- name: Place server artifacts-es
env:
EDITION: ${{ vars.EDITION }}
Expand Down Expand Up @@ -105,6 +104,9 @@ jobs:
args+=(--build-arg "APPSMITH_CLOUD_SERVICES_BASE_URL=https://release-cs.appsmith.com")
fi
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[@]}" .
# Saving the docker image to tar file
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ jobs:
with:
node-version-file: app/client/package.json

# actions/setup-node@v4 doesnt 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
# Restoring the cache manually instead
- name: Restore Yarn cache
Expand Down Expand Up @@ -247,6 +247,7 @@ jobs:
rm app/client/packages/rts/dist/rts-dist.tar
- name: Generate info.json
id: info_json
run: |
scripts/generate_info_json.sh
Expand Down Expand Up @@ -277,3 +278,7 @@ jobs:
BASE=${{ vars.DOCKER_HUB_ORGANIZATION }}/base-${{ vars.EDITION }}:nightly
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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
with:
node-version-file: app/client/package.json

# actions/setup-node@v4 doesnt 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
# Restoring the cache manually instead
- name: Restore Yarn cache
Expand Down Expand Up @@ -169,10 +169,9 @@ jobs:
rm app/client/packages/rts/dist/rts-dist.tar
- name: Generate info.json
id: info_json
run: |
if [[ -f scripts/generate_info_json.sh ]]; then
scripts/generate_info_json.sh
fi
scripts/generate_info_json.sh
- name: Place server artifacts-es
run: |
Expand Down Expand Up @@ -209,6 +208,10 @@ jobs:
cache-from: ${{ vars.DOCKER_HUB_ORGANIZATION }}/appsmith-${{ vars.EDITION }}:release
tags: |
${{ 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: |
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 }}
Expand Down
13 changes: 11 additions & 2 deletions scripts/generate_info_json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ jq -n \
--argjson isCI "${CI:-false}" \
'$ARGS.named' | tee "$(git rev-parse --show-toplevel)/deploy/docker/fs/opt/appsmith/info.json"

# Usage
# 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
# ./scripts/generate_info_json.sh v0.0.1
# ./scripts/generate_info_json.sh v0.1
# ./scripts/generate_info_json.sh
# ./scripts/generate_info_json.sh

0 comments on commit 648dc85

Please sign in to comment.