-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
53 lines (44 loc) · 1.83 KB
/
docker-entrypoint.sh
File metadata and controls
53 lines (44 loc) · 1.83 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
#!/bin/bash
# Docker entrypoint script for SpeedCam application
# This script handles OpenCV library loading in the Linux container environment
set -e
echo "Starting SpeedCam application in container..."
# Look for OpenCV native libraries in various locations
OPENCV_LIB_PATH=""
for path in "/usr/local/lib64" "/usr/local/lib" "/usr/lib" "/usr/lib/x86_64-linux-gnu"; do
if [ -d "$path" ] && [ -n "$(find "$path" -name "libopencv_core.so*" 2>/dev/null)" ]; then
OPENCV_LIB_PATH="$path:$OPENCV_LIB_PATH"
fi
done
# Look for OpenCV Java library specifically
OPENCV_JAVA_LIB=""
for path in "/usr/lib/jni" "/usr/local/lib64" "/usr/local/lib" "/usr/lib" "/usr/lib/x86_64-linux-gnu"; do
if [ -d "$path" ]; then
JAVA_LIB=$(find "$path" -name "libopencv_java*.so" 2>/dev/null | head -1)
if [ -n "$JAVA_LIB" ]; then
OPENCV_JAVA_LIB="$JAVA_LIB"
echo "Found OpenCV Java library: $OPENCV_JAVA_LIB"
# Add JNI path to library path
OPENCV_LIB_PATH="$path:$OPENCV_LIB_PATH"
break
fi
fi
done
if [ -n "$OPENCV_LIB_PATH" ]; then
echo "Found OpenCV libraries in: $OPENCV_LIB_PATH"
export LD_LIBRARY_PATH="$OPENCV_LIB_PATH:$LD_LIBRARY_PATH"
else
echo "Warning: No OpenCV native libraries found"
fi
# Set system properties for OpenCV loading
if [ -n "$OPENCV_JAVA_LIB" ]; then
echo "Using system OpenCV Java library"
JAVA_OPTS="$JAVA_OPTS -Duse.system.opencv=true -Djava.library.path=$LD_LIBRARY_PATH"
else
echo "No OpenCV Java library found, will attempt to use bundled version"
JAVA_OPTS="$JAVA_OPTS -Djava.library.path=$LD_LIBRARY_PATH"
fi
echo "Java library path: $LD_LIBRARY_PATH"
echo "Starting application..."
# Execute the Java application
exec java $JAVA_OPTS -cp "./target/speedcam-0.1-jar-with-dependencies.jar" com.pinealpha.SpeedDetect "$@"