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

DM-48977: Update Dockerfile to use uv #409

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,29 @@ RUN ./install-base-packages.sh && rm ./install-base-packages.sh

FROM base-image AS install-image

# Install uv.
COPY --from=ghcr.io/astral-sh/uv:0.6.1 /uv /bin/uv

# Install system packages only needed for building dependencies.
COPY scripts/install-dependency-packages.sh .
RUN ./install-dependency-packages.sh

# Create a Python virtual environment
ENV VIRTUAL_ENV=/opt/venv
RUN python -m venv $VIRTUAL_ENV
RUN uv venv $VIRTUAL_ENV

# Make sure we use the virtualenv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# Put the latest pip and setuptools in the virtualenv
RUN pip install --upgrade --no-cache-dir pip setuptools wheel

# Install the app's Python runtime dependencies
COPY requirements/main.txt ./requirements.txt
RUN pip install --quiet --no-cache-dir -r requirements.txt
RUN uv pip install --compile-bytecode --verify-hashes --no-cache \
-r requirements.txt

# Install the application.
COPY . /workdir
WORKDIR /workdir
RUN pip install --no-cache-dir .
RUN uv pip install --compile-bytecode --no-cache .

FROM base-image AS runtime-image

Expand All @@ -61,4 +62,4 @@ USER appuser
EXPOSE 8080

# Run the application.
CMD ["uvicorn", "mobu.main:create_app", "--host", "0.0.0.0", "--port", "8080"]
CMD ["uvicorn", "--factory", "mobu.main:create_app", "--host", "0.0.0.0", "--port", "8080"]
Loading