File size: 1,414 Bytes
755e71e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
FROM python:3.10-slim

# Hugging Face runs on UID 1000
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"

WORKDIR /home/user/app

# Install dependencies
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Copy app files
COPY --chown=user . .

# IMPORTANT: Use --server.address and --server.port
# Do NOT use --host or -p
CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]

# # Use a lightweight Python base image
# FROM python:3.10-slim

# # Set the working directory inside the container
# # Streamlit apps work best when not run from the root '/' directory
# WORKDIR /app

# # Install system dependencies (optional but recommended for image processing)
# RUN apt-get update && apt-get install -y \
#     build-essential \
#     curl \
#     software-properties-common \
#     && rm -rf /var/lib/apt/lists/*

# # Copy requirements first to leverage Docker caching
# COPY requirements.txt .

# # Install Python dependencies
# RUN pip install --no-cache-dir -r requirements.txt

# # Copy the rest of your app files (app.py and the images folder)
# COPY . .

# # Expose the default Hugging Face port
# EXPOSE 7860

# # Command to run the Streamlit app
# # Note: --server.port 7860 and --server.address 0.0.0.0 are required for HF
# CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]