Skip to content
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

Docker builds for tags #145

Merged
merged 2 commits into from
Nov 22, 2024
Merged

Docker builds for tags #145

merged 2 commits into from
Nov 22, 2024

Conversation

naveensrinivasan
Copy link
Member

@naveensrinivasan naveensrinivasan commented Nov 19, 2024

Summary by CodeRabbit

  • New Features

    • Added support for versioned tags in the Docker image build process.
    • Introduced a new step to extract Git tags for better version management.
  • Improvements

    • Updated workflow steps for enhanced clarity and functionality, including renaming and simplifications.
    • Enhanced error handling for Docker image pushes.
  • Chores

    • Removed unnecessary build step to streamline the workflow.

Copy link
Contributor

coderabbitai bot commented Nov 19, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request modifies the GitHub Actions workflow for building and pushing Docker images. It introduces a new trigger for versioned tags, updates several steps to use specific versions, and renames steps for clarity. A new step captures the Git tag from the workflow context, and the process for pushing Docker images is streamlined to include both versioned and latest tags.

Changes

File Path Change Summary
.github/workflows/main.yaml - Added trigger for tags matching 'v*'.
- Renamed Set up Docker to Set up Docker Buildx.
- Added step Extract Git Tag to capture Git tag from context.
- Removed Run build step.
- Renamed Push Docker images to Push Docker Images.

Possibly related PRs

  • Container scan #107: The changes in this PR involve the Set up Docker Buildx step, which is also modified in the main PR, indicating a direct connection in the context of Docker workflows.
  • Enabled CGO for Go Builds #144: Although this PR primarily focuses on enabling CGO for Go builds, it involves modifications to the Dockerfile, which may relate to the overall Docker image building process referenced in the main PR.

Suggested reviewers

  • neilnaveen

Poem

🐰 In the garden where Docker blooms,
A tag is caught, dispelling glooms.
With Buildx set and images bright,
We push our dreams into the night.
Versioned paths, we hop along,
In code and tags, we sing our song! 🎶


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 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

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅


🚨 Try these New Features:

Copy link
Contributor

@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: 3

🧹 Outside diff range and nitpick comments (2)
.github/workflows/main.yaml (2)

36-39: Consider Docker build optimizations

Several improvements could enhance the Docker build process:

  1. Parameterize the repository name using GitHub environment variables
  2. Add multi-platform build support
  3. Implement build caching

Example implementation:

       - name: Docker Build
         run: |
           TAG=${GIT_TAG:-latest}
-          docker build -t ghcr.io/bitbomdev/minefield:latest -t ghcr.io/bitbomdev/minefield:${TAG} .
+          REPO="ghcr.io/${{ github.repository_owner }}/minefield"
+          docker buildx build \
+            --platform linux/amd64,linux/arm64 \
+            --cache-from type=gha \
+            --cache-to type=gha,mode=max \
+            -t ${REPO}:latest \
+            -t ${REPO}:${TAG} \
+            .
🧰 Tools
🪛 actionlint

37-37: shellcheck reported issue in this script: SC2086:info:2:83: Double quote to prevent globbing and word splitting

(shellcheck)


Workflow conflicts detected - action required

The new main.yaml workflow needs adjustment as it overlaps with existing workflows:

  • build.yaml already handles Docker builds for the main branch but without publishing
  • grype.yaml performs security scanning for Docker images on PRs
  • The new workflow adds tag-based releases and GHCR publishing

Recommendations:

  • Move the Docker publishing logic from main.yaml into build.yaml's Docker job for better consolidation
  • Keep the tag-based triggers and GHCR publishing steps
  • Add dependency on the security scan job from grype.yaml before publishing
🔗 Analysis chain

Line range hint 1-52: Verify workflow uniqueness and integration

Let's ensure this workflow doesn't conflict with other existing Docker build workflows.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other Docker-related workflows
echo "Checking for other Docker workflows..."
fd -e yml -e yaml . .github/workflows/ -x grep -l 'docker' {} \;

# Search for other tag-triggered workflows
echo "Checking for other tag-triggered workflows..."
fd -e yml -e yaml . .github/workflows/ -x grep -l "tags:" {} \;

Length of output: 465


Script:

#!/bin/bash
# Let's examine the content of these workflows to understand potential conflicts
echo "=== Content of grype.yaml ==="
cat .github/workflows/grype.yaml

echo -e "\n=== Content of build.yaml ==="
cat .github/workflows/build.yaml

Length of output: 3402

🧰 Tools
🪛 actionlint

20-20: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


28-28: the runner of "actions/setup-go@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


34-34: shellcheck reported issue in this script: SC2086:info:1:44: Double quote to prevent globbing and word splitting

(shellcheck)


37-37: shellcheck reported issue in this script: SC2086:info:2:83: Double quote to prevent globbing and word splitting

(shellcheck)


49-49: shellcheck reported issue in this script: SC2086:info:3:41: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint

[error] 8-8: trailing spaces

(trailing-spaces)


[error] 16-16: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)


[error] 30-30: trailing spaces

(trailing-spaces)


[error] 52-52: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 3fc9391 and 4560cf4.

📒 Files selected for processing (1)
  • .github/workflows/main.yaml (1 hunks)
🧰 Additional context used
🪛 actionlint
.github/workflows/main.yaml

20-20: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


28-28: the runner of "actions/setup-go@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


34-34: shellcheck reported issue in this script: SC2086:info:1:44: Double quote to prevent globbing and word splitting

(shellcheck)


37-37: shellcheck reported issue in this script: SC2086:info:2:83: Double quote to prevent globbing and word splitting

(shellcheck)


49-49: shellcheck reported issue in this script: SC2086:info:3:41: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint
.github/workflows/main.yaml

[error] 8-8: trailing spaces

(trailing-spaces)


[error] 16-16: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)


[error] 30-30: trailing spaces

(trailing-spaces)


[error] 52-52: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (1)
.github/workflows/main.yaml (1)

7-8: LGTM: Tag trigger configuration is correct

The addition of the tag trigger for versioned releases follows best practices.

🧰 Tools
🪛 yamllint

[error] 8-8: trailing spaces

(trailing-spaces)

.github/workflows/main.yaml Outdated Show resolved Hide resolved
.github/workflows/main.yaml Outdated Show resolved Hide resolved
Copy link
Contributor

@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: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 4560cf4 and fa49808.

📒 Files selected for processing (1)
  • .github/workflows/main.yaml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.3)
.github/workflows/main.yaml

20-20: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


28-28: the runner of "actions/setup-go@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


37-37: shellcheck reported issue in this script: SC2086:info:2:83: Double quote to prevent globbing and word splitting

(shellcheck)


49-49: shellcheck reported issue in this script: SC2086:info:3:41: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint (1.29.0-1)
.github/workflows/main.yaml

[error] 8-8: trailing spaces

(trailing-spaces)


[error] 16-16: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)


[error] 30-30: trailing spaces

(trailing-spaces)


[error] 52-52: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (2)
.github/workflows/main.yaml (2)

7-8: LGTM: Tag trigger for versioned releases

The addition of the tag trigger is well-implemented and follows the standard pattern for versioned releases.

🧰 Tools
🪛 yamllint (1.29.0-1)

[error] 8-8: trailing spaces

(trailing-spaces)


32-34: LGTM: Secure tag extraction implementation

The Git tag extraction is well-implemented with proper conditions and secure shell practices.

.github/workflows/main.yaml Outdated Show resolved Hide resolved
.github/workflows/main.yaml Outdated Show resolved Hide resolved
.github/workflows/main.yaml Outdated Show resolved Hide resolved
.github/workflows/main.yaml Outdated Show resolved Hide resolved
Copy link
Contributor

@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

🧹 Outside diff range and nitpick comments (1)
.github/workflows/main.yaml (1)

24-25: Consider implementing Docker layer caching

To improve build times, consider implementing Docker layer caching. This can be achieved by:

  1. Using buildx cache from GitHub Actions cache
  2. Implementing multi-stage builds with proper layer ordering

Example implementation:

- uses: actions/cache@v3
  with:
    path: /tmp/.buildx-cache
    key: ${{ runner.os }}-buildx-${{ github.sha }}
    restore-keys: |
      ${{ runner.os }}-buildx-

- uses: docker/build-push-action@v5
  with:
    context: .
    push: false
    cache-from: type=local,src=/tmp/.buildx-cache
    cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between fa49808 and 1bcd40a.

📒 Files selected for processing (1)
  • .github/workflows/main.yaml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.3)
.github/workflows/main.yaml

20-20: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


28-28: the runner of "actions/setup-go@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


37-37: shellcheck reported issue in this script: SC2086:info:2:83: Double quote to prevent globbing and word splitting

(shellcheck)

🪛 yamllint (1.29.0-1)
.github/workflows/main.yaml

[error] 8-8: trailing spaces

(trailing-spaces)


[error] 16-16: trailing spaces

(trailing-spaces)


[error] 22-22: trailing spaces

(trailing-spaces)


[error] 30-30: trailing spaces

(trailing-spaces)

🔇 Additional comments (6)
.github/workflows/main.yaml (6)

7-8: LGTM: Tag-based trigger is properly configured

The addition of the v* tag trigger is a good practice for automated releases.

🧰 Tools
🪛 yamllint (1.29.0-1)

[error] 8-8: trailing spaces

(trailing-spaces)


16-16: LGTM: Appropriate permissions set

The packages: write permission is correctly configured for pushing to GHCR.

🧰 Tools
🪛 yamllint (1.29.0-1)

[error] 16-16: trailing spaces

(trailing-spaces)


20-30: Existing comments address the version updates needed

Previous review comments already cover the necessary updates for action versions and Go version.

🧰 Tools
🪛 actionlint (1.7.3)

20-20: the runner of "actions/checkout@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


28-28: the runner of "actions/setup-go@v2" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🪛 yamllint (1.29.0-1)

[error] 22-22: trailing spaces

(trailing-spaces)


[error] 30-30: trailing spaces

(trailing-spaces)


32-34: LGTM: Git tag extraction is properly implemented

The tag extraction is correctly implemented with proper quoting and conditional checking.


36-39: Existing comments address the Docker build improvements

Previous review comments already cover the necessary improvements for the Docker build step.

🧰 Tools
🪛 actionlint (1.7.3)

37-37: shellcheck reported issue in this script: SC2086:info:2:83: Double quote to prevent globbing and word splitting

(shellcheck)


42-57: Existing comments address the Docker login and push improvements

Previous review comments already cover the necessary improvements for the Docker login and push steps.

Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
Signed-off-by: naveensrinivasan <172697+naveensrinivasan@users.noreply.github.com>
@neilnaveen neilnaveen merged commit a1e1869 into main Nov 22, 2024
8 of 9 checks passed
@neilnaveen neilnaveen deleted the naveen/fix/docker-builds-tags branch November 22, 2024 16:14
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