FROM rust:1.82-slim AS builder WORKDIR /build # Copy workspace COPY Cargo.toml Cargo.lock ./ COPY apps/ apps/ COPY libs/ libs/ COPY vendor/ vendor/ # Build backend only RUN apt-get update && apt-get install -y pkg-config libssl-dev liblmdb-dev && \ cargo build --release -p backend # Runtime FROM debian:bookworm-slim RUN apt-get update && apt-get install -y nginx ca-certificates && rm -rf /var/lib/apt/lists/* COPY --from=builder /build/target/release/backend /usr/local/bin/backend # Static files COPY static/ /var/www/html/ # Nginx: static on 7860, proxy /api/ to backend RUN cat > /etc/nginx/sites-available/default <<'EOF' server { listen 7860; root /var/www/html; index index.html; location / { try_files $uri $uri/ =404; add_header Access-Control-Allow-Origin *; } location /catalog/ { autoindex on; add_header Access-Control-Allow-Origin *; } location /api/ { proxy_pass https://127.0.0.1:8443/api/; proxy_ssl_verify off; } location /health { proxy_pass https://127.0.0.1:8443/health; proxy_ssl_verify off; } } EOF COPY start.sh /start.sh RUN chmod +x /start.sh EXPOSE 7860 CMD ["/start.sh"]