Yes—you need all workspace members present for uv sync --locked to work, since the lockfile covers the full workspace. A common approach is to copy everything first, run uv sync, then slim down the image with a multi-stage build.
uv sync --locked
uv sync