Spaces:
Sleeping
Sleeping
Update Dockerfile
Browse files- Dockerfile +36 -12
Dockerfile
CHANGED
@@ -1,18 +1,42 @@
|
|
1 |
-
# Base image
|
2 |
FROM python:3.9-slim
|
3 |
|
4 |
-
|
5 |
-
WORKDIR /app
|
6 |
|
7 |
-
#
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
-
COPY --chown=user ./requirements.txt requirements.txt
|
11 |
-
# Install dependencies
|
12 |
-
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
13 |
|
14 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
EXPOSE 7860
|
16 |
-
|
17 |
-
#
|
18 |
-
CMD ["
|
|
|
|
|
1 |
FROM python:3.9-slim
|
2 |
|
3 |
+
WORKDIR /code
|
|
|
4 |
|
5 |
+
# Install system dependencies
|
6 |
+
RUN apt-get update && \
|
7 |
+
apt-get install -y --no-install-recommends \
|
8 |
+
build-essential \
|
9 |
+
curl \
|
10 |
+
libhdf5-dev \
|
11 |
+
&& rm -rf /var/lib/apt/lists/*
|
12 |
|
|
|
|
|
|
|
13 |
|
14 |
+
# Copy requirements first to leverage Docker cache
|
15 |
+
COPY requirements.txt .
|
16 |
+
|
17 |
+
# Clean pip cache and install requirements with specific versions
|
18 |
+
RUN pip cache purge && \
|
19 |
+
pip install --no-cache-dir -r requirements.txt
|
20 |
+
|
21 |
+
# Copy project structure
|
22 |
+
COPY app.py .
|
23 |
+
COPY templates/ ./templates/
|
24 |
+
|
25 |
+
|
26 |
+
# Set environment variables
|
27 |
+
ENV PORT=7860
|
28 |
+
ENV HOST=0.0.0.0
|
29 |
+
ENV FLASK_APP=app.py
|
30 |
+
ENV FLASK_ENV=production
|
31 |
+
ENV FLASK_DEBUG=0
|
32 |
+
|
33 |
+
|
34 |
+
|
35 |
+
# Create cache directory for tensorflow-hub
|
36 |
+
RUN mkdir -p /root/.cache/tensorflow-hub
|
37 |
+
|
38 |
+
# Expose the port
|
39 |
EXPOSE 7860
|
40 |
+
|
41 |
+
# Run Flask application with proper host and port
|
42 |
+
CMD ["python", "-c", "from app import app; app.run(host='0.0.0.0', port=7860, debug=False)"]
|