|
1 | | -# Build: docker build -t fingr . |
| 1 | +# Build: docker build -t fingr -f Dockerfile.ubuntu . |
2 | 2 | # Run: docker run -it --rm fingr:latest |
3 | | -# Distroless image for minimal attack surface and security |
4 | 3 |
|
5 | | -# Build stage. Python 3.11 to match distroless debian12 |
6 | | -FROM python:3.11-slim AS builder |
| 4 | +FROM ubuntu:24.04 |
| 5 | +COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/ |
7 | 6 |
|
8 | | -WORKDIR /app |
9 | | - |
10 | | -# Install uv and build dependencies for numpy |
11 | | -COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv |
12 | | - |
13 | | -# Install system dependencies needed for numpy |
14 | | -RUN apt-get update && \ |
15 | | - apt-get install -y --no-install-recommends \ |
| 7 | +RUN apt-get update && apt-get install -y \ |
16 | 8 | gcc \ |
17 | 9 | g++ \ |
18 | 10 | libgfortran5 \ |
19 | | - libgomp1 |
| 11 | + libgomp1 \ |
| 12 | + cl-cffi \ |
| 13 | + && apt-get clean && rm -rf /var/lib/apt/lists/* |
| 14 | + |
| 15 | +WORKDIR /app |
| 16 | +RUN useradd --home-dir=/app fingr && chown -R fingr /app |
| 17 | +USER fingr |
20 | 18 |
|
21 | | -# Copy project files |
22 | | -COPY pyproject.toml . |
23 | | -COPY fingr/ fingr/ |
24 | | -COPY fingr.py . |
| 19 | +COPY pyproject.toml uv.lock . |
25 | 20 |
|
26 | 21 | # Install dependencies with uv |
27 | 22 | # UV_COMPILE_BYTECODE: Precompile Python files to .pyc for faster startup |
28 | 23 | ENV UV_COMPILE_BYTECODE=1 \ |
29 | | - UV_LINK_MODE=copy |
| 24 | + UV_LINK_MODE=copy \ |
| 25 | + UV_NO_DEV=1 |
30 | 26 |
|
31 | | -RUN uv pip install --system --no-cache . |
| 27 | +RUN uv python install 3.14 |
| 28 | +RUN uv sync --locked --no-cache |
32 | 29 |
|
33 | | -# Runtime stage - distroless |
34 | | -FROM gcr.io/distroless/python3-debian12:nonroot |
35 | | - |
36 | | -# Copy required shared libraries from builder for numpy C extensions |
37 | | -COPY --from=builder /usr/lib/x86_64-linux-gnu/libgfortran.so.5* /usr/lib/x86_64-linux-gnu/ |
38 | | -COPY --from=builder /usr/lib/x86_64-linux-gnu/libquadmath.so.0* /usr/lib/x86_64-linux-gnu/ |
39 | | -COPY --from=builder /usr/lib/x86_64-linux-gnu/libgomp.so.1* /usr/lib/x86_64-linux-gnu/ |
40 | | -COPY --from=builder /lib/x86_64-linux-gnu/libgcc_s.so.1* /lib/x86_64-linux-gnu/ |
41 | | - |
42 | | -# Copy Python packages and application |
43 | | -COPY --from=builder /usr/local/lib/python3.11/site-packages /usr/local/lib/python3.11/site-packages |
44 | | -COPY fingr/ /app/fingr/ |
45 | | -COPY fingr.py /app/ |
46 | | - |
47 | | -WORKDIR /app |
48 | | -ENV PYTHONPATH=/usr/local/lib/python3.11/site-packages |
| 30 | +COPY fingr.py ./ |
| 31 | +COPY fingr/ ./fingr/ |
49 | 32 |
|
50 | 33 | EXPOSE 7979 |
51 | | -ENTRYPOINT ["/usr/bin/python3", "fingr.py", "--verbose", "--host", "0.0.0.0"] |
| 34 | +ENTRYPOINT ["uv", "run", "--no-cache", "./fingr.py", "--verbose", "--host", "0.0.0.0"] |
0 commit comments