-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
85 lines (64 loc) · 1.98 KB
/
Dockerfile
File metadata and controls
85 lines (64 loc) · 1.98 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# PixIntelligence Dockerfile
# Multi-stage build for optimized image size
# Stage 1: Base image with system dependencies
FROM python:3.10-slim AS base
# Set working directory
WORKDIR /app
# Install system dependencies
RUN apt-get update && apt-get install -y \
libgl1 \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender1 \
libgomp1 \
libgfortran5 \
libmagic1 \
git \
curl \
&& rm -rf /var/lib/apt/lists/*
# Stage 2: Builder stage for Python dependencies
FROM base AS builder
# Copy requirements file
COPY requirements.txt .
# Install Python dependencies in a virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
# Upgrade pip and install dependencies
RUN pip install --no-cache-dir --upgrade pip setuptools wheel && \
pip install --no-cache-dir -r requirements.txt
# Stage 3: Final runtime image
FROM base
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PATH="/opt/venv/bin:$PATH" \
PIXINTELLIGENCE_HOST=0.0.0.0 \
PIXINTELLIGENCE_PORT=8000
# Copy virtual environment from builder
COPY --from=builder /opt/venv /opt/venv
# Create necessary directories
RUN mkdir -p /app/src/data/uploads \
/app/src/data/camera_fingerprints \
/app/output \
/app/logs
# Copy application code
COPY . /app/
# Install the package in development mode
RUN pip install -e .
# Make entrypoint script executable
RUN chmod +x /app/docker-entrypoint.sh
# Create non-root user for security
RUN useradd -m -u 1000 pixintel && \
chown -R pixintel:pixintel /app
# Switch to non-root user
USER pixintel
# Expose port
EXPOSE 8000
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/').read()"
# Set entrypoint
ENTRYPOINT ["/app/docker-entrypoint.sh"]
# Default command: run web server
CMD ["pixintelligence", "serve", "--host", "0.0.0.0", "--port", "8000"]