Spaces:
Build error
Build error
Update Dockerfile
Browse files- Dockerfile +48 -12
Dockerfile
CHANGED
|
@@ -1,24 +1,60 @@
|
|
| 1 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
# ---
|
| 4 |
-
FROM node:20-
|
| 5 |
WORKDIR /app/frontend
|
| 6 |
-
# Copy package files first for caching
|
| 7 |
COPY frontend/package*.json ./
|
| 8 |
RUN npm install
|
| 9 |
-
# Copy the rest of the frontend files
|
| 10 |
COPY frontend/ ./
|
| 11 |
-
# This will now run 'vite build' without failing on type checks
|
| 12 |
RUN npm run build
|
| 13 |
|
| 14 |
-
# ---
|
| 15 |
FROM debian:bookworm-slim
|
| 16 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
#
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
EXPOSE 7860
|
|
|
|
|
|
|
| 24 |
CMD ["./polymorphic-agent"]
|
|
|
|
| 1 |
+
# --- STAGE 1: Build Rust Backend ---
|
| 2 |
+
FROM rust:1.84-bookworm AS backend_build
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
RUN apt-get update && apt-get install -y pkg-config libssl-dev
|
| 5 |
+
COPY Cargo.toml ./
|
| 6 |
+
# Build dependencies only (caching)
|
| 7 |
+
RUN mkdir src && echo "fn main() {}" > src/main.rs && cargo build --release
|
| 8 |
+
# Build actual source
|
| 9 |
+
COPY src ./src
|
| 10 |
+
RUN touch src/main.rs && cargo build --release
|
| 11 |
|
| 12 |
+
# --- STAGE 2: Build React Frontend ---
|
| 13 |
+
FROM node:20-bookworm AS frontend_build
|
| 14 |
WORKDIR /app/frontend
|
|
|
|
| 15 |
COPY frontend/package*.json ./
|
| 16 |
RUN npm install
|
|
|
|
| 17 |
COPY frontend/ ./
|
|
|
|
| 18 |
RUN npm run build
|
| 19 |
|
| 20 |
+
# --- STAGE 3: Final Runtime (Nix + Agent) ---
|
| 21 |
FROM debian:bookworm-slim
|
| 22 |
+
# Install system tools and browser libs
|
| 23 |
+
RUN apt-get update && apt-get install -y \
|
| 24 |
+
curl xz-utils wget ca-certificates procps \
|
| 25 |
+
libssl3 libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \
|
| 26 |
+
libdbus-1-3 libexpat1 libfontconfig1 libgbm1 libgcc1 \
|
| 27 |
+
libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 \
|
| 28 |
+
libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 \
|
| 29 |
+
libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
|
| 30 |
+
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 \
|
| 31 |
+
libxrandr2 libxrender1 libxss1 libxtst6 \
|
| 32 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 33 |
|
| 34 |
+
# Setup non-root user for Hugging Face
|
| 35 |
+
RUN useradd -m -u 1000 user
|
| 36 |
+
USER user
|
| 37 |
+
ENV HOME=/home/user
|
| 38 |
+
WORKDIR /home/user
|
| 39 |
|
| 40 |
+
# Install Nix in single-user mode
|
| 41 |
+
RUN curl -L https://nixos.org/nix/install | sh -s -- --no-daemon
|
| 42 |
+
ENV PATH="/home/user/.nix-profile/bin:${PATH}"
|
| 43 |
+
ENV NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz
|
| 44 |
+
|
| 45 |
+
# Copy the Rust binary from STAGE 1
|
| 46 |
+
COPY --from=backend_build /app/target/release/polymorphic-agent .
|
| 47 |
+
|
| 48 |
+
# Copy the Frontend dist from STAGE 2
|
| 49 |
+
# Axum will serve this folder
|
| 50 |
+
COPY --from=frontend_build /app/frontend/dist ./frontend/dist
|
| 51 |
+
|
| 52 |
+
# Create dynamic UI folder for the agent to write to
|
| 53 |
+
RUN mkdir -p ./frontend/src/dynamic
|
| 54 |
+
|
| 55 |
+
# Set environment variables
|
| 56 |
+
ENV PORT=7860
|
| 57 |
EXPOSE 7860
|
| 58 |
+
|
| 59 |
+
# Start the agent
|
| 60 |
CMD ["./polymorphic-agent"]
|