-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDockerfile
More file actions
77 lines (64 loc) · 2.07 KB
/
Dockerfile
File metadata and controls
77 lines (64 loc) · 2.07 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
# Use Python 3.11 slim as base image for better performance and smaller size
FROM python:3.11-slim
# Set environment variables
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PIP_NO_CACHE_DIR=1 \
PIP_DISABLE_PIP_VERSION_CHECK=1
# Set working directory
WORKDIR /app
# Install system dependencies required for OpenCV and other packages
RUN apt-get update && apt-get install -y \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
libgtk-3-0 \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libv4l-dev \
libxvidcore-dev \
libx264-dev \
libjpeg-dev \
libpng-dev \
libtiff-dev \
libopenblas-dev \
liblapack-dev \
gfortran \
wget \
git \
portaudio19-dev \
libasound2-dev \
libusb-1.0-0 \
libusb-1.0-0-dev \
libudev-dev \
&& rm -rf /var/lib/apt/lists/*
# Copy requirements first for better Docker layer caching
COPY requirements.txt pyproject.toml ./
# Install Python dependencies
RUN pip install --no-cache-dir -r requirements.txt
# Copy the entire project
COPY . .
# Create necessary directories
RUN mkdir -p /app/InferenceNode/model_repository \
/app/InferenceNode/logs \
/app/InferenceNode/static \
/app/InferenceNode/templates
# Set permissions for the application directory
RUN chmod -R 755 /app
# Create a non-root user for security
RUN useradd --create-home --shell /bin/bash infernode && \
chown -R infernode:infernode /app
USER infernode
# Expose the default ports
EXPOSE 5555 8888/udp
# Set default port (can be overridden in docker-compose)
ENV NODE_PORT=5555
# Health check - uses NODE_PORT environment variable
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD python -c "import urllib.request, os; urllib.request.urlopen(f'http://localhost:{os.environ.get(\"NODE_PORT\", \"5555\")}/health', timeout=5)" || exit 1
# Default command to run the inference node in production mode
# Using shell form to allow environment variable expansion
CMD python main.py --port ${NODE_PORT} --production