diff --git a/Dockerfile b/Dockerfile index cf6e871c..176ca4b2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,23 @@ FROM python:3.10-bullseye WORKDIR /app -COPY requirements-dev.txt requirements-dev.txt -RUN pip --no-cache-dir install --ignore-installed distlib -r requirements-dev.txt -RUN pip install gunicorn -RUN pip install uvicorn -RUN apt-get update && apt-get install -y postgresql-client + +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ + +# Install the project's dependencies using the lockfile and settings +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 + +# Then, add the rest of the project source code and install it +# Installing separately from its dependencies allows optimal layer caching COPY . . +RUN --mount=type=cache,target=/root/.cache/uv \ + uv sync --frozen +# Place executables in the environment at the front of the path +ENV PATH="/app/.venv/bin:$PATH" EXPOSE 8080 + CMD ["gunicorn", "--worker-class", "uvicorn.workers.UvicornWorker", "wsgi:app", "-b", "0.0.0.0:8080"]