sinhapiyush86 commited on
Commit
c74f73f
·
verified ·
1 Parent(s): 552c957

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +81 -12
Dockerfile CHANGED
@@ -1,33 +1,86 @@
1
- # Use Python 3.10 slim image
 
 
 
 
 
 
 
 
 
 
 
2
  FROM python:3.10-slim
3
 
4
- # Set working directory
 
 
 
 
 
5
  WORKDIR /app
 
 
 
 
 
 
 
6
 
7
- # Install system dependencies
 
 
8
  RUN apt-get update && apt-get install -y \
9
  build-essential \
10
  curl \
11
  && rm -rf /var/lib/apt/lists/*
12
 
13
- # Copy requirements first for better caching
 
 
 
 
 
14
  COPY requirements.txt .
15
 
16
- # Install Python dependencies
 
 
17
  RUN pip install --no-cache-dir --upgrade pip && \
18
  pip install --no-cache-dir -r requirements.txt
19
 
20
- # Copy application files
 
 
 
 
 
21
  COPY . .
22
 
23
- # Create vector store directory
 
 
 
 
 
24
  RUN mkdir -p vector_store
25
 
26
- # Copy all PDF documents for testing
 
 
 
 
 
27
  COPY *.pdf /app/
28
 
29
- # Set environment variables
 
 
 
 
30
  ENV PYTHONPATH=/app
 
 
31
  ENV STREAMLIT_SERVER_PORT=8501
32
  ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
33
  ENV STREAMLIT_SERVER_HEADLESS=true
@@ -35,11 +88,27 @@ ENV STREAMLIT_SERVER_ENABLE_CORS=false
35
  ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false
36
  ENV STREAMLIT_LOGGER_LEVEL=debug
37
 
38
- # Expose port
 
 
 
 
 
39
  EXPOSE 8501
40
 
41
- # Health check
 
 
 
 
 
42
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
43
 
44
- # Run the application
 
 
 
 
 
 
45
  CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ # =============================================================================
2
+ # RAG System Dockerfile for Hugging Face Spaces
3
+ # =============================================================================
4
+ # This Dockerfile creates a containerized environment for the RAG system
5
+ # with all necessary dependencies and configurations for deployment.
6
+
7
+ # =============================================================================
8
+ # BASE IMAGE SELECTION
9
+ # =============================================================================
10
+
11
+ # Use Python 3.10 slim image for optimal size and compatibility
12
+ # Slim images contain only essential packages, reducing container size
13
  FROM python:3.10-slim
14
 
15
+ # =============================================================================
16
+ # WORKING DIRECTORY SETUP
17
+ # =============================================================================
18
+
19
+ # Set the working directory inside the container
20
+ # All subsequent commands will be executed from this directory
21
  WORKDIR /app
22
+ ENV PYTHONUNBUFFERED=1 \
23
+ PORT=8000 \
24
+ HF_HOME=/home/user/huggingface
25
+
26
+ # =============================================================================
27
+ # SYSTEM DEPENDENCIES INSTALLATION
28
+ # =============================================================================
29
 
30
+ # Install system-level dependencies required for Python packages
31
+ # build-essential: Required for compiling some Python packages
32
+ # curl: Used for health checks and potential downloads
33
  RUN apt-get update && apt-get install -y \
34
  build-essential \
35
  curl \
36
  && rm -rf /var/lib/apt/lists/*
37
 
38
+ # =============================================================================
39
+ # PYTHON DEPENDENCIES INSTALLATION
40
+ # =============================================================================
41
+
42
+ # Copy requirements file first for better Docker layer caching
43
+ # This ensures that dependencies are only reinstalled if requirements.txt changes
44
  COPY requirements.txt .
45
 
46
+ # Install Python dependencies with optimized settings
47
+ # --no-cache-dir: Reduces image size by not caching downloaded packages
48
+ # --upgrade pip: Ensures we have the latest pip version
49
  RUN pip install --no-cache-dir --upgrade pip && \
50
  pip install --no-cache-dir -r requirements.txt
51
 
52
+ # =============================================================================
53
+ # APPLICATION FILES COPY
54
+ # =============================================================================
55
+
56
+ # Copy all application files to the container
57
+ # This includes Python scripts, configuration files, and documentation
58
  COPY . .
59
 
60
+ # =============================================================================
61
+ # DIRECTORY CREATION
62
+ # =============================================================================
63
+
64
+ # Create vector store directory for FAISS index persistence
65
+ # This directory will store the vector embeddings and metadata
66
  RUN mkdir -p vector_store
67
 
68
+ # =============================================================================
69
+ # TEST DATA SETUP
70
+ # =============================================================================
71
+
72
+ # Copy all PDF documents for testing and demonstration
73
+ # These files will be automatically loaded when the system starts
74
  COPY *.pdf /app/
75
 
76
+ # =============================================================================
77
+ # ENVIRONMENT VARIABLES CONFIGURATION
78
+ # =============================================================================
79
+
80
+ # Set Python path to include the application directory
81
  ENV PYTHONPATH=/app
82
+
83
+ # Streamlit server configuration for containerized deployment
84
  ENV STREAMLIT_SERVER_PORT=8501
85
  ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0
86
  ENV STREAMLIT_SERVER_HEADLESS=true
 
88
  ENV STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false
89
  ENV STREAMLIT_LOGGER_LEVEL=debug
90
 
91
+ # =============================================================================
92
+ # NETWORK CONFIGURATION
93
+ # =============================================================================
94
+
95
+ # Expose port 8501 for Streamlit web interface
96
+ # This port will be accessible from outside the container
97
  EXPOSE 8501
98
 
99
+ # =============================================================================
100
+ # HEALTH CHECK CONFIGURATION
101
+ # =============================================================================
102
+
103
+ # Health check to monitor application status
104
+ # Uses curl to check if the Streamlit health endpoint is responding
105
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
106
 
107
+ # =============================================================================
108
+ # APPLICATION STARTUP
109
+ # =============================================================================
110
+
111
+ # Start the Streamlit application with proper configuration
112
+ # --server.port: Specifies the port for the web interface
113
+ # --server.address: Binds to all network interfaces for container access
114
  CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"]