# Use rust image with all tools included FROM rust:1.90-alpine # Install build and runtime dependencies RUN apk add --no-cache \ musl-dev \ pkgconfig \ openssl-dev \ openssl-libs-static \ ca-certificates # Create app user RUN addgroup -g 1001 -S appgroup && \ adduser -S appuser -u 1001 -G appgroup # Set working directory WORKDIR /app # Copy source code COPY . . # Change ownership to app user before building RUN chown -R appuser:appgroup /app # Switch to non-root user USER appuser # Set environment variables for proper Rust compilation ENV CARGO_TARGET_DIR=/app/target ENV CARGO_HOME=/app/.cargo # Expose the default port EXPOSE 7860 # Set environment variables ENV RUST_LOG=info ENV API_HOST=0.0.0.0 ENV API_PORT=7860 # Run the application using cargo run CMD ["cargo", "run", "--bin", "api_server", "--", "--no-proxy"]