Spaces:
Sleeping
Sleeping
Claude commited on
Make the app deployable as a Hugging Face Docker Space
Browse files- README.md: add HF Space YAML frontmatter (sdk: docker, app_port: 8000) and
a "Deploy to Hugging Face Spaces" section.
- Dockerfile: run as non-root user 1000 (HF best practice), copy app with
--chown, keep QPDF/libxml baked in; serves on port 8000.
- .dockerignore: trim the runtime image (drop .git, tests, scripts, docs).
Reuses the existing FastAPI backend + single-page UI unchanged. Smoke test
still green (7/7) against a local server.
- .dockerignore +17 -0
- Dockerfile +10 -4
- README.md +36 -0
.dockerignore
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.git
|
| 2 |
+
.gitignore
|
| 3 |
+
__pycache__/
|
| 4 |
+
*.py[cod]
|
| 5 |
+
.venv/
|
| 6 |
+
venv/
|
| 7 |
+
.env
|
| 8 |
+
.DS_Store
|
| 9 |
+
.idea/
|
| 10 |
+
.vscode/
|
| 11 |
+
backend/_work/
|
| 12 |
+
|
| 13 |
+
# Not needed inside the runtime image
|
| 14 |
+
tests/
|
| 15 |
+
scripts/
|
| 16 |
+
docker-compose.yml
|
| 17 |
+
*.md
|
Dockerfile
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
|
|
| 1 |
FROM python:3.12-slim
|
| 2 |
|
| 3 |
-
# pikepdf needs QPDF
|
| 4 |
RUN apt-get update \
|
| 5 |
&& apt-get install -y --no-install-recommends \
|
| 6 |
qpdf \
|
|
@@ -8,14 +9,19 @@ RUN apt-get update \
|
|
| 8 |
libxslt1.1 \
|
| 9 |
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
WORKDIR /app
|
| 12 |
|
| 13 |
COPY requirements.txt ./
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
| 16 |
-
COPY backend ./backend
|
| 17 |
-
COPY frontend ./frontend
|
| 18 |
-
COPY tools ./tools
|
|
|
|
|
|
|
| 19 |
|
| 20 |
EXPOSE 8000
|
| 21 |
|
|
|
|
| 1 |
+
# Hugging Face Spaces-compatible image (SDK: docker, app_port: 8000).
|
| 2 |
FROM python:3.12-slim
|
| 3 |
|
| 4 |
+
# pikepdf needs QPDF; lxml needs libxml2/libxslt. Installed as root at build.
|
| 5 |
RUN apt-get update \
|
| 6 |
&& apt-get install -y --no-install-recommends \
|
| 7 |
qpdf \
|
|
|
|
| 9 |
libxslt1.1 \
|
| 10 |
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
+
# Run as a non-root user (Hugging Face Spaces best practice).
|
| 13 |
+
RUN useradd -m -u 1000 user
|
| 14 |
+
|
| 15 |
WORKDIR /app
|
| 16 |
|
| 17 |
COPY requirements.txt ./
|
| 18 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 19 |
|
| 20 |
+
COPY --chown=user backend ./backend
|
| 21 |
+
COPY --chown=user frontend ./frontend
|
| 22 |
+
COPY --chown=user tools ./tools
|
| 23 |
+
|
| 24 |
+
USER user
|
| 25 |
|
| 26 |
EXPOSE 8000
|
| 27 |
|
README.md
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# PPTX / PDF Accessibility Tools
|
| 2 |
|
| 3 |
Tools for remediating PowerPoint and PDF files (caps, language tags, math
|
| 4 |
variables, reading order, footers, metadata, HTML export). Usable both as
|
| 5 |
command-line scripts and through an internal web app.
|
| 6 |
|
|
|
|
|
|
|
|
|
|
| 7 |
## Web app
|
| 8 |
|
| 9 |
A FastAPI backend wraps each tool's existing core function (in `tools/`) and a
|
|
@@ -37,6 +50,29 @@ scripts/smoke_test.sh http://localhost:8000 # HTTP checks against a running se
|
|
| 37 |
scripts/docker_smoke.sh # build image, run container, smoke test, tear down
|
| 38 |
```
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
## Command-line setup (once)
|
| 41 |
|
| 42 |
```bash
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: PPTX PDF Accessibility Tools
|
| 3 |
+
emoji: ♿
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 8000
|
| 8 |
+
pinned: false
|
| 9 |
+
---
|
| 10 |
+
|
| 11 |
# PPTX / PDF Accessibility Tools
|
| 12 |
|
| 13 |
Tools for remediating PowerPoint and PDF files (caps, language tags, math
|
| 14 |
variables, reading order, footers, metadata, HTML export). Usable both as
|
| 15 |
command-line scripts and through an internal web app.
|
| 16 |
|
| 17 |
+
> The YAML block above configures a [Hugging Face Space](https://huggingface.co/docs/hub/spaces-sdks-docker)
|
| 18 |
+
> (Docker SDK, served on port 8000). See **Deploy to Hugging Face Spaces** below.
|
| 19 |
+
|
| 20 |
## Web app
|
| 21 |
|
| 22 |
A FastAPI backend wraps each tool's existing core function (in `tools/`) and a
|
|
|
|
| 50 |
scripts/docker_smoke.sh # build image, run container, smoke test, tear down
|
| 51 |
```
|
| 52 |
|
| 53 |
+
### Deploy to Hugging Face Spaces
|
| 54 |
+
|
| 55 |
+
This repo is a ready-to-run Docker Space. The `README.md` YAML header sets
|
| 56 |
+
`sdk: docker` and `app_port: 8000`; the `Dockerfile` builds the FastAPI app
|
| 57 |
+
(with QPDF baked in) and serves the same web UI.
|
| 58 |
+
|
| 59 |
+
1. Create a new Space: https://huggingface.co/new-space → **SDK: Docker**
|
| 60 |
+
(blank template).
|
| 61 |
+
2. Push this repository to the Space's git remote:
|
| 62 |
+
```bash
|
| 63 |
+
git remote add space https://huggingface.co/spaces/<user>/<space-name>
|
| 64 |
+
git push space <your-branch>:main
|
| 65 |
+
```
|
| 66 |
+
(Spaces build from the `main` branch.)
|
| 67 |
+
3. The Space builds the image and serves the app on port 8000 — open the
|
| 68 |
+
Space URL and the tool UI loads.
|
| 69 |
+
|
| 70 |
+
Notes:
|
| 71 |
+
- No persistent storage is needed: uploads and results live in `/tmp` and are
|
| 72 |
+
cleaned up after download (and swept after an hour).
|
| 73 |
+
- There's no auth — keep the Space **private** if the files aren't public.
|
| 74 |
+
(A clean seam to add token/SSO auth later is described in the project notes.)
|
| 75 |
+
|
| 76 |
## Command-line setup (once)
|
| 77 |
|
| 78 |
```bash
|