|
1 | 1 | FROM python:3.11-slim AS base_image |
2 | 2 |
|
3 | 3 | FROM base_image AS builder |
4 | | -RUN apt update -y && apt install -y npm |
5 | | -RUN python -m pip install pip --upgrade && \ |
6 | | - pip install --upgrade setuptools && \ |
7 | | - pip install wheel build |
| 4 | +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ |
| 5 | + --mount=type=cache,target=/var/lib/apt,sharing=locked \ |
| 6 | + apt update -y && apt install --no-install-recommends -y npm |
8 | 7 | COPY getmarcapi /src/getmarcapi/ |
9 | 8 | COPY src /src/src/ |
10 | | -COPY pyproject.toml README.rst README.md setup.py MANIFEST.in requirements.txt /src/ |
11 | 9 | WORKDIR /src |
12 | 10 | COPY package.json package-lock.json webpack.config.js ./ |
13 | | -RUN npm install |
| 11 | +RUN --mount=type=cache,target=/root/.npm npm install |
| 12 | +RUN npm run env -- webpack --output-path=/output |
14 | 13 |
|
| 14 | +# |
15 | 15 | ARG PIP_INDEX_URL |
16 | 16 | ARG PIP_EXTRA_INDEX_URL |
17 | | -COPY requirements.txt ./requirements.txt |
18 | | -RUN pip wheel --wheel-dir=/wheels -r /src/requirements.txt |
19 | | -RUN python -m build --wheel --outdir /wheels |
| 17 | +COPY pyproject.toml uv.lock README.rst README.md setup.py MANIFEST.in /src/ |
| 18 | +RUN python -m pip install --disable-pip-version-check uv && \ |
| 19 | + uv build --wheel --out-dir /wheels |
20 | 20 |
|
21 | 21 | FROM base_image |
22 | | - |
23 | 22 | COPY --from=builder /wheels/*.whl /wheels/ |
24 | | -COPY requirements.txt ./requirements.txt |
25 | | -RUN pip install --find-links=/wheels --no-index -r requirements.txt |
26 | | -RUN pip install --find-links=/wheels --no-index getmarcapi |
27 | | -EXPOSE 5000 |
28 | 23 | WORKDIR /app |
| 24 | +COPY pyproject.toml uv.lock README.rst /app/ |
| 25 | +ARG PIP_INDEX_URL |
| 26 | +ARG UV_INDEX_URL |
| 27 | +ARG UV_CACHE_DIR=/.cache/uv |
| 28 | +ARG UV_EXTRA_INDEX_URL |
| 29 | +RUN --mount=type=cache,target=${UV_CACHE_DIR} \ |
| 30 | + python -m venv uv && \ |
| 31 | + ./uv/bin/pip install --disable-pip-version-check uv && \ |
| 32 | + ./uv/bin/uv sync --group deploy --no-dev --no-editable --no-install-project --find-links=/wheels && \ |
| 33 | + ./uv/bin/uv pip install --find-links=/wheels --no-index getmarcapi --no-deps |
| 34 | +EXPOSE 5000 |
29 | 35 | COPY api.cfg /app/settings.cfg |
30 | 36 | ENV GETMARCAPI_SETTINGS=/app/settings.cfg |
31 | | -RUN python -m getmarcapi --check |
32 | | -CMD gunicorn getmarcapi.app:app --bind 0.0.0.0:5000 --log-level=debug |
| 37 | +RUN ./.venv/bin/python -m getmarcapi --check |
| 38 | +CMD ./.venv/bin/gunicorn getmarcapi.app:app --bind 0.0.0.0:5000 --log-level=debug |
33 | 39 |
|
0 commit comments