Add docker build setup compose, dockerfile, entrypoint, configs
This commit is contained in:
parent
8b2670ac35
commit
08126ec17f
@ -1,3 +1,12 @@
|
||||
# Ignore everything in data except the configs we need
|
||||
data/*
|
||||
!data/addresses.txt
|
||||
!data/configuration.json
|
||||
!data/inferserver/**
|
||||
!data/nvmsgboker_configs/msgbroker_config.txt
|
||||
!data/nvmsgconv_configs/msgconv_config.txt
|
||||
!data/tracker_configs/**
|
||||
|
||||
# Ignore local build outputs
|
||||
build
|
||||
*.o
|
||||
@ -13,7 +22,19 @@ build
|
||||
# Git
|
||||
.git
|
||||
.gitignore
|
||||
.gitattributes
|
||||
|
||||
# OS / misc
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Ignore model directories completely
|
||||
face_post_process/
|
||||
pose_detection/
|
||||
|
||||
|
||||
# Common junk
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.log
|
||||
*.tmp
|
||||
38
Dockerfile
38
Dockerfile
@ -6,6 +6,8 @@ FROM nvcr.io/nvidia/deepstream:7.1-triton-multiarch AS builder
|
||||
# Remove broken Intel Realsense repo + key
|
||||
# Install build dependencies (CMake, g++, etc.)
|
||||
RUN rm -f /etc/apt/sources.list.d/archive_uri-https_librealsense_intel_com_debian_apt-repo-jammy.list && \
|
||||
rm -f /etc/apt/sources.list.d/cuda* && \
|
||||
rm -f /etc/apt/sources.list.d/nvidia-ml* && \
|
||||
apt-get update && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
@ -18,6 +20,17 @@ RUN rm -f /etc/apt/sources.list.d/archive_uri-https_librealsense_intel_com_debia
|
||||
libglib2.0 \
|
||||
libglib2.0-dev \
|
||||
libssl-dev \
|
||||
libmp3lame0 \
|
||||
libmp3lame-dev \
|
||||
libflac8 \
|
||||
libflac-dev \
|
||||
python3-opencv \
|
||||
libopencv-dev \
|
||||
libchromaprint1 \
|
||||
libmpg123-0 \
|
||||
mjpegtools \
|
||||
libavcodec58 \
|
||||
libmjpegutils-2.1-0 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# =========================
|
||||
@ -50,6 +63,7 @@ RUN git clone https://github.com/jupp0r/prometheus-cpp.git && \
|
||||
-DENABLE_EXPOSER=ON && \
|
||||
cmake --build . --parallel $(nproc) && \
|
||||
cmake --install . && \
|
||||
echo "/usr/local/lib" | tee /etc/ld.so.conf.d/prometheus-cpp.conf && \
|
||||
ldconfig && \
|
||||
rm -rf /tmp/prometheus-cpp
|
||||
|
||||
@ -81,10 +95,11 @@ RUN wget http://download.redis.io/releases/redis-6.0.8.tar.gz && \
|
||||
# src/redis-server &
|
||||
|
||||
# expose redis default port
|
||||
#EXPOSE 6379
|
||||
# EXPOSE 9736
|
||||
|
||||
# run redis server (no protected mode)
|
||||
#CMD ["redis-server", "--protected-mode", "no"]
|
||||
# CMD is the last line → when you run the container, it’ll start Redis automatically.
|
||||
# CMD ["redis-server", "--protected-mode", "no"]
|
||||
|
||||
# Set working dir
|
||||
WORKDIR /app
|
||||
@ -92,6 +107,7 @@ WORKDIR /app
|
||||
# Copy only cmake configs first (for caching)
|
||||
COPY CMakeLists.txt ./
|
||||
COPY src ./src
|
||||
COPY entrypoint.sh ./
|
||||
|
||||
# Copy only required configs from host → container
|
||||
COPY data/addresses.txt ./data/
|
||||
@ -125,13 +141,26 @@ RUN mkdir -p build && cd build && \
|
||||
# =========================
|
||||
FROM nvcr.io/nvidia/deepstream:7.1-triton-multiarch
|
||||
|
||||
# =========================
|
||||
# Install Python dependencies
|
||||
# =========================
|
||||
RUN pip3 install \
|
||||
numpy==1.26.4 \
|
||||
opencv-python-headless==4.10.0.84 \
|
||||
tritonclient \
|
||||
gevent \
|
||||
geventhttpclient
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy configs from build stage: Copy runtime data/configs
|
||||
COPY --from=builder /app/data ./data
|
||||
|
||||
WORKDIR /app/build
|
||||
|
||||
# Copy compiled binaries from builder
|
||||
COPY --from=builder /app/build /app/build
|
||||
COPY --from=builder /app/build/bin/BodyPipeline /app/build/bin/BodyPipeline
|
||||
COPY --from=builder /app/entrypoint.sh /app/entrypoint.sh
|
||||
|
||||
|
||||
# Copy DeepStream runtime libs/configs (container → image → host at runtime)
|
||||
@ -150,5 +179,4 @@ RUN mkdir -p /app/data/nvmsgboker_configs && \
|
||||
cp /opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so /app/data/tracker_configs/ && \
|
||||
cp /opt/nvidia/deepstream/deepstream/lib/gst-plugins/libnvdsgst_tracker.so /app/data/tracker_configs/
|
||||
|
||||
# Default entrypoint (change main binary name if different)
|
||||
ENTRYPOINT ["./build/bin/BodyPipeline"]
|
||||
RUN chmod +x /app/entrypoint.sh
|
||||
@ -63,7 +63,7 @@
|
||||
"msgbroker_config_file": "../data/nvmsgboker_configs/msgbroker_config.txt",
|
||||
"protocol_adaptor_library": "../data/nvmsgboker_configs/libnvds_redis_proto.so",
|
||||
"redis_broker_host": "localhost",
|
||||
"redis_broker_port": 6379,
|
||||
"redis_broker_port": 9736,
|
||||
"topic_redis": "redis_stream"
|
||||
},
|
||||
"compression_coefficient": 0.125,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
[message-broker]
|
||||
# Redis-specific options
|
||||
hostname=localhost
|
||||
port=6379
|
||||
port=9736
|
||||
streamsize=10000
|
||||
payloadkey=metadata
|
||||
consumergroup=mygroup
|
||||
|
||||
42
docker-compose.yml
Normal file
42
docker-compose.yml
Normal file
@ -0,0 +1,42 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis:8
|
||||
container_name: redis_server
|
||||
restart: always
|
||||
network_mode: host
|
||||
volumes:
|
||||
- ./redis.conf:/usr/local/etc/redis/redis.conf
|
||||
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
|
||||
deepstream-app:
|
||||
build: .
|
||||
depends_on:
|
||||
- redis
|
||||
container_name: deepstream_with_triton
|
||||
restart: always
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: all
|
||||
capabilities: [gpu]
|
||||
network_mode: host
|
||||
volumes:
|
||||
# Mount configs (edit locally, no rebuild needed)
|
||||
- ./data:/app/data
|
||||
- ./Put.mp4:/root/Put.mp4
|
||||
|
||||
# Mount models for first Triton: Pose detection
|
||||
- ./pose_detection/models:/root/pose_detection/models:ro
|
||||
|
||||
# Mount second Triton repo: Face detection
|
||||
- ./face_post_process:/root/face_models:ro
|
||||
|
||||
env_file:
|
||||
- ./triton_ports.env
|
||||
environment:
|
||||
REDIS_HOST: 127.0.0.1 # since DeepStream is host network
|
||||
NVIDIA_VISIBLE_DEVICES: all
|
||||
entrypoint: ["/app/entrypoint.sh"]
|
||||
36
entrypoint.sh
Normal file
36
entrypoint.sh
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# Load ports from config
|
||||
if [ -f /app/triton_ports.env ]; then
|
||||
export $(grep -v '^#' /app/triton_ports.env | xargs)
|
||||
fi
|
||||
|
||||
|
||||
echo "[INFO] Starting Triton servers with the following ports:"
|
||||
echo "Pose - HTTP:$POSE_HTTP_PORT GRPC:$POSE_GRPC_PORT METRICS:$POSE_METRICS_PORT"
|
||||
echo "Face - HTTP:$FACE_HTTP_PORT GRPC:$FACE_GRPC_PORT METRICS:$FACE_METRICS_PORT"
|
||||
|
||||
# Start Triton server #1 (Body detection) in background
|
||||
tritonserver \
|
||||
--model-repository=/root/pose_detection \
|
||||
--http-port=$POSE_HTTP_PORT \
|
||||
--grpc-port=$POSE_GRPC_PORT \
|
||||
--metrics-port=$POSE_METRICS_PORT &
|
||||
|
||||
# Wait a bit to ensure Triton servers are up
|
||||
sleep 5
|
||||
|
||||
# Start Triton server #2 (Face detection, preprocess, postprocess) in background
|
||||
tritonserver \
|
||||
--model-repository=/root/face_models \
|
||||
--http-port=$FACE_HTTP_PORT \
|
||||
--grpc-port=$FACE_GRPC_PORT \
|
||||
--metrics-port=$FACE_METRICS_PORT &
|
||||
|
||||
# Wait a bit to ensure Triton servers are up
|
||||
sleep 5
|
||||
|
||||
# Run DeepStream app (expects configs under /app/data): (foreground, keeps container alive)
|
||||
cd /app/build
|
||||
./bin/BodyPipeline
|
||||
2
redis.conf
Normal file
2
redis.conf
Normal file
@ -0,0 +1,2 @@
|
||||
port 9736
|
||||
bind 0.0.0.0
|
||||
9
triton_ports.env
Normal file
9
triton_ports.env
Normal file
@ -0,0 +1,9 @@
|
||||
# Triton server 1 (pose detection)
|
||||
POSE_HTTP_PORT=3000
|
||||
POSE_GRPC_PORT=3001
|
||||
POSE_METRICS_PORT=3002
|
||||
|
||||
# Triton server 2 (face detection)
|
||||
FACE_HTTP_PORT=4000
|
||||
FACE_GRPC_PORT=4001
|
||||
FACE_METRICS_PORT=4002
|
||||
Loading…
x
Reference in New Issue
Block a user