@@ -21,17 +21,22 @@ async fn image_exists(docker: &Docker, image_name: &str) -> bool {
2121}
2222
2323/// Build the custom Grafana image if it doesn't exist
24- async fn build_grafana_image_if_needed ( docker : & Docker , image_name : & str ) {
24+ async fn build_grafana_image_if_needed (
25+ docker : & Docker ,
26+ image_name : & str ,
27+ dockerfile_content : & str ,
28+ ) {
2529 if image_exists ( docker, image_name) . await {
2630 println ! ( "[*] Using cached Grafana image: {}" , image_name) ;
2731 return ;
2832 }
2933
30- let build_context = "docker/grafana" ;
34+ let build_context = embed_files:: setup_dockerfile ( dockerfile_content) ;
35+ let build_context_str = build_context. to_str ( ) . unwrap ( ) ;
3136
3237 println ! ( "[*] Building custom Grafana image..." ) ;
3338 let output = Command :: new ( "docker" )
34- . args ( [ "build" , "-t" , image_name, build_context ] )
39+ . args ( [ "build" , "-t" , image_name, build_context_str ] )
3540 . output ( )
3641 . expect ( "[-] Failed to execute docker build" ) ;
3742
@@ -51,6 +56,7 @@ pub async fn start_container<'a>(
5156 report_db_path : & Path ,
5257 embedded_dir : & Dir < ' a > ,
5358 embedded_file : & str ,
59+ dockerfile_content : & str ,
5460) {
5561 if !report_db_path. exists ( ) {
5662 eprintln ! ( "[*] Error: The specified report.db path does not exist." ) ;
@@ -103,7 +109,7 @@ pub async fn start_container<'a>(
103109
104110 // Build the custom Grafana image if it doesn't exist
105111 let image_name = "wuppiefuzz-grafana:latest" ;
106- build_grafana_image_if_needed ( docker, image_name) . await ;
112+ build_grafana_image_if_needed ( docker, image_name, dockerfile_content ) . await ;
107113
108114 // Create the container
109115 let mut create_options = ContainerCreateOptions :: new ( image_name) ;
0 commit comments