@@ -18,6 +18,18 @@ fn try_main() -> Result<(), DynError> {
1818 match task. as_deref ( ) {
1919 Some ( "clean" ) => clean ( ) ?,
2020 Some ( "dist" ) => dist ( ) ?,
21+ Some ( "build-docker" ) => build_docker ( ) ?,
22+ Some ( "run-docker" ) => {
23+ let Some ( data_dir) = env:: args ( ) . nth ( 2 ) else {
24+ eprintln ! ( "data_dir is required" ) ;
25+ std:: process:: exit ( -1 ) ;
26+ } ;
27+ let Some ( workspace_dir) = env:: args ( ) . nth ( 3 ) else {
28+ eprintln ! ( "workspace_dir is required" ) ;
29+ std:: process:: exit ( -1 ) ;
30+ } ;
31+ run_docker ( & data_dir, & workspace_dir) ?;
32+ }
2133 _ => print_help ( ) ,
2234 }
2335 Ok ( ( ) )
@@ -27,19 +39,18 @@ fn print_help() {
2739 eprintln ! (
2840 "Tasks:
2941
30- clean cleans project directory from logs and artifacts
31- dist builds application
42+ clean cleans project directory from logs and artifacts
43+ dist builds application
44+ build-docker builds docker image
45+ run-docker <data_dir> <workspace_dir> runs docker image
3246"
3347 )
3448}
3549
3650fn clean ( ) -> Result < ( ) , DynError > {
37- let _ = fs:: remove_dir_all ( project_root ( ) . join ( "logs " ) ) ;
51+ let _ = fs:: remove_dir_all ( project_root ( ) . join ( "data " ) ) ;
3852 let _ = fs:: remove_dir_all ( project_root ( ) . join ( ".fastembed_cache" ) ) ;
3953 let _ = fs:: remove_dir_all ( project_root ( ) . join ( "target/workspace" ) ) ;
40- let _ = fs:: remove_file ( project_root ( ) . join ( "memory.yaml" ) ) ;
41- let _ = fs:: remove_file ( project_root ( ) . join ( "history.json" ) ) ;
42- let _ = fs:: remove_file ( project_root ( ) . join ( "openrouter_models.json" ) ) ;
4354 Ok ( ( ) )
4455}
4556
@@ -85,6 +96,35 @@ fn dist_binary() -> Result<(), DynError> {
8596 Ok ( ( ) )
8697}
8798
99+ fn build_docker ( ) -> Result < ( ) , DynError > {
100+ let _ = Command :: new ( "docker" )
101+ . arg ( "build" )
102+ . arg ( "-t" )
103+ . arg ( "huly-coder" )
104+ . arg ( "-f" )
105+ . arg ( "./Dockerfile" )
106+ . arg ( "." )
107+ . status ( ) ?;
108+ Ok ( ( ) )
109+ }
110+
111+ fn run_docker ( data_dir : & str , workspace_dir : & str ) -> Result < ( ) , DynError > {
112+ let _ = Command :: new ( "docker" )
113+ . arg ( "run" )
114+ . arg ( "-it" )
115+ . arg ( "--rm" )
116+ . arg ( "-v" )
117+ . arg ( format ! ( "{}:/target/workspace" , workspace_dir) )
118+ . arg ( "-v" )
119+ . arg ( format ! ( "{}:/data" , data_dir) )
120+ . arg ( "-v" )
121+ . arg ( format ! ( "{}/.fastembed_cache:/.fastembed_cache" , data_dir) )
122+ . arg ( "huly-coder" )
123+ . status ( ) ?;
124+
125+ Ok ( ( ) )
126+ }
127+
88128fn project_root ( ) -> PathBuf {
89129 Path :: new ( & env ! ( "CARGO_MANIFEST_DIR" ) )
90130 . ancestors ( )
0 commit comments