Skip to content

ci: Add some build details to image labels as per OCI#39025

Merged
sharat87 merged 1 commit intoreleasefrom
ci/info-labels
Feb 6, 2025
Merged

ci: Add some build details to image labels as per OCI#39025
sharat87 merged 1 commit intoreleasefrom
ci/info-labels

Conversation

@sharat87
Copy link
Member

@sharat87 sharat87 commented Feb 5, 2025

Description

This will allow us to identify the commit used for a Docker image, via DockerHub API, without having to download the image and inspecting the info.json inside.

Only doing it on release image for starters. If it works out well, and provides value, I'll open another PR to do this for the other places we're building the image.

Automation

/test sanity

🔍 Cypress test results

Caution

If you modify the content in this section, you are likely to disrupt the CI result for your PR.

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Docker images now include enhanced metadata (commit revision, source, and version details) to improve image traceability and support deployment tracking.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

The workflow in .github/workflows/test-build-docker-image.yml has been updated to include a new step (info_json) that runs the scripts/generate_info_json.sh script. This step captures output data (commit SHA, repository, and version) via jq and exposes it as GitHub output variables. The Docker image build and push processes are then updated to embed these outputs into appropriate labels for improved image metadata.

Changes

File Path Change Summary
.github/workflows/test-build-docker-image.yml Added a new step (info_json) executing scripts/generate_info_json.sh to collect commit information; updated Docker build/push steps to incorporate new output variables as labels

Sequence Diagram(s)

sequenceDiagram
    participant GitHub as GitHub Workflow
    participant Script as generate_info_json.sh
    participant Parser as jq
    participant Docker as Docker Build Process

    GitHub->>Script: Execute generate_info_json.sh
    Script-->>GitHub: Return JSON with commit info
    GitHub->>Parser: Parse JSON output
    Parser-->>GitHub: Extract commitSha, repo, version
    GitHub->>Docker: Build and push Docker image with labels
Loading

Suggested reviewers

  • nidhi-nair
  • mohanarpit

Poem

In the realm of code so fine,
A script now gathers secrets in line,
Commit data revealed with grace,
Docker images don labels in their place,
Cheers to tweaks that shine so bright!
🚀🌟

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1de2408 and 66eb154.

📒 Files selected for processing (1)
  • .github/workflows/test-build-docker-image.yml (2 hunks)
🔇 Additional comments (2)
.github/workflows/test-build-docker-image.yml (2)

352-358: Review the new "Generate info.json" step for robustness.
This new step executes scripts/generate_info_json.sh and parses its output via jq to set GitHub output variables. Consider adding error handling to verify that the script produces valid JSON and non-empty values before echoing to the output. Also, using >> $GITHUB_OUTPUT rather than tee -a $GITHUB_OUTPUT might simplify the implementation and reduce the risk of unexpected side effects.


391-395: Ensure consistency and reliability in Docker image labels.
The labels for org.opencontainers.image.revision, org.opencontainers.image.source, and org.opencontainers.image.version are now sourced from the outputs of the info_json step. This is aligned with the OCI specification, and it improves image metadata. Please verify that the generate_info_json.sh script consistently returns the expected JSON structure, as missing or malformed fields could lead to incorrect labels being embedded.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog CI labels Feb 5, 2025
@sharat87 sharat87 marked this pull request as ready for review February 5, 2025 11:44
@sharat87 sharat87 merged commit 6604f36 into release Feb 6, 2025
22 checks passed
@sharat87 sharat87 deleted the ci/info-labels branch February 6, 2025 01:42
sharat87 added a commit that referenced this pull request Feb 6, 2025
## Description

Completion of #39025.

We're able to see the labels with Docker API (script written by Cursor):


![shot-2025-02-06-04-41-44](https://github.com/user-attachments/assets/2523b85c-cd2c-4481-ac08-2de76a0dc979)


Implemented by these two Cursor prompts 🙂


![shot-2025-02-06-05-16-29](https://github.com/user-attachments/assets/6787e5f4-161e-41c6-b6fb-bdec4ea92b38)


![shot-2025-02-06-05-16-43](https://github.com/user-attachments/assets/1ec3d449-0dff-44b0-9b39-487ef6514eea)


<!-- 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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants