You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My company does a two part build process in the docker image
We first install dependencies and then we build the image using a non root user
When using poetry we just copy the .venv folder to the new workdir in the image creation step and everything works fine. However when I do this with UV and run the app, I was getting issues bash: line 1: /app/.venv/bin/uvicorn: cannot execute: required file not found even though they are 100% there. After reviewing further I see it might be a symlink issue pointing to a path in first build that doesn't exist in second build. I tried setting link-mode to copy, but I assume the core issue here is I lack an understanding of what is really going on here.
Any advice would be greatly appreciated!
(WE do 2 part built for slight speed improvements, but isn't 100% necessary - seeing if we can just do it all in one go)
Here is a slimmed down version of what we are doing (using UV)
FROM python:3.11.4-bookworm AS build
ARG ENV
COPY --from=ghcr.io/astral-sh/uv:0.4.17 /uv /bin/uv
# SET ENV
ENV LIBRARY_PATH=/lib:/usr/lib
# Prepare install
WORKDIR /app
COPY pyproject.toml uv.lock ./
RUN uv sync --frozen --no-install-project
# Run second stage of build
FROM python:3.11.4-slim
RUN useradd --create-home appuser
# create /app directory and chown to to node user or else it will be owned by root
RUN mkdir -p /app && chown appuser:appuser /app
WORKDIR /app
ENV LIBRARY_PATH=/lib:/usr/lib
# Copy files from build stage
COPY --chown=appuser:appuser --from=build /app/.venv /app/.venv
COPY --chown=appuser:appuser . /app
ENV VIRTUAL_ENV=/app/.venv
ENV PATH="/app/.venv/bin:$PATH"
ENV PYTHONHASHSEED=0
USER lev
The text was updated successfully, but these errors were encountered:
My company does a two part build process in the docker image
We first install dependencies and then we build the image using a non root user
When using poetry we just copy the .venv folder to the new workdir in the image creation step and everything works fine. However when I do this with UV and run the app, I was getting issues
bash: line 1: /app/.venv/bin/uvicorn: cannot execute: required file not found
even though they are 100% there. After reviewing further I see it might be a symlink issue pointing to a path in first build that doesn't exist in second build. I tried setting link-mode to copy, but I assume the core issue here is I lack an understanding of what is really going on here.Any advice would be greatly appreciated!
(WE do 2 part built for slight speed improvements, but isn't 100% necessary - seeing if we can just do it all in one go)
Here is a slimmed down version of what we are doing (using UV)
The text was updated successfully, but these errors were encountered: