Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files- Dockerfile +50 -26
Dockerfile
CHANGED
|
@@ -1,34 +1,58 @@
|
|
| 1 |
-
#
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
WORKDIR /app/frontend
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
COPY frontend/package.json frontend/package-lock.json ./
|
| 9 |
-
RUN npm install
|
| 10 |
-
|
| 11 |
-
# Copy the rest of the frontend code and build it
|
| 12 |
COPY frontend/ ./
|
|
|
|
| 13 |
RUN npm run build
|
| 14 |
|
| 15 |
-
#
|
| 16 |
-
|
| 17 |
-
# Stage 2: Build the final Python image
|
| 18 |
-
FROM python:3.9-slim
|
| 19 |
-
|
| 20 |
WORKDIR /app
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
-
RUN pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
| 26 |
-
# Copy
|
| 27 |
-
COPY
|
| 28 |
-
|
| 29 |
-
# Copy your backend application code
|
| 30 |
-
COPY . .
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2025 Google LLC
|
| 2 |
+
#
|
| 3 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 4 |
+
# you may not use this file except in compliance with the License.
|
| 5 |
+
# You may obtain a copy of the License at
|
| 6 |
+
#
|
| 7 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 8 |
+
#
|
| 9 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 10 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 11 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 12 |
+
# See the License for the specific language governing permissions and
|
| 13 |
+
# limitations under the License.
|
| 14 |
+
|
| 15 |
+
# Build React app
|
| 16 |
+
FROM node:24-slim AS frontend-build
|
| 17 |
WORKDIR /app/frontend
|
| 18 |
+
# Upgrade npm to the desired version
|
| 19 |
+
RUN npm install -g npm@11.4.x
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
COPY frontend/ ./
|
| 21 |
+
RUN npm install
|
| 22 |
RUN npm run build
|
| 23 |
|
| 24 |
+
# Python backend
|
| 25 |
+
FROM python:3.10-slim
|
|
|
|
|
|
|
|
|
|
| 26 |
WORKDIR /app
|
| 27 |
|
| 28 |
+
# Install ffmpeg for audio conversion
|
| 29 |
+
RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*
|
|
|
|
| 30 |
|
| 31 |
+
# Copy requirements.txt first for better caching
|
| 32 |
+
COPY requirements.txt ./
|
| 33 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
|
|
|
|
|
|
| 34 |
|
| 35 |
+
# Copy Flask app
|
| 36 |
+
COPY *.py ./
|
| 37 |
+
COPY symptoms.json ./
|
| 38 |
+
COPY report_template.txt ./
|
| 39 |
+
|
| 40 |
+
# Copy built React app
|
| 41 |
+
COPY --from=frontend-build /app/frontend/build ./frontend/build
|
| 42 |
+
ENV FRONTEND_BUILD=/app/frontend/build
|
| 43 |
+
|
| 44 |
+
# Create cache directory and set permissions, then assign the env variable
|
| 45 |
+
RUN mkdir -p /cache && chmod 777 /cache
|
| 46 |
+
ENV CACHE_DIR=/cache
|
| 47 |
+
|
| 48 |
+
# If cache.zip exists, extract it into /cache
|
| 49 |
+
COPY cache* /tmp/
|
| 50 |
+
RUN if [ -f /tmp/cache_archive.zip ]; then \
|
| 51 |
+
apt-get update && apt-get install -y unzip && \
|
| 52 |
+
unzip /tmp/cache_archive.zip -d /cache && \
|
| 53 |
+
rm /tmp/cache_archive.zip && \
|
| 54 |
+
chmod -R 777 /cache; \
|
| 55 |
+
fi
|
| 56 |
+
|
| 57 |
+
EXPOSE 7860
|
| 58 |
+
CMD ["gunicorn", "-b", "0.0.0.0:7860", "app:app", "--threads", "4", "--timeout", "300"]
|