-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.optimized
More file actions
45 lines (34 loc) · 1.09 KB
/
Dockerfile.optimized
File metadata and controls
45 lines (34 loc) · 1.09 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
# syntax=docker/dockerfile:1
FROM python:3.11-slim
# Install system dependencies for OpenCV and RTSP streaming
RUN apt-get update && apt-get install -y --no-install-recommends \
libglib2.0-0 \
libsm6 \
libxrender1 \
libxext6 \
ffmpeg \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user for OpenShift compatibility
RUN useradd -m -u 10001 -s /bin/bash appuser
WORKDIR /app
# Copy and install Python dependencies with BuildKit cache mount
COPY app/requirements.txt /app/requirements.txt
RUN --mount=type=cache,target=/root/.cache/pip \
pip install --no-cache-dir -r /app/requirements.txt
# Copy model weights (changes infrequently)
COPY models /models
RUN chmod -R 755 /models
# Copy application code (changes most frequently - last layer for better caching)
COPY app /app
# Set ownership for non-root user
RUN chown -R appuser:appuser /app /models
# Drop to non-root user
USER appuser
# Environment variables
ENV PYTHONUNBUFFERED=1 \
MODEL_PATH=/models/yolov8n.onnx \
IMG=640 \
CONF=0.5 \
NMS=0.45
ENTRYPOINT ["python", "-u", "track.py"]