Spaces:
Sleeping
Sleeping
Gokul Soumya
commited on
Commit
·
5272088
1
Parent(s):
4ed321b
build(binary-shield): HuggingFace docker space for demo
Browse files
Dockerfile
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.13-slim
|
| 2 |
+
|
| 3 |
+
# Install uv
|
| 4 |
+
COPY --from=ghcr.io/astral-sh/uv:0.8.13 /uv /bin/
|
| 5 |
+
|
| 6 |
+
# Set up user with ID 1000 (HF Spaces requirement)
|
| 7 |
+
RUN useradd -m -u 1000 user
|
| 8 |
+
|
| 9 |
+
# Switch to the user
|
| 10 |
+
USER user
|
| 11 |
+
|
| 12 |
+
# Set home to the user's home directory
|
| 13 |
+
ENV HOME=/home/user \
|
| 14 |
+
PATH=/home/user/.local/bin:$PATH
|
| 15 |
+
|
| 16 |
+
# Set the working directory to the user's home directory
|
| 17 |
+
WORKDIR $HOME/app
|
| 18 |
+
|
| 19 |
+
# Install system dependencies to speed up wheel building
|
| 20 |
+
USER root
|
| 21 |
+
RUN apt-get update && apt-get install -y \
|
| 22 |
+
gcc \
|
| 23 |
+
g++ \
|
| 24 |
+
libffi-dev \
|
| 25 |
+
libssl-dev \
|
| 26 |
+
build-essential \
|
| 27 |
+
curl \
|
| 28 |
+
&& apt-get clean \
|
| 29 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 30 |
+
|
| 31 |
+
# Switch back to user
|
| 32 |
+
USER user
|
| 33 |
+
|
| 34 |
+
# Use copy link mode to avoid warnings with cache mounts
|
| 35 |
+
ENV UV_LINK_MODE=copy
|
| 36 |
+
|
| 37 |
+
# Copy the binary-shield directory structure
|
| 38 |
+
COPY --chown=user . .
|
| 39 |
+
|
| 40 |
+
# Install dependencies first (intermediate layer for better caching)
|
| 41 |
+
# This layer will be cached and reused unless pyproject.toml changes
|
| 42 |
+
RUN --mount=type=cache,target=/home/user/.cache/uv \
|
| 43 |
+
uv sync --no-install-project --all-groups
|
| 44 |
+
|
| 45 |
+
# Install the project itself (this layer changes more frequently)
|
| 46 |
+
RUN --mount=type=cache,target=/home/user/.cache/uv \
|
| 47 |
+
uv sync --compile-bytecode --all-groups
|
| 48 |
+
|
| 49 |
+
# Expose port 7860 (HF Spaces default)
|
| 50 |
+
EXPOSE 7860
|
| 51 |
+
|
| 52 |
+
# Run the demo application
|
| 53 |
+
CMD ["uv", "run", "python", "demo.py"]
|
| 54 |
+
|
Justfile
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
set fallback
|
| 2 |
+
|
| 3 |
+
deploy-demo:
|
| 4 |
+
#!/usr/bin/env bash
|
| 5 |
+
cd ..
|
| 6 |
+
if ! git remote show hf-binary-shield-demo-space >/dev/null 2>&1; then
|
| 7 |
+
echo "Error: Remote 'hf-binary-shield-demo-space' does not exist."
|
| 8 |
+
echo "Add it with: git remote add hf-binary-shield-demo-space git@hf.co:spaces/sudormrfbin/binary-shield"
|
| 9 |
+
exit 1
|
| 10 |
+
fi
|
| 11 |
+
git subtree push --prefix=binary-shield hf-binary-shield-demo-space main
|
| 12 |
+
|
README.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
Implementation of the paper "Cross-Service Threat Intelligence in LLM Services using Privacy-Preserving Fingerprints".
|
| 2 |
|
| 3 |
https://arxiv.org/abs/2509.05608v1
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Binary Shield Demo
|
| 3 |
+
sdk: docker
|
| 4 |
+
app_port: 7860
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
Implementation of the paper "Cross-Service Threat Intelligence in LLM Services using Privacy-Preserving Fingerprints".
|
| 8 |
|
| 9 |
https://arxiv.org/abs/2509.05608v1
|
demo.py
CHANGED
|
@@ -327,4 +327,4 @@ def create_demo():
|
|
| 327 |
|
| 328 |
if __name__ == "__main__":
|
| 329 |
demo = create_demo()
|
| 330 |
-
demo.launch()
|
|
|
|
| 327 |
|
| 328 |
if __name__ == "__main__":
|
| 329 |
demo = create_demo()
|
| 330 |
+
demo.launch(server_name="0.0.0.0", server_port=7860)
|