@@ -43,7 +43,10 @@ Commands:
4343 build-binaries Build Linux and Windows binaries with YARA
4444 build-linux Build Linux binary with YARA support
4545 build-windows Build Windows binary with YARA support
46- clean Remove Docker build cache
46+ build-runtime Build the runtime image (FastFinder inside container)
47+ run-runtime Run FastFinder inside a container named "runtime"
48+ Options: --config=PATH --scan=PATH --interactive --triage
49+ clean Remove FastFinder Docker resources
4750 help Show this help message
4851
4952Examples:
@@ -56,7 +59,22 @@ Examples:
5659 # Build only Windows binary
5760 $0 build-windows
5861
59- # Clean up Docker build cache
62+ # Build runtime image
63+ $0 build-runtime
64+
65+ # Run FastFinder in container with config directory
66+ $0 run-runtime --config=/path/to/config --scan=/data
67+
68+ # Run with specific config file
69+ $0 run-runtime --config=/path/to/config.yaml --scan=/data
70+
71+ # Interactive shell mode
72+ $0 run-runtime --interactive
73+
74+ # Triage mode (continuous monitoring)
75+ $0 run-runtime --config=/path/to/config --scan=/data --triage
76+
77+ # Clean up FastFinder Docker resources
6078 $0 clean
6179
6280For more details, see docker/README.md
@@ -149,15 +167,141 @@ build_windows() {
149167 fi
150168}
151169
170+ # Build runtime image
171+ build_runtime () {
172+ print_info " Building FastFinder runtime image..."
173+
174+ cd " $PROJECT_ROOT "
175+
176+ docker build \
177+ -f docker/Dockerfile.runtime \
178+ -t fastfinder:runtime \
179+ .
180+
181+ print_success " Runtime image built as fastfinder:runtime"
182+ }
183+
184+ # Run FastFinder in runtime container
185+ run_runtime () {
186+ local config_path=" $PROJECT_ROOT /examples"
187+ local scan_path=" $PROJECT_ROOT "
188+ local interactive=false
189+ local triage=false
190+
191+ # Parse arguments
192+ while [[ $# -gt 0 ]]; do
193+ case $1 in
194+ --config=* )
195+ config_path=" ${1#* =} "
196+ shift
197+ ;;
198+ --scan=* )
199+ scan_path=" ${1#* =} "
200+ shift
201+ ;;
202+ --interactive)
203+ interactive=true
204+ shift
205+ ;;
206+ --triage)
207+ triage=true
208+ shift
209+ ;;
210+ * )
211+ print_error " Unknown option: $1 "
212+ return 1
213+ ;;
214+ esac
215+ done
216+
217+ # Ensure runtime image exists
218+ if ! docker image inspect fastfinder:runtime > /dev/null 2>&1 ; then
219+ build_runtime
220+ fi
221+
222+ # Check config path exists
223+ if [ ! -e " $config_path " ]; then
224+ print_error " Config path not found: $config_path "
225+ return 1
226+ fi
227+
228+ # Resolve paths
229+ config_path=$( realpath " $config_path " )
230+
231+ local config_file_in_container=" /config/config.yml"
232+ local host_config_dir
233+
234+ if [ -d " $config_path " ]; then
235+ host_config_dir=" $config_path "
236+ print_info " Config mode: directory mounting - looking for config.yml in $config_path "
237+ else
238+ host_config_dir=$( dirname " $config_path " )
239+ config_file_in_container=" /config/$( basename " $config_path " ) "
240+ print_info " Config mode: file mounting - using $( basename " $config_path " ) from $host_config_dir "
241+ fi
242+
243+ # Resolve scan path if not Linux-style
244+ if [[ ! " $scan_path " =~ ^/ ]]; then
245+ if [ ! -e " $scan_path " ]; then
246+ print_error " Scan path not found: $scan_path "
247+ return 1
248+ fi
249+ scan_path=$( realpath " $scan_path " )
250+ fi
251+
252+ print_info " Running FastFinder in container 'runtime' (privileged for drive discovery)..."
253+
254+ # Remove existing container if present
255+ docker rm -f runtime > /dev/null 2>&1 || true
256+
257+ # Build docker run command
258+ local docker_cmd=(docker run --rm -it --name runtime --privileged --pid=host)
259+ docker_cmd+=(--cap-add SYS_ADMIN --cap-add SYS_RAWIO)
260+ docker_cmd+=(-e " FASTFINDER_DISABLE_MUTEX=1" )
261+ docker_cmd+=(-v " ${host_config_dir} :/config" )
262+ docker_cmd+=(-v " ${scan_path} :/scan:ro" )
263+
264+ if [ " $interactive " = true ]; then
265+ docker_cmd+=(--entrypoint /bin/bash fastfinder:runtime)
266+ else
267+ docker_cmd+=(fastfinder:runtime -c " $config_file_in_container " )
268+ if [ " $triage " = true ]; then
269+ docker_cmd+=(-t)
270+ print_info " Triage mode enabled - continuous monitoring active"
271+ fi
272+ fi
273+
274+ " ${docker_cmd[@]} "
275+ }
276+
152277# Clean up Docker build cache
153278clean_docker () {
154- print_warning " Cleaning up Docker build cache..."
279+ print_warning " Cleaning up FastFinder Docker resources..."
280+
281+ # Remove FastFinder runtime containers
282+ print_info " Removing FastFinder containers..."
283+ local containers=$( docker ps -a --filter " name=runtime" --format " {{.ID}}" 2> /dev/null || true)
284+ if [ -n " $containers " ]; then
285+ docker rm -f $containers > /dev/null 2>&1 || true
286+ print_success " Removed FastFinder containers"
287+ else
288+ print_info " No FastFinder containers found"
289+ fi
155290
156- # Prune build cache
157- print_info " Pruning Docker build cache..."
158- docker builder prune -f
291+ # Remove FastFinder images
292+ print_info " Removing FastFinder images..."
293+ local images=$( docker images --filter " reference=fastfinder:*" --format " {{.ID}}" 2> /dev/null || true)
294+ if [ -n " $images " ]; then
295+ docker rmi -f $images > /dev/null 2>&1 || true
296+ print_success " Removed FastFinder images"
297+ else
298+ print_info " No FastFinder images found"
299+ fi
300+
301+ # Optional: prune all build cache (affects all projects!)
302+ print_warning " To clean ALL Docker build cache (all projects), run: docker builder prune -f"
159303
160- print_success " Cleanup complete!"
304+ print_success " FastFinder cleanup complete!"
161305}
162306
163307# Main logic
@@ -171,6 +315,13 @@ case "${1:-help}" in
171315 build-windows)
172316 build_windows
173317 ;;
318+ build-runtime)
319+ build_runtime
320+ ;;
321+ run-runtime)
322+ shift
323+ run_runtime " $@ "
324+ ;;
174325 clean)
175326 clean_docker
176327 ;;
0 commit comments