This repository was archived by the owner on Jun 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
feat: create Dockerfile for shipping codegate as image #113
Merged
Changes from all commits
Commits
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 hidden or 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Builder stage: Install dependencies and build the application | ||
FROM python:3.12-slim AS builder | ||
|
||
# Install system dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
gcc \ | ||
g++ \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Set environment variable to ensure Python modules are installed in the correct location | ||
ENV PYTHONPATH=/app | ||
|
||
# Install Poetry | ||
RUN pip install poetry==1.8.4 | ||
|
||
# Create a non-root user and switch to it | ||
RUN adduser --system --no-create-home codegate --uid 1000 | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Copy only the files needed for installing dependencies | ||
COPY pyproject.toml poetry.lock* /app/ | ||
|
||
# Configure Poetry and install dependencies | ||
RUN poetry config virtualenvs.create false && \ | ||
poetry install --no-dev | ||
|
||
# Copy the rest of the application | ||
COPY . /app | ||
|
||
# Runtime stage: Create the final lightweight image | ||
FROM python:3.12-slim AS runtime | ||
|
||
# Install runtime system dependencies | ||
RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
libgomp1 \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Create a non-root user and switch to it | ||
RUN adduser --system --no-create-home codegate --uid 1000 | ||
USER codegate | ||
|
||
# Copy necessary artifacts from the builder stage | ||
COPY --from=builder /usr/local/lib/python3.12/site-packages /usr/local/lib/python3.12/site-packages | ||
COPY --from=builder /app /app | ||
|
||
# Set the working directory | ||
WORKDIR /app | ||
|
||
# Set the PYTHONPATH environment variable | ||
ENV PYTHONPATH=/app/src | ||
|
||
# Allow to expose weaviate_data volume | ||
VOLUME ["/app/weaviate_data"] | ||
|
||
# Set the container's default entrypoint | ||
EXPOSE 8989 | ||
#ENTRYPOINT ["python", "-m", "src.codegate.cli", "serve", "--port", "8989", "--host", "0.0.0.0"] | ||
CMD ["python", "-m", "src.codegate.cli", "serve", "--port", "8989", "--host", "0.0.0.0"] |
This file contains hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
I'm not a 100% sure. But I think that if we copy the complete application into the
app
directory and then runpoetry install --no-dev
it should installcodegate
module. In other words, doingWould already enable us to do
from codegate. # import whatever submodule
This has the benefit that we would avoid changing the
PYTHONPATH
further down the fileIt's just a nit I noticed. I think as it is it should do the trick