garyuzair commited on
Commit
8c546bd
·
verified ·
1 Parent(s): 8a904f1

Create Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +62 -0
Dockerfile ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dockerfile
2
+
3
+ # 1. Base Image: Python 3.10 on Debian (Bullseye for ffmpeg availability)
4
+ # Using a slim image to keep the size down.
5
+ FROM python:3.10-slim-bullseye
6
+
7
+ # 2. Set Environment Variables
8
+ ENV PYTHONUNBUFFERED=1 \
9
+ PIP_NO_CACHE_DIR=off \
10
+ PIP_DISABLE_PIP_VERSION_CHECK=on \
11
+ PIP_DEFAULT_TIMEOUT=100 \
12
+ # For Hugging Face cache inside the container (optional, models will download on first run)
13
+ HF_HOME="/app/.huggingface_cache" \
14
+ TRANSFORMERS_CACHE="/app/.huggingface_cache/transformers" \
15
+ HUGGINGFACE_HUB_CACHE="/app/.huggingface_cache/hub"
16
+
17
+ # 3. Install System Dependencies
18
+ # - ffmpeg: for video processing
19
+ # - git: in case any pip package needs to be installed from a git source
20
+ RUN apt-get update && \
21
+ apt-get install -y --no-install-recommends \
22
+ ffmpeg \
23
+ git \
24
+ curl \
25
+ && apt-get clean && \
26
+ rm -rf /var/lib/apt/lists/*
27
+
28
+ # 4. Set Working Directory
29
+ WORKDIR /app
30
+
31
+ # 5. Copy requirements.txt and Install Python Dependencies
32
+ COPY requirements.txt .
33
+ RUN pip install --no-cache-dir -r requirements.txt
34
+
35
+ # 6. Copy Application Code and Secrets
36
+ # First, copy the secrets file (if it exists and you intend to build it into the image)
37
+ # WARNING: Building secrets into the image is generally NOT recommended for production.
38
+ # Manage secrets via environment variables or Docker secrets/volume mounts at runtime.
39
+ # This is included for completeness if you are managing it this way for development.
40
+ COPY .streamlit/secrets.toml .streamlit/secrets.toml
41
+
42
+ # Copy the rest of your application code
43
+ COPY app.py .
44
+ # If you have other Python modules or asset files, copy them as well:
45
+ # COPY your_module.py .
46
+ # COPY assets/ /app/assets/
47
+
48
+ # 7. Create Hugging Face cache directory and set permissions (optional)
49
+ # This helps if the user running the container is not root and needs to write to cache.
50
+ RUN mkdir -p /app/.huggingface_cache && \
51
+ chmod -R 777 /app/.huggingface_cache
52
+
53
+ # 8. Expose Port for Streamlit
54
+ EXPOSE 8501
55
+
56
+ # 9. Healthcheck (Optional but recommended)
57
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
58
+ CMD curl --fail http://localhost:8501/_stcore/health || exit 1
59
+
60
+ # 10. Command to Run the Streamlit Application
61
+ # The --server.address=0.0.0.0 makes the app accessible externally from the container.
62
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--logger.level=info"]