afscomercial commited on
Commit
954e83c
Β·
1 Parent(s): d81a83d

add docker

Browse files
Files changed (3) hide show
  1. .github/workflows/deploy-to-spaces.yml +1 -1
  2. Dockerfile +22 -0
  3. 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 streamlit -y || true
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
  ```