-
Notifications
You must be signed in to change notification settings - Fork 18
Closed
Labels
containersPull requests that update containers codePull requests that update containers codeenhancementNew feature or requestNew feature or request
Description
Background
In PR #342, a multi-stage Dockerfile was introduced for the FastAPI application. The current implementation duplicates the pip install step in both the build and runtime stages.
Suggested Improvement
Leverage the build stage to prepare wheels, then install from that wheelhouse in the runtime stage to speed up builds and reduce image size.
Proposed Changes
# In the build stage:
-COPY requirements.txt .
-RUN pip install --no-cache-dir -r requirements.txt
+COPY requirements.txt .
+RUN pip wheel --no-cache --no-deps -r requirements.txt -w /app/wheelhouse
# In the runtime stage:
-COPY requirements.txt .
-RUN pip install --no-cache-dir -r requirements.txt
+COPY requirements.txt .
+COPY --from=build /app/wheelhouse /app/wheelhouse
+RUN pip install --no-cache-dir --no-index --find-links /app/wheelhouse -r requirements.txtBenefits
- Faster build times
- Reduced image size
- Better caching in CI/CD pipelines
References
Metadata
Metadata
Assignees
Labels
containersPull requests that update containers codePull requests that update containers codeenhancementNew feature or requestNew feature or request