Really-amin commited on
Commit
604285b
·
verified ·
1 Parent(s): 649a5f5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +122 -8
Dockerfile CHANGED
@@ -1,47 +1,161 @@
1
  # Stage 1: Build Frontend
 
2
  FROM node:18-slim AS frontend-builder
3
 
 
 
4
  WORKDIR /app
5
 
 
 
6
  # Copy frontend package files
 
7
  COPY package*.json ./
8
 
 
 
9
  # Install dependencies
 
10
  RUN npm install
11
 
12
- # Copy frontend source
13
- COPY frontend/ ./
 
 
 
 
 
14
 
15
- # Build frontend
16
- RUN npm run build
 
 
 
 
 
 
 
 
 
17
 
18
  # Stage 2: Setup Backend and Serve
 
19
  FROM python:3.10-slim
20
 
 
 
21
  WORKDIR /app
22
 
 
 
23
  # Install system dependencies
 
24
  RUN apt-get update && apt-get install -y \
 
25
  gcc \
 
 
 
 
 
26
  && rm -rf /var/lib/apt/lists/*
27
 
 
 
28
  # Copy backend requirements
29
- COPY backend/requirements.txt ./
 
 
 
30
 
31
  # Install Python dependencies
 
32
  RUN pip install --no-cache-dir -r requirements.txt
33
 
 
 
34
  # Copy backend code
 
35
  COPY backend/ ./backend/
36
 
 
 
 
 
 
 
 
 
37
  # Copy built frontend from previous stage
38
- COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
 
40
  # Expose Hugging Face Space port
 
41
  EXPOSE 7860
42
 
 
 
43
  # Set environment variables
44
- ENV PYTHONUNBUFFERED=1
 
 
 
 
 
 
 
 
 
 
 
 
 
45
 
46
  # Run the application
47
- CMD ["uvicorn", "backend.app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
 
1
  # Stage 1: Build Frontend
2
+
3
  FROM node:18-slim AS frontend-builder
4
 
5
+
6
+
7
  WORKDIR /app
8
 
9
+
10
+
11
  # Copy frontend package files
12
+
13
  COPY package*.json ./
14
 
15
+
16
+
17
  # Install dependencies
18
+
19
  RUN npm install
20
 
21
+
22
+
23
+ # Copy frontend source files
24
+
25
+ COPY *.html ./
26
+
27
+ COPY *.js ./
28
 
29
+ COPY config.js ./
30
+
31
+
32
+
33
+ # Note: This project uses static HTML/JS files, no build step needed
34
+
35
+ # If you add a build step later, uncomment the next line
36
+
37
+ # RUN npm run build
38
+
39
+
40
 
41
  # Stage 2: Setup Backend and Serve
42
+
43
  FROM python:3.10-slim
44
 
45
+
46
+
47
  WORKDIR /app
48
 
49
+
50
+
51
  # Install system dependencies
52
+
53
  RUN apt-get update && apt-get install -y \
54
+
55
  gcc \
56
+
57
+ g++ \
58
+
59
+ curl \
60
+
61
  && rm -rf /var/lib/apt/lists/*
62
 
63
+
64
+
65
  # Copy backend requirements
66
+
67
+ COPY requirements.txt ./
68
+
69
+
70
 
71
  # Install Python dependencies
72
+
73
  RUN pip install --no-cache-dir -r requirements.txt
74
 
75
+
76
+
77
  # Copy backend code
78
+
79
  COPY backend/ ./backend/
80
 
81
+
82
+
83
+ # Copy other Python files
84
+
85
+ COPY *.py ./
86
+
87
+
88
+
89
  # Copy built frontend from previous stage
90
+
91
+ COPY --from=frontend-builder /app/*.html ./
92
+
93
+ COPY --from=frontend-builder /app/*.js ./
94
+
95
+ COPY --from=frontend-builder /app/config.js ./
96
+
97
+
98
+
99
+ # Copy additional directories
100
+
101
+ COPY api/ ./api/
102
+
103
+ COPY collectors/ ./collectors/
104
+
105
+ COPY database/ ./database/
106
+
107
+ COPY monitoring/ ./monitoring/
108
+
109
+ COPY scripts/ ./scripts/
110
+
111
+ COPY tests/ ./tests/
112
+
113
+ COPY utils/ ./utils/
114
+
115
+
116
+
117
+ # Copy data files
118
+
119
+ COPY *.json ./
120
+
121
+
122
+
123
+ # Create necessary directories
124
+
125
+ RUN mkdir -p data logs
126
+
127
+
128
+
129
+ # Set proper permissions
130
+
131
+ RUN chmod -R 755 data logs
132
+
133
+
134
 
135
  # Expose Hugging Face Space port
136
+
137
  EXPOSE 7860
138
 
139
+
140
+
141
  # Set environment variables
142
+
143
+ ENV PYTHONUNBUFFERED=1 \
144
+
145
+ PYTHONDONTWRITEBYTECODE=1
146
+
147
+
148
+
149
+ # Health check
150
+
151
+ HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
152
+
153
+ CMD curl -f http://localhost:7860/health || exit 1
154
+
155
+
156
 
157
  # Run the application
158
+
159
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--log-level", "info"]
160
+
161
+