这是indexloc提供的服务,不要输入任何密码
Skip to content

fix(docker): set initiad version in docker image #374

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 1 commit into from
Mar 21, 2025
Merged

Conversation

Vritra4
Copy link
Contributor

@Vritra4 Vritra4 commented Mar 21, 2025

Description

Closes: #XXXX


Author Checklist

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

@Vritra4 Vritra4 self-assigned this Mar 21, 2025
@Vritra4 Vritra4 requested a review from a team as a code owner March 21, 2025 04:08
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails
actions/actions/checkout 4.*.* 🟢 5.8
Details
CheckScoreReason
Binary-Artifacts🟢 10no binaries found in the repo
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Code-Review🟢 10all changesets reviewed
Maintained⚠️ 12 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 1
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Fuzzing⚠️ 0project is not fuzzed
Signed-Releases⚠️ -1no releases found
Pinned-Dependencies🟢 3dependency not pinned by hash detected -- score normalized to 3
Branch-Protection⚠️ -1internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration
Security-Policy🟢 9security policy file detected
Packaging🟢 10packaging workflow detected
SAST🟢 9SAST tool detected but not run on all commits
Vulnerabilities⚠️ 28 existing vulnerabilities detected
actions/docker/build-push-action 6.*.* 🟢 5.5
Details
CheckScoreReason
Security-Policy🟢 9security policy file detected
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
Code-Review🟢 4Found 3/7 approved changesets -- score normalized to 4
Maintained🟢 1024 commit(s) and 12 issue activity found in the last 90 days -- score normalized to 10
Binary-Artifacts🟢 10no binaries found in the repo
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Branch-Protection🟢 5branch protection is not maximal on development and all release branches
Packaging🟢 10packaging workflow detected
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 46 existing vulnerabilities detected
actions/docker/login-action 3.*.* 🟢 6.3
Details
CheckScoreReason
Maintained🟢 1016 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 10
Packaging⚠️ -1packaging workflow not detected
Security-Policy🟢 9security policy file detected
Code-Review🟢 10all changesets reviewed
Binary-Artifacts🟢 10no binaries found in the repo
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Fuzzing⚠️ 0project is not fuzzed
License🟢 10license file detected
Signed-Releases⚠️ -1no releases found
Branch-Protection🟢 5branch protection is not maximal on development and all release branches
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
SAST🟢 8SAST tool detected but not run on all commits
Vulnerabilities🟢 46 existing vulnerabilities detected
actions/docker/metadata-action 5.*.* 🟢 5.9
Details
CheckScoreReason
Maintained🟢 1025 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Code-Review🟢 8Found 5/6 approved changesets -- score normalized to 8
Security-Policy🟢 9security policy file detected
Binary-Artifacts🟢 10no binaries found in the repo
Token-Permissions⚠️ 0detected GitHub workflow tokens with excessive permissions
Dangerous-Workflow🟢 10no dangerous workflow patterns detected
CII-Best-Practices⚠️ 0no effort to earn an OpenSSF best practices badge detected
License🟢 10license file detected
Fuzzing⚠️ 0project is not fuzzed
Signed-Releases⚠️ -1no releases found
Branch-Protection🟢 5branch protection is not maximal on development and all release branches
Packaging🟢 10packaging workflow detected
Pinned-Dependencies⚠️ 0dependency not pinned by hash detected -- score normalized to 0
SAST⚠️ 0SAST tool is not run on all commits -- score normalized to 0
Vulnerabilities🟢 46 existing vulnerabilities detected

Scanned Files

  • .github/workflows/docker.yml

Copy link

coderabbitai bot commented Mar 21, 2025

📝 Walkthrough

Walkthrough

This update introduces new build arguments in the Dockerfile and modifies the Makefile's handling of versioning variables. The Dockerfile now declares ARG VERSION and ARG COMMIT and updates its build command to utilize both arguments. In parallel, the Makefile removes the previous static COMMIT definition and adds a conditional assignment: if COMMIT is unset, it is populated using a git log command. The comments are updated accordingly for clarity. These changes improve the build process by accurately incorporating commit information and preserving any user-defined value.

Changes

File(s) Change Summary
Dockerfile Added ARG VERSION and ARG COMMIT at the start; updated the build command to include both arguments, thus integrating commit data into the build process.
Makefile Removed the unconditional COMMIT assignment; introduced a conditional check to assign COMMIT using git log if not preset, with updated comments for clarity.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant M as Makefile
    participant G as Git
    participant D as Docker Build

    U->>M: Invoke build process
    M->>M: Check if COMMIT is set
    alt COMMIT not set
        M->>G: Retrieve latest COMMIT via `git log`
        G-->>M: Return commit hash
    end
    M->>D: Execute docker build with VERSION & COMMIT
    D->>Dockerfile: Build command uses both arguments
Loading

Poem

I'm a bunny with a hop so bright,
New changes spring into the light.
VERSION and COMMIT now play their part,
Guiding the build with a cheerful heart.
Hopping along, our code feels just right! 🐇✨


🪧 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.
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Makefile (1)

14-20: Fallback Mechanism for VERSION:
The logic first attempts to set VERSION via git describe --tags and, if that yields an empty value, falls back to the pattern $(BRANCH)-$(COMMIT). This provides a robust fallback mechanism. Although functionally sound, consider refactoring or adding comments to clarify the nested conditionals for future maintainers.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b8eb64e and 2262224.

⛔ Files ignored due to path filters (1)
  • .github/workflows/docker.yml is excluded by !**/*.yml
📒 Files selected for processing (2)
  • Dockerfile (2 hunks)
  • Makefile (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (4)
Dockerfile (2)

7-8: Build Arguments Addition:
The addition of the ARG VERSION and ARG COMMIT lines enhances the traceability of the Docker image by allowing version and commit information to be injected at build time. Ensure that these arguments are supplied during the build process when required.


41-41: Updated Build Command with Versioning Info:
The RUN command now propagates the VERSION and COMMIT values into the build process, which is essential for embedding accurate metadata into the binary. Double-check that the complex quoting around LDFLAGS (with the escaped quotes) behaves as intended in your shell environment.

Makefile (2)

9-12: Preservation of User-Defined COMMIT:
The conditional assignment for COMMIT (“if empty, then set it using git log”) is a good approach to preserve any user-defined value, ensuring that it isn’t inadvertently overridden.


72-77: Embedding Versioning Information in ldflags:
The ldflags now include $(VERSION) and $(COMMIT) to ensure that the built binary contains accurate version metadata. This change maintains consistency with the Dockerfile modifications and is well integrated.

Copy link
Member

@beer-1 beer-1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@beer-1 beer-1 merged commit a453feb into main Mar 21, 2025
7 checks passed
@beer-1 beer-1 deleted the fix/version-in-image branch March 21, 2025 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants