3
3
4
4
echo " Ready to start"
5
5
6
+ # Function to run scripts
7
+ run_script () {
8
+ local script=$1
9
+ case " $script " in
10
+ * .sh)
11
+ if [ -x " $script " ]; then
12
+ " $script "
13
+ else
14
+ bash " $script "
15
+ fi
16
+ ;;
17
+ * .py)
18
+ if [ -x " $script " ]; then
19
+ " $script "
20
+ else
21
+ python3 " $script "
22
+ fi
23
+ ;;
24
+ * )
25
+ echo " Unknown file type: $script " >&2
26
+ ;;
27
+ esac
28
+ }
29
+
6
30
if [ " $CUSTOMIZE " = " true" ]; then
7
31
echo " Customization is enabled."
8
32
# Check if the base entry point script exists
@@ -12,18 +36,32 @@ if [ "$CUSTOMIZE" = "true" ]; then
12
36
echo " Base entry point is running."
13
37
# Wait for 10 seconds
14
38
sleep 10
39
+ else
40
+ echo " Base entry point script not found: /usr/local/bin/base_entrypoint.sh" >&2
41
+ exit 1
15
42
fi
16
- echo " Customization can be added here. If no additional services are defined then the container will exit."
17
- echo " Running the custom entry point..."
18
43
19
- # Custom logic or services can be added here
20
- # Example: Start a Python script
21
- # echo "Starting the Python script..."
22
- # python3 /app/your_python_script.py
44
+ # Run all bash or Python scripts found inside custom entrypoints folder
45
+ if [ -d " $CUSTOM_ENTRYPOINTS_DIR " ]; then
46
+ for script in " $CUSTOM_ENTRYPOINTS_DIR " /* .{sh,py}; do
47
+ if [ -f " $script " ]; then
48
+ echo " Running custom entry point script: $script "
49
+ run_script " $script "
50
+ fi
51
+ done
52
+ else
53
+ echo " Custom entrypoints directory not found: $CUSTOM_ENTRYPOINTS_DIR " >&2
54
+ exit 1
55
+ fi
23
56
24
- # ### ADD YOUR CUSTOM CODE HERE ####
57
+ echo " Customization completed. If no additional services are defined then the container will exit. "
25
58
26
59
else
27
60
echo " Customization is disabled. Running the base entry point in the foreground..."
28
- exec /usr/local/bin/base_entrypoint.sh
61
+ if [ -f /usr/local/bin/base_entrypoint.sh ]; then
62
+ exec /usr/local/bin/base_entrypoint.sh
63
+ else
64
+ echo " Base entry point script not found: /usr/local/bin/base_entrypoint.sh" >&2
65
+ exit 1
66
+ fi
29
67
fi
0 commit comments