File size: 942 Bytes
92d98e6
3fbe6f7
 
92d98e6
3fbe6f7
 
 
 
 
92d98e6
3fbe6f7
 
92d98e6
 
 
3fbe6f7
92d98e6
 
 
 
 
3fbe6f7
 
92d98e6
 
 
 
 
 
 
 
 
 
 
 
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

# Stage 1: Build the Rust core library in a full-featured environment
FROM python:3.9 as builder

# Install rustup and the Rust toolchain
ENV RUSTUP_HOME=/usr/local/rustup \
    CARGO_HOME=/usr/local/cargo \
    PATH=/usr/local/cargo/bin:$PATH
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y

# Copy the Rust project and build it
WORKDIR /app
COPY laa_core /app/laa_core
RUN cd laa_core && cargo build --release

# Stage 2: Create the final, minimal production image
FROM python:3.9-slim

WORKDIR /app

# Install Python dependencies
COPY requirements-hf.txt .
RUN pip install --no-cache-dir -r requirements-hf.txt

# Copy the built Rust library from the builder stage
COPY --from=builder /app/laa_core/target/release/liblaa_core.so /app/laa_core.so

# Copy the application code
COPY app.py .

# Expose the port Gradio runs on
EXPOSE 7860

# Run the Gradio app
CMD ["gradio", "app.py", "--server_name", "0.0.0.0"]