1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Do I have to copy every workspace member in the Dockerfile to be able to use `uv sync...

Discussão em 'Python' iniciado por Stack, Setembro 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm currently in the process of migrating an existing codebase in my org to use uv as a package manager. It's a monorepo and having the ability to setup workspaces within a single repo was amazing. I'm still running into an issue for building a Docker image with the uv.lock file.

    Below is my folder structure.

    org-backend
    └── src
    └── base
    └── ..
    └── pyproject.toml
    └── bo
    └── ..
    └── pyproject.toml
    └── application
    └── ..
    └── pyproject.toml
    └── pyproject.toml


    Here's the root pyproject.toml

    [project]
    name = "org-backend"
    version = "0.1.0"
    description = ".."
    readme = "README.md"
    requires-python = "==3.12.*"

    [tool.uv.workspace]
    members = ["src/base", "src/bo", "application"]


    The root pyproject.toml contains base,bo and application as a workspace member. While building the Docker image for application service, I only copy the following /src/base and /application.

    # Dockerfile for application
    RUN pip install uv==0.8.17

    COPY ./src/base /org-backend/src/base

    COPY application /org-backend/application

    COPY pyproject.toml /org-backend/
    COPY uv.lock /org-backend/


    WORKDIR /org-backend
    RUN uv sync --locked --active --no-group dev --package application


    Here's the error message when building with above docker file, The lockfile at 'uv.lock' needs to be updated, but '--locked' was provided. To update the lockfile, run 'uv lock'.

    My question is do I have to copy every workspace member? If not, what would be the best approach to build an image?

    If yes, this is going to be a hassle since I have 4-5 packages and over 15 services. Everything will be defined as a workspace member and the 15 services will not even be related to each other. Having to copy every workspace member is going to wreak havoc and also contain unnecessary code!

    Continue reading...

Compartilhe esta Página