Skip to content

Commit 4d565e8

Browse files
Update Dockerfile to use uv for building image
1 parent 60d605e commit 4d565e8

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

Dockerfile

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
FROM python:3.12 AS build
2-
3-
WORKDIR /tmp
4-
RUN pip install poetry
5-
COPY ./pyproject.toml ./poetry.lock /tmp/
6-
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
7-
81
FROM python:3.12-slim
92

103
WORKDIR /code
11-
COPY --from=build /tmp/requirements.txt /code/requirements.txt
12-
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
4+
5+
# Install the application dependencies.
6+
RUN --mount=from=ghcr.io/astral-sh/uv,source=/uv,target=/bin/uv \
7+
--mount=type=bind,source=uv.lock,target=uv.lock \
8+
--mount=type=bind,source=pyproject.toml,target=pyproject.toml \
9+
uv sync --frozen --no-cache
10+
11+
# Copy the application into the container.
1312
COPY ./app /code/app
1413

1514
RUN groupadd -r nonroot && useradd -r -g nonroot nonroot
1615
USER nonroot
1716

18-
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
17+
CMD ["/code/.venv/bin/uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]

0 commit comments

Comments
 (0)