-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
51 lines (39 loc) · 1.34 KB
/
Dockerfile
File metadata and controls
51 lines (39 loc) · 1.34 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
# ---- Stage 1: Rust build ----
FROM rust:1.82-bookworm AS rust-builder
WORKDIR /build
COPY Cargo.toml Cargo.lock rust-toolchain.toml ./
COPY crates/ crates/
RUN cargo build --release
# ---- Stage 2: Frontend build ----
FROM node:22-alpine AS frontend-builder
WORKDIR /build
COPY frontend/package.json frontend/package-lock.json ./
RUN npm ci
COPY frontend/ .
RUN npm run build
# ---- Stage 3: Python runtime ----
FROM python:3.11-slim-bookworm
RUN apt-get update && apt-get install -y --no-install-recommends \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install maturin for building the Rust extension
RUN pip install --no-cache-dir maturin>=1.7
# Copy Rust build artifacts
COPY --from=rust-builder /build/target/release/lib_engine.so /tmp/engine.so
# Copy Python source and config
COPY pyproject.toml Cargo.toml Cargo.lock rust-toolchain.toml ./
COPY crates/ crates/
COPY src/ src/
# Build and install the Python package with Rust extension
RUN maturin build --release --out dist && \
pip install --no-cache-dir dist/*.whl && \
rm -rf dist
# Copy frontend build output
COPY --from=frontend-builder /build/dist /app/static
# Copy data and config files
COPY data/ data/
COPY alembic.ini alembic/
COPY alembic/ alembic/
EXPOSE 8000
CMD ["uvicorn", "biolab.api.app:create_app", "--factory", "--host", "0.0.0.0", "--port", "8000"]