-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
65 lines (52 loc) · 1.64 KB
/
Dockerfile
File metadata and controls
65 lines (52 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# Use Python 3.9 with CUDA support for better performance
FROM nvidia/cuda:11.8-devel-ubuntu20.04
# Set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies
RUN apt-get update && apt-get install -y \
python3.9 \
python3.9-dev \
python3-pip \
wget \
curl \
git \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
libgl1-mesa-glx \
libglib2.0-0 \
libgtk-3-0 \
&& rm -rf /var/lib/apt/lists/*
# Create symbolic link for python
RUN ln -s /usr/bin/python3.9 /usr/bin/python
# Set working directory
WORKDIR /app
# Copy requirements first for better Docker layer caching
COPY requirements.txt .
# Install Python dependencies
RUN pip3 install --no-cache-dir --upgrade pip
RUN pip3 install --no-cache-dir -r requirements.txt
# Create necessary directories
RUN mkdir -p app/models app/static app/templates data
# Download SAM model weights
RUN wget -O app/models/sam_vit_h_4b8939.pth \
https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth
# Copy application code
COPY app/ ./app/
COPY run.py .
# Create .env file with default values
RUN echo 'APP_NAME="AI Disaster Mapping API"' > .env && \
echo 'DEBUG=True' >> .env && \
echo 'MODEL_PATH="app/models/sam_vit_h_4b8939.pth"' >> .env && \
echo 'MODEL_TYPE="vit_h"' >> .env
# Expose port
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
CMD curl -f http://localhost:8080/health || exit 1
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8080"]