euler314 commited on
Commit
86de8ad
·
verified ·
1 Parent(s): 3990dbb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +34 -16
Dockerfile CHANGED
@@ -2,7 +2,7 @@ FROM python:3.10-slim
2
 
3
  WORKDIR /code
4
 
5
- # Install system dependencies required for cartopy and other packages
6
  RUN apt-get update && apt-get install -y \
7
  gcc \
8
  g++ \
@@ -11,7 +11,15 @@ RUN apt-get update && apt-get install -y \
11
  proj-bin \
12
  libgeos-dev \
13
  libgeos-c1v5 \
 
 
14
  git \
 
 
 
 
 
 
15
  && rm -rf /var/lib/apt/lists/*
16
 
17
  # Create data directory and set permissions
@@ -22,34 +30,44 @@ RUN mkdir -p /code/data && \
22
  RUN mkdir -p /tmp/matplotlib && \
23
  chmod 777 /tmp/matplotlib
24
 
25
- # Set matplotlib config directory
 
 
 
 
26
  ENV MPLCONFIGDIR=/tmp/matplotlib
 
 
 
 
 
 
27
 
28
  # Copy requirements file
29
  COPY requirements.txt .
30
 
31
- # Fix protobuf compatibility and install Python dependencies
32
- RUN pip install --no-cache-dir protobuf>=3.20.0,<4.0.0 && \
 
33
  pip install --no-cache-dir -r requirements.txt
34
 
35
  # Copy application code
36
  COPY . .
37
 
38
- # Set environment variables
39
- ENV DATA_PATH=/code/data
40
- ENV DASH_DEBUG_MODE=false
41
- ENV PYTHONUNBUFFERED=1
42
- ENV TF_CPP_MIN_LOG_LEVEL=3
43
-
44
- # Expose port
45
- EXPOSE 7860
46
-
47
- # Create non-root user
48
  RUN useradd -m -u 1000 appuser && \
49
- chown -R appuser:appuser /code
 
50
 
51
  # Switch to non-root user
52
  USER appuser
53
 
54
- # Start the application
 
 
 
 
 
 
 
55
  CMD ["python", "app.py"]
 
2
 
3
  WORKDIR /code
4
 
5
+ # Install system dependencies required for cartopy, ML libraries, and multimedia
6
  RUN apt-get update && apt-get install -y \
7
  gcc \
8
  g++ \
 
11
  proj-bin \
12
  libgeos-dev \
13
  libgeos-c1v5 \
14
+ libgdal-dev \
15
+ gdal-bin \
16
  git \
17
+ ffmpeg \
18
+ libsm6 \
19
+ libxext6 \
20
+ libfontconfig1 \
21
+ libxrender1 \
22
+ libgl1-mesa-glx \
23
  && rm -rf /var/lib/apt/lists/*
24
 
25
  # Create data directory and set permissions
 
30
  RUN mkdir -p /tmp/matplotlib && \
31
  chmod 777 /tmp/matplotlib
32
 
33
+ # Create cache directories for ML libraries
34
+ RUN mkdir -p /tmp/.cache && \
35
+ chmod 777 /tmp/.cache
36
+
37
+ # Set environment variables
38
  ENV MPLCONFIGDIR=/tmp/matplotlib
39
+ ENV DATA_PATH=/code/data
40
+ ENV DASH_DEBUG_MODE=false
41
+ ENV PYTHONUNBUFFERED=1
42
+ ENV TF_CPP_MIN_LOG_LEVEL=3
43
+ ENV NUMBA_CACHE_DIR=/tmp/.cache/numba
44
+ ENV UMAP_DISABLE_CHECK_RANDOM_STATE=1
45
 
46
  # Copy requirements file
47
  COPY requirements.txt .
48
 
49
+ # Install Python dependencies with optimizations
50
+ RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
51
+ pip install --no-cache-dir protobuf>=3.20.0,<4.0.0 && \
52
  pip install --no-cache-dir -r requirements.txt
53
 
54
  # Copy application code
55
  COPY . .
56
 
57
+ # Create non-root user for security
 
 
 
 
 
 
 
 
 
58
  RUN useradd -m -u 1000 appuser && \
59
+ chown -R appuser:appuser /code && \
60
+ chown -R appuser:appuser /tmp
61
 
62
  # Switch to non-root user
63
  USER appuser
64
 
65
+ # Expose port
66
+ EXPOSE 7860
67
+
68
+ # Health check
69
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
70
+ CMD curl -f http://localhost:7860/ || exit 1
71
+
72
+ # Start the application with optimized settings
73
  CMD ["python", "app.py"]