-
Notifications
You must be signed in to change notification settings - Fork 18
chore: add .dockerignore to optimize build context #353
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
Conversation
WalkthroughA Changes
Possibly related PRs
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Coverage summary from CodacySee diff coverage on Codacy
Coverage variation details
Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: Diff coverage details
Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: See your quality gate settings Change summary preferences |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #353 +/- ##
=======================================
Coverage 89.18% 89.18%
=======================================
Files 2 2
Lines 111 111
=======================================
Hits 99 99
Misses 12 12
🚀 New features to boost your workflow:
|
There was a problem hiding this 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 (3)
.dockerignore (1)
1-21: Enhance .dockerignore with common Python and environment artifactsConsider adding patterns like
__pycache__/,*.py[cod],.mypy_cache/, and environment files (.env,.env.*) to prevent Python bytecode, cache dirs, and secret-bearing env files from bloating your build context.Dockerfile (2)
24-29: Cleanup wheelhouse after installing depsTo shrink the final image, remove the prebuilt wheels once they’ve been used.
-RUN pip install --no-cache-dir --no-index --find-links /app/wheelhouse -r requirements.txt +RUN pip install --no-cache-dir --no-index --find-links /app/wheelhouse -r requirements.txt && \ + rm -rf /app/wheelhouse
30-37: Consolidate COPY instructions to reduce layersCombining multiple
COPYlines into one reduces image layers and speeds up the build.-COPY models ./models -COPY routes ./routes -COPY schemas ./schemas -COPY services ./services -COPY data ./data -COPY main.py . +COPY models routes schemas services data main.py ./
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.dockerignore(1 hunks)Dockerfile(1 hunks)README.md(1 hunks)
🧰 Additional context used
🪛 GitHub Check: Codeac Code Quality
Dockerfile
[warning] 9-9: DL3008
Pin versions in apt get install. Instead of apt-get install <package> use apt-get install <package>=<version>
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: container
- GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (10)
README.md (1)
51-52: Image tag updated correctlyThe build and run commands now use the new
python-samples-fastapi-restfultag, aligning the README with your Dockerfile changes.Also applies to: 57-58
Dockerfile (9)
1-2: Clear Stage 1 headerThe new comment clearly delineates the build stage for wheel creation, improving readability.
7-8: Explain system build tools installationThe added comments clarify why
build-essentialandgccare needed, aiding maintainability.
13-17: Pre-build wheels for deterministic installsGood use of
pip wheelto cache dependencies; this ensures reproducible and offline-capable installs.
18-18: Stage 2 header for runtime imageSeparating build and runtime stages with a clear comment enhances the Dockerfile’s structure.
38-41: Include README and assets for GHCR metadataCopying these files supports container registry pages—great for documentation.
42-45: Use a non-root user for securitySwitching to a dedicated
fastapiuser and updating ownership follows container security best practices.
47-49: Ensure unbuffered Python logsSetting
PYTHONUNBUFFERED=1guarantees immediate log output, which is helpful for real-time debugging.
50-52: Expose the correct portPort
9000matches the Uvicorn server’s configuration—consistent and clear.
53-55: Clear CMD for container startupThe
CMDsuccinctly documents how to launch Uvicorn with FastAPI in the container.



This change is
Summary by CodeRabbit
.dockerignorefile to optimize Docker builds by excluding unnecessary files and directories.