|
1 | | -FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim |
2 | | -SHELL ["/bin/bash", "-c"] |
| 1 | +FROM python:3.12-slim |
3 | 2 |
|
4 | | -# Configure environment |
5 | | -ENV UV_COMPILE_BYTECODE=1 \ |
6 | | - UV_LINK_MODE=copy \ |
7 | | - PYTHONUNBUFFERED=1 \ |
8 | | - VIRTUAL_ENV=/opt/venv \ |
9 | | - PATH="/opt/venv/bin:$PATH" \ |
10 | | - AWS_RETRY_MODE=adaptive \ |
11 | | - AWS_MAX_ATTEMPTS=10 \ |
12 | | - DEBIAN_FRONTEND=noninteractive |
13 | | - |
14 | | -WORKDIR /software/scallops |
15 | | - |
16 | | -# --- DEPENDENCY LAYER --- |
17 | | -COPY pyproject.toml setup.py requirements.txt requirements.cellpose.txt requirements.ufish.txt ./ |
18 | | - |
19 | | -ARG TF_PKG="tensorflow==2.19.0" |
20 | | - |
21 | | -RUN --mount=type=cache,target=/root/.cache/uv \ |
22 | | - --mount=type=cache,target=/var/cache/apt \ |
23 | | - --mount=type=cache,target=/var/lib/apt \ |
24 | | - set -eux; \ |
25 | | - # Install system dependencies |
26 | | - apt-get update && \ |
27 | | - apt-get install --no-install-recommends -y \ |
| 3 | +ENV AWS_RETRY_MODE=adaptive \ |
| 4 | + AWS_MAX_ATTEMPTS=10 |
| 5 | +RUN apt-get update -qq && \ |
| 6 | + apt-get install -qq --no-install-recommends -y \ |
28 | 7 | build-essential \ |
29 | 8 | git \ |
30 | | - ca-certificates && \ |
31 | | - # Create virtual environment |
32 | | - uv venv /opt/venv && \ |
33 | | - # Filter out tensorflow from requirements |
34 | | - grep -vE '^tensorflow(==|>=|<=|~=|!=)' requirements.txt > /tmp/requirements.no-tf.txt && \ |
35 | | - # Install Python dependencies |
36 | | - uv pip install --no-cache-dir \ |
37 | | - -r /tmp/requirements.no-tf.txt \ |
38 | | - -r requirements.cellpose.txt \ |
39 | | - -r requirements.ufish.txt \ |
40 | | - "${TF_PKG}" && \ |
41 | | - # Cleanup |
42 | | - apt-get remove -y build-essential git && \ |
43 | | - apt-get autoremove -y && \ |
44 | | - apt-get clean && \ |
45 | | - rm -rf /tmp/* /var/tmp/* |
46 | | - |
47 | | -# --- APPLICATION LAYER --- |
48 | | -COPY scallops scallops/ |
49 | | - |
50 | | -# Install the application itself |
51 | | -RUN --mount=type=bind,source=.git,target=.git \ |
52 | | - apt-get update && \ |
53 | | - apt-get install --no-install-recommends -y build-essential git && \ |
54 | | - # Install app in editable mode into the venv |
55 | | - uv pip install -e . && \ |
56 | | - apt-get remove -y build-essential git && \ |
57 | | - apt-get autoremove -y && \ |
58 | | - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* |
| 9 | + ca-certificates |
| 10 | +WORKDIR /app |
| 11 | +COPY requirements.txt requirements.ufish.txt ./ |
| 12 | +RUN pip install -q --no-cache-dir --upgrade pip && pip install -q --no-cache-dir -r requirements.txt |
| 13 | +RUN pip install -q --no-cache-dir -r requirements.ufish.txt |
| 14 | +COPY . ./ |
| 15 | +RUN pip install . |
| 16 | +RUN apt-get remove -qq -y build-essential git && \ |
| 17 | + apt-get autoremove -qq -y && apt-get clean -qq && \ |
| 18 | + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /app/ |
0 commit comments