Spaces:
Sleeping
Sleeping
Commit Β·
954e83c
1
Parent(s): d81a83d
add docker
Browse files- .github/workflows/deploy-to-spaces.yml +1 -1
- Dockerfile +22 -0
- README.md +17 -0
.github/workflows/deploy-to-spaces.yml
CHANGED
|
@@ -36,7 +36,7 @@ jobs:
|
|
| 36 |
echo "Using Space repository: $SPACE_REPO"
|
| 37 |
|
| 38 |
# Create the Space if it does not exist
|
| 39 |
-
huggingface-cli repo create "$SPACE_REPO" --type space --space-sdk
|
| 40 |
|
| 41 |
# Push all files to the Space
|
| 42 |
git config --global user.email "actions@github.com"
|
|
|
|
| 36 |
echo "Using Space repository: $SPACE_REPO"
|
| 37 |
|
| 38 |
# Create the Space if it does not exist
|
| 39 |
+
huggingface-cli repo create "$SPACE_REPO" --type space --space-sdk docker -y || true
|
| 40 |
|
| 41 |
# Push all files to the Space
|
| 42 |
git config --global user.email "actions@github.com"
|
Dockerfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.10-slim
|
| 2 |
+
|
| 3 |
+
# Disable telemetry
|
| 4 |
+
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
|
| 5 |
+
PIP_NO_CACHE_DIR=1 \
|
| 6 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 7 |
+
PYTHONUNBUFFERED=1
|
| 8 |
+
|
| 9 |
+
WORKDIR /app
|
| 10 |
+
|
| 11 |
+
# Install Python dependencies first (leverages Docker layer caching)
|
| 12 |
+
COPY requirements.txt ./
|
| 13 |
+
RUN pip install --upgrade pip && \
|
| 14 |
+
pip install -r requirements.txt
|
| 15 |
+
|
| 16 |
+
# Copy the rest of the code
|
| 17 |
+
COPY . .
|
| 18 |
+
|
| 19 |
+
# Hugging Face sets the PORT env variable (default 7860)
|
| 20 |
+
EXPOSE 7860
|
| 21 |
+
|
| 22 |
+
CMD streamlit run app.py --server.port $PORT --server.address 0.0.0.0 --server.headless true
|
README.md
CHANGED
|
@@ -26,6 +26,22 @@ The app will open in your browser at `http://localhost:8501`.
|
|
| 26 |
|
| 27 |
---
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
## Deploy to Hugging Face Spaces
|
| 30 |
|
| 31 |
1. **Create a new Space** (type: *Streamlit*) at `https://huggingface.co/new-space` or let the Action do it for you automatically.
|
|
@@ -52,5 +68,6 @@ On each push to the `main` branch the GitHub workflow located at `.github/workfl
|
|
| 52 |
βββ .github/
|
| 53 |
β βββ workflows/
|
| 54 |
β βββ deploy-to-spaces.yml # CI/CD pipeline
|
|
|
|
| 55 |
βββ README.md
|
| 56 |
```
|
|
|
|
| 26 |
|
| 27 |
---
|
| 28 |
|
| 29 |
+
## Quick start (Docker)
|
| 30 |
+
|
| 31 |
+
If you prefer to run the chatbot in a container instead of a local virtual-env, use the provided `Dockerfile`.
|
| 32 |
+
|
| 33 |
+
```bash
|
| 34 |
+
# 1. Build the image (tagged "streamlit-chatbot")
|
| 35 |
+
docker build -t streamlit-chatbot .
|
| 36 |
+
|
| 37 |
+
# 2. Run the container and expose the app on http://localhost:8501
|
| 38 |
+
docker run --rm -it -e PORT=8501 -p 8501:8501 streamlit-chatbot
|
| 39 |
+
```
|
| 40 |
+
|
| 41 |
+
The container entrypoint launches Streamlit on the port given by the `PORT` environment variable (the same variable Hugging Face uses). By passing `-e PORT=8501` and mapping `-p 8501:8501`, you can access the interface in your browser at `http://localhost:8501`.
|
| 42 |
+
|
| 43 |
+
---
|
| 44 |
+
|
| 45 |
## Deploy to Hugging Face Spaces
|
| 46 |
|
| 47 |
1. **Create a new Space** (type: *Streamlit*) at `https://huggingface.co/new-space` or let the Action do it for you automatically.
|
|
|
|
| 68 |
βββ .github/
|
| 69 |
β βββ workflows/
|
| 70 |
β βββ deploy-to-spaces.yml # CI/CD pipeline
|
| 71 |
+
βββ Dockerfile # Container definition for Docker/HF Spaces
|
| 72 |
βββ README.md
|
| 73 |
```
|