-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
83 lines (69 loc) · 2.7 KB
/
Dockerfile
File metadata and controls
83 lines (69 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# syntax=docker/dockerfile:1
#
# Multi-stage build for the nvisy-server binary.
#
# docker build -f docker/Dockerfile -t nvisy-server .
#
# Build context must be the repository root.
# Stage 1: Build
FROM rust:1.92-bookworm AS build
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Forward-compatible PyO3 ABI for any Python ≥ 3.7.
ENV PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1
# Dependency cache layer
# Copy only manifests + lock so dependency builds are cached until a
# Cargo.toml or Cargo.lock changes. Stub source files satisfy cargo.
COPY Cargo.toml Cargo.lock ./
COPY crates/nvisy-cli/Cargo.toml crates/nvisy-cli/Cargo.toml
COPY crates/nvisy-codec/Cargo.toml crates/nvisy-codec/Cargo.toml
COPY crates/nvisy-core/Cargo.toml crates/nvisy-core/Cargo.toml
COPY crates/nvisy-engine/Cargo.toml crates/nvisy-engine/Cargo.toml
COPY crates/nvisy-identify/Cargo.toml crates/nvisy-identify/Cargo.toml
COPY crates/nvisy-ocr/Cargo.toml crates/nvisy-ocr/Cargo.toml
COPY crates/nvisy-ontology/Cargo.toml crates/nvisy-ontology/Cargo.toml
COPY crates/nvisy-pattern/Cargo.toml crates/nvisy-pattern/Cargo.toml
COPY crates/nvisy-python/Cargo.toml crates/nvisy-python/Cargo.toml
COPY crates/nvisy-rig/Cargo.toml crates/nvisy-rig/Cargo.toml
COPY crates/nvisy-server/Cargo.toml crates/nvisy-server/Cargo.toml
# Stub lib.rs / main.rs + empty READMEs (every crate uses
# `include_str!("../README.md")`).
RUN set -e; \
for c in nvisy-codec nvisy-core nvisy-engine nvisy-identify \
nvisy-ocr nvisy-ontology nvisy-pattern nvisy-python \
nvisy-rig nvisy-server; do \
mkdir -p "crates/$c/src"; \
echo "" > "crates/$c/src/lib.rs"; \
touch "crates/$c/README.md"; \
done; \
mkdir -p crates/nvisy-cli/src; \
echo "fn main() {}" > crates/nvisy-cli/src/main.rs; \
touch crates/nvisy-cli/README.md
RUN cargo build --release 2>/dev/null || true
# Full build
COPY . .
RUN cargo build --release --bin nvisy-server
# Stage 2: Runtime
FROM debian:bookworm-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
python3 \
python3-pip \
python3-venv \
&& rm -rf /var/lib/apt/lists/*
# PDFium (PDF-to-image rendering)
COPY scripts/install-pdfium.sh /tmp/install-pdfium.sh
RUN /tmp/install-pdfium.sh && rm /tmp/install-pdfium.sh
# Python packages
COPY packages/ /opt/nvisy/packages/
RUN python3 -m pip install --break-system-packages --no-cache-dir \
/opt/nvisy/packages/nvisy-ai \
/opt/nvisy/packages/nvisy-exif
# Binary
COPY --from=build /app/target/release/nvisy-server /usr/local/bin/
EXPOSE 8080
ENTRYPOINT ["nvisy-server"]