|
| 1 | +# syntax=docker/dockerfile:1.4 |
| 2 | + |
| 3 | +############################################################### |
| 4 | +# Base stage, with the non-python runtime dependencies, and uv. |
| 5 | +# |
| 6 | + |
| 7 | +FROM ghcr.io/acsone/odoo-bedrock:14.0-py39-focal-latest AS base |
| 8 | + |
| 9 | +# Install apt runtime dependencies. |
| 10 | +RUN set -e \ |
| 11 | + && apt update \ |
| 12 | + && apt -y install --no-install-recommends \ |
| 13 | + postgresql-client \ |
| 14 | + && apt -y clean \ |
| 15 | + && rm -rf /var/lib/apt/lists/* |
| 16 | + |
| 17 | +# Install uv, and configure it for optimal usage in Dockerfile. |
| 18 | +COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv |
| 19 | +ENV UV_PROJECT_ENVIRONMENT=$VIRTUAL_ENV |
| 20 | +ENV UV_LINK_MODE=copy |
| 21 | +ENV UV_COMPILE_BYTECODE=1 |
| 22 | + |
| 23 | +############################################################### |
| 24 | +# Dependencies stage, where we install tools necessary to build |
| 25 | +# source distributions, and install all the locked dependencies |
| 26 | +# in the virtual environment. |
| 27 | +# |
| 28 | + |
| 29 | +FROM base AS dependencies |
| 30 | + |
| 31 | +# Install git and other build tools. |
| 32 | +RUN set -e \ |
| 33 | + && apt update \ |
| 34 | + && apt -y install --no-install-recommends \ |
| 35 | + git \ |
| 36 | + python3.9-dev \ |
| 37 | + build-essential \ |
| 38 | + libpq-dev \ |
| 39 | + && apt -y clean \ |
| 40 | + && rm -rf /var/lib/apt/lists/* |
| 41 | + |
| 42 | +# Install the locked dependencies in the virtual environment, |
| 43 | +# but not the project |
| 44 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 45 | + --mount=type=bind,source=uv.lock,target=uv.lock \ |
| 46 | + --mount=type=bind,source=pyproject.toml,target=pyproject.toml \ |
| 47 | + uv sync --frozen --no-install-project |
| 48 | + |
| 49 | +############################################################### |
| 50 | +# In this runtime stage, we install the app in editable mode, |
| 51 | +# on top of dependencies. |
| 52 | +# |
| 53 | + |
| 54 | +FROM base AS runtime |
| 55 | + |
| 56 | +COPY --from=dependencies $VIRTUAL_ENV $VIRTUAL_ENV |
| 57 | + |
| 58 | +# Install the app |
| 59 | +COPY . /app |
| 60 | +WORKDIR /app |
| 61 | +RUN python -m compileall . |
| 62 | +RUN --mount=type=cache,target=/root/.cache/uv \ |
| 63 | + uv sync --locked --no-dev |
0 commit comments