-
Notifications
You must be signed in to change notification settings - Fork 427
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
Optimize backend docker image #1103
Merged
+39
−18
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
fcadbf2
Use multi-stage for backend image
thainguyensunya c833019
Use multi-stage for backend image
thainguyensunya 57e75cf
Add required packages for run stage
thainguyensunya 2d06f20
Utilize cache for docker build in Github action
thainguyensunya 23e7e33
Workaround no space left on device of GitHub-hosted runner
thainguyensunya 13fefe3
Upgrade google-github-actions/auth to v2
thainguyensunya 0dc67b1
Merge branch 'main' into optimize-backend-docker-image
thainguyensunya 288dc7b
Fix warning of docker build
thainguyensunya b4f56b9
Fix deprecated error of google-github-actions/deploy-cloudrun by upgr…
thainguyensunya 764c73a
Implement fix for comments in coderabbitai
thainguyensunya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
FROM tiangolo/uvicorn-gunicorn:python3.11 | ||
FROM python:3.11 AS builder | ||
|
||
RUN apt-get update && apt-get install --no-install-recommends --no-install-suggests -y curl | ||
RUN apt-get install unzip | ||
RUN apt-get -y install python3 | ||
RUN apt-get -y install python3-pip | ||
RUN apt-get -y install git | ||
RUN apt-get -y install ffmpeg | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
RUN python -m venv /opt/venv | ||
|
||
COPY backend/requirements.txt /tmp/requirements.txt | ||
RUN pip install --no-cache-dir -r /tmp/requirements.txt | ||
RUN pip install --no-cache-dir --upgrade -r /tmp/requirements.txt | ||
|
||
COPY backend/ /app | ||
FROM python:3.11-slim | ||
|
||
WORKDIR /app | ||
ENV PATH="/opt/venv/bin:$PATH" | ||
|
||
RUN apt-get update && apt-get -y install ffmpeg curl unzip && rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /opt/venv /opt/venv | ||
COPY backend/ . | ||
|
||
EXPOSE 8080 | ||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"] | ||
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080"] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
Consider using 'python:3.11-slim' in the builder stage for consistency and reduced image size
Since you're using
python:3.11-slim
in the final stage, you might consider using it in the builder stage as well to maintain consistency and potentially reduce the overall image size. Ensure that all necessary build tools and libraries are available in the slim image for successful dependency installation.Apply this diff to implement the suggestion:
📝 Committable suggestion