docs `docker.md`: example to use bind mounts (#6921)

## Summary

Update the extended docker example to use bind mounts and avoid creating
extra layers and avoid copying files into layers

This is in line with the official Docker templates for Python
applications (you can try them out using `docker init`. I found them
very helpful!)
This commit is contained in:
David Bern 2024-09-03 09:36:54 -05:00 committed by GitHub
parent 37e25e2b1d
commit b7795024a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 6 deletions

View File

@ -366,18 +366,18 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
# Change the working directory to the `app` directory
WORKDIR /app
# Copy the lockfile and `pyproject.toml` into the image
ADD uv.lock /app/uv.lock
ADD pyproject.toml /app/pyproject.toml
# Install dependencies
RUN uv sync --frozen --no-install-project
RUN --mount=type=cache,target=/root/.cache/uv \
--mount=type=bind,source=uv.lock,target=uv.lock \
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
uv sync --frozen --no-install-project
# Copy the project into the image
ADD . /app
# Sync the project
RUN uv sync --frozen
RUN --mount=type=cache,target=/root/.cache/uv \
uv sync --frozen
```
Note that the `pyproject.toml` is required to identify the project root and name, but the project