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

Add --system flag to uv sync command to use it in Docker #7344

Closed
rfsan opened this issue Sep 12, 2024 · 2 comments
Closed

Add --system flag to uv sync command to use it in Docker #7344

rfsan opened this issue Sep 12, 2024 · 2 comments
Labels
duplicate This issue or pull request already exists question Asking for clarification or support

Comments

@rfsan
Copy link

rfsan commented Sep 12, 2024

I have the current Dockerfile

FROM python:3.12-slim
ENV PYTHONUNBUFFERED=1
RUN apt-get update && \
    apt-get install -y git libgomp1 && \
    rm -rf /var/lib/apt/lists/*
ARG CODE=/app
WORKDIR $CODE
COPY pyproject.toml uv.lock ./
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
    uv sync --frozen --no-cache --compile-bytecode --no-dev
COPY src/ src/
CMD [".venv/bin/python", "-m", "src.api_sample"]

I would like to install the dependencies using the system Python so that the final command is CMD ["python", "-m", "src.api_sample"]

I tried using uv pip install -r pyproject.toml --system but this approach does not use the uv.lock file

@Xdynix
Copy link

Xdynix commented Sep 12, 2024

To force uv to use the system Python, provide the --python-preference only-system option.

Maybe consider this?

Ref: https://docs.astral.sh/uv/concepts/python-versions/#adjusting-python-version-preferences

@zanieb
Copy link
Member

zanieb commented Sep 13, 2024

@zanieb zanieb closed this as completed Sep 13, 2024
@zanieb zanieb added question Asking for clarification or support duplicate This issue or pull request already exists labels Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

3 participants