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

chore(infra): Improve .dockerignore #17048

Merged
merged 3 commits into from
Nov 27, 2024
Merged

chore(infra): Improve .dockerignore #17048

merged 3 commits into from
Nov 27, 2024

Conversation

AndesKrrrrrrrrrrr
Copy link
Member

@AndesKrrrrrrrrrrr AndesKrrrrrrrrrrr commented Nov 27, 2024

Much faster "Transferring build context" and thinner images.

Cherry-picked from #17050

Summary by CodeRabbit

  • Chores
    • Updated the .dockerignore file to include new ignore patterns for improved organization and specificity, enhancing the Docker build process.

@AndesKrrrrrrrrrrr AndesKrrrrrrrrrrr marked this pull request as ready for review November 27, 2024 15:12
@AndesKrrrrrrrrrrr AndesKrrrrrrrrrrr requested a review from a team as a code owner November 27, 2024 15:12
@AndesKrrrrrrrrrrr AndesKrrrrrrrrrrr added the automerge Merge this PR as soon as all checks pass label Nov 27, 2024
Copy link
Contributor

coderabbitai bot commented Nov 27, 2024

Walkthrough

The changes in this pull request focus on the .dockerignore file, which has been significantly updated to include new ignore patterns and reorganize existing entries. Specific patterns have been added to ignore Git-related files, environment files, cache directories, log files, and Docker-related files. This results in a more comprehensive and structured approach to managing ignored files during Docker builds.

Changes

File Change Summary
.dockerignore Added new ignore patterns for Git files, environment files, cache directories, log files, and Docker-related files. Reorganized existing entries for clarity and specificity.

Possibly related PRs

Suggested labels

deploy-feature

Suggested reviewers

  • busla
  • peturgq

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.

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

🧹 Outside diff range and nitpick comments (5)
.dockerignore (5)

1-2: Consider removing the vim filetype directive

The vim filetype directive is helpful during development but doesn't affect Docker functionality. Consider removing it to keep the file focused on its primary purpose.

-# vi: ft=gitignore
-

3-9: Enhance environment file patterns

While the current patterns are good, consider adding more common environment file variants for completeness.

 # Known ignores
 /.github/
 /.git/
 /scripts/ci/
 /.env.*
 /.envrc*
+/.env
+/.environment
+/.env.local
+/.env.*.local

Note: .git/ is automatically ignored by Docker, so its entry is redundant but harmless.


15-20: Add more temporary file patterns

Consider adding more common temporary file patterns to ensure comprehensive coverage.

 # Logs and temporaries
 **/log/
 **/*.log
 **/tmp/
 **/temp/
+**/*.tmp
+**/*.temp
+**/.DS_Store
+**/Thumbs.db

21-24: Add more build output patterns

Consider adding more common build output directories to ensure comprehensive coverage.

 # Outputs
 **/dist/
 **/out/
+**/build/
+**/.build/
+**/coverage/
+**/.coverage/
+**/.next/

1-31: Consider organizing patterns by priority and scope

The current organization is good, but consider restructuring the file to:

  1. Place most impactful patterns first (like node_modules and build outputs)
  2. Group patterns by their scope (global vs local)
  3. Add comments explaining why certain patterns are included

This would make the file more maintainable and help others understand the impact of each pattern.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 0226fb1 and a1a4be5.

📒 Files selected for processing (1)
  • .dockerignore (1 hunks)
🔇 Additional comments (1)
.dockerignore (1)

25-31: Enhance Docker-related patterns and verify impact

The patterns look good, but consider adding more Docker-related files. Also, let's verify the impact of these changes on the build context size.

 # Docker-stuff
 **/Dockerfile
 **/Dockerfile.*
 **/Containerfile
 **/Containerfile.*
 **/*-compose.yaml
 **/*-compose.yml
+**/.docker/
+**/docker-compose.override.*
✅ Verification successful

Let me gather more information about Docker-related files in the repository.


Docker-related patterns in .dockerignore are sufficient

The current Docker-related patterns in .dockerignore are comprehensive and well-structured. After analyzing the repository:

  • All Dockerfile variants are covered by existing patterns
  • Multiple docker-compose.yml files exist but are already covered
  • No .docker directories or docker-compose.override files were found
  • Container-related source files (*.ts, *.tsx) should not be ignored as they are part of the application code

The suggested additions are not necessary as they would either:

  • Match non-existent files (.docker/, docker-compose.override.*)
  • Or potentially ignore required source code files
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of .dockerignore changes on build context size

# Get the total size of files that would be included in build context
echo "Files that would be included in build context:"
tar -czf - . --exclude-vcs | wc -c

# List any potentially large files that might have been missed
echo -e "\nPotentially large files (>10MB) that would be included:"
find . -type f -size +10M ! -path "*/\.*" ! -path "*/node_modules/*" ! -path "*/dist/*" ! -path "*/build/*" -exec ls -lh {} \;

Length of output: 716


Script:

#!/bin/bash
# Check for Docker-related files that might need to be ignored
echo "Finding Docker-related files:"
fd -H -t f "docker|container" -E ".dockerignore"

echo -e "\nChecking for .docker directories:"
fd -H -t d "^\.docker$"

echo -e "\nChecking for docker-compose override files:"
fd -t f "docker-compose\.override\."

Length of output: 4066

.dockerignore Show resolved Hide resolved
Copy link
Member

@svanaeinars svanaeinars left a comment

Choose a reason for hiding this comment

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

LGTM

@AndesKrrrrrrrrrrr AndesKrrrrrrrrrrr changed the title chore(infra): Improve .dockerignore chore(infra): Improve .dockerignore Nov 27, 2024
Copy link

codecov bot commented Nov 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 35.70%. Comparing base (6d774ed) to head (1a4ede9).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##             main   #17048    +/-   ##
========================================
  Coverage   35.69%   35.70%            
========================================
  Files        6939     6929    -10     
  Lines      147081   146454   -627     
  Branches    41832    41617   -215     
========================================
- Hits        52495    52285   -210     
+ Misses      94586    94169   -417     
Flag Coverage Δ
judicial-system-web 28.09% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 52 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d774ed...1a4ede9. Read the comment docs.

@datadog-island-is
Copy link

datadog-island-is bot commented Nov 27, 2024

Datadog Report

Branch report: chore/dockerignore
Commit report: 161d603
Test service: judicial-system-web

✅ 0 Failed, 335 Passed, 0 Skipped, 56.6s Total Time
➡️ Test Sessions change in coverage: 1 no change

@kodiakhq kodiakhq bot merged commit ede53ec into main Nov 27, 2024
31 checks passed
@kodiakhq kodiakhq bot deleted the chore/dockerignore branch November 27, 2024 18:49
AndesKrrrrrrrrrrr added a commit that referenced this pull request Nov 28, 2024
kodiakhq bot pushed a commit that referenced this pull request Nov 28, 2024
AndesKrrrrrrrrrrr added a commit that referenced this pull request Nov 28, 2024
kodiakhq bot added a commit that referenced this pull request Nov 29, 2024
* Revert "revert: "chore(infra): Improve `.dockerignore` (#17048)" (#17063)"

This reverts commit 1fdf64d.

* Don't ignore _all_ caches

* Add .cache/

* Add more git-ignored ignores

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Merge this PR as soon as all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants