feat: add Docker configuration for Hugging Face Spaces deployment
Browse files- .dockerignore +21 -0
- Dockerfile +31 -0
- commit_msg.txt +0 -7
- design.md +5 -3
- docker-compose.yaml +12 -0
- requirements.txt +1 -0
.dockerignore
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python ignores
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
venv/
|
| 6 |
+
.env
|
| 7 |
+
|
| 8 |
+
# Project specific
|
| 9 |
+
examples/rpg_character_config.json
|
| 10 |
+
*.png
|
| 11 |
+
comfy_node_info.json
|
| 12 |
+
|
| 13 |
+
# Tooling
|
| 14 |
+
.vscode/
|
| 15 |
+
.idea/
|
| 16 |
+
.git/
|
| 17 |
+
commit_msg.txt
|
| 18 |
+
|
| 19 |
+
# OS
|
| 20 |
+
.DS_Store
|
| 21 |
+
Thumbs.db
|
Dockerfile
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Use official Python image
|
| 2 |
+
FROM python:3.10-slim
|
| 3 |
+
|
| 4 |
+
# Set working directory
|
| 5 |
+
WORKDIR /app
|
| 6 |
+
|
| 7 |
+
# Create a non-root user (Hugging Face standard)
|
| 8 |
+
RUN useradd -m -u 1000 user
|
| 9 |
+
USER user
|
| 10 |
+
ENV HOME=/home/user \
|
| 11 |
+
PATH=/home/user/.local/bin:$PATH
|
| 12 |
+
|
| 13 |
+
# Set working directory to app and ensure ownership
|
| 14 |
+
WORKDIR $HOME/app
|
| 15 |
+
|
| 16 |
+
# Copy requirements and install
|
| 17 |
+
COPY --chown=user requirements.txt .
|
| 18 |
+
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 19 |
+
|
| 20 |
+
# Copy the rest of the application
|
| 21 |
+
COPY --chown=user . .
|
| 22 |
+
|
| 23 |
+
# Hugging Face Spaces standard port
|
| 24 |
+
EXPOSE 7860
|
| 25 |
+
|
| 26 |
+
# Set environment variables for Gradio to run on 0.0.0.0:7860
|
| 27 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0" \
|
| 28 |
+
GRADIO_SERVER_PORT=7860
|
| 29 |
+
|
| 30 |
+
# Command to run the application
|
| 31 |
+
CMD ["python", "app.py"]
|
commit_msg.txt
DELETED
|
@@ -1,7 +0,0 @@
|
|
| 1 |
-
refactor: modularize codebase and reorganize utilities
|
| 2 |
-
|
| 3 |
-
- Split monolithic app.py into modules/config.py, modules/integrations.py, modules/core_logic.py, and modules/ui_layout.py.
|
| 4 |
-
- Consolited ComfyUI utilities into a dedicated comfy/ directory.
|
| 5 |
-
- Updated imports to use the new package structure.
|
| 6 |
-
- Enhanced .gitignore to include __pycache__ and temporary character saves.
|
| 7 |
-
- Documented new architecture and safer port management in design.md.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
design.md
CHANGED
|
@@ -67,6 +67,8 @@ The app uses a 3-stage prompt pipeline:
|
|
| 67 |
- **`modules/ui_layout.py`**: The full Gradio UI definition (`build_ui`).
|
| 68 |
- **`comfy/`**: Dedicated folder for ComfyUI-specific JSON workflows and utility scripts.
|
| 69 |
|
| 70 |
-
### 3.
|
| 71 |
-
- **
|
| 72 |
-
- **
|
|
|
|
|
|
|
|
|
| 67 |
- **`modules/ui_layout.py`**: The full Gradio UI definition (`build_ui`).
|
| 68 |
- **`comfy/`**: Dedicated folder for ComfyUI-specific JSON workflows and utility scripts.
|
| 69 |
|
| 70 |
+
### 3. Deployment (Hugging Face Spaces)
|
| 71 |
+
- **Containerization**: The app is containerized using the provided `Dockerfile` and `.dockerignore`.
|
| 72 |
+
- **User Permissions**: The Dockerfile uses `useradd -m -u 1000 user` to comply with Hugging Face's security requirements for non-root users.
|
| 73 |
+
- **Port Mapping**: Hugging Face Spaces expects the app on port 7860. The `GRADIO_SERVER_NAME="0.0.0.0"` and `GRADIO_SERVER_PORT=7860` environment variables ensure the app is bound correctly for external routing.
|
| 74 |
+
- **Local Testing**: Run `docker-compose up --build` to verify the deployment state locally.
|
docker-compose.yaml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.8'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
rpg-portrait:
|
| 5 |
+
build: .
|
| 6 |
+
ports:
|
| 7 |
+
- "7860:7860"
|
| 8 |
+
env_file:
|
| 9 |
+
- .env
|
| 10 |
+
volumes:
|
| 11 |
+
- ./examples:/home/user/app/examples
|
| 12 |
+
restart: unless-stopped
|
requirements.txt
CHANGED
|
@@ -3,3 +3,4 @@ PyYAML
|
|
| 3 |
python-dotenv
|
| 4 |
google-genai
|
| 5 |
requests
|
|
|
|
|
|
| 3 |
python-dotenv
|
| 4 |
google-genai
|
| 5 |
requests
|
| 6 |
+
Pillow
|