@@ -15,11 +15,16 @@ from typing import TYPE_CHECKING, Any, List, Optional
1515
1616import yaml
1717
18- CompletedProcess = subprocess .CompletedProcess [str ] if TYPE_CHECKING else subprocess .CompletedProcess
18+ CompletedProcess = (
19+ subprocess .CompletedProcess [str ] if TYPE_CHECKING else subprocess .CompletedProcess
20+ )
1921
2022
2123def run (
22- args : argparse .Namespace , command : List [str ], exit_on_error : bool = True , ** kwargs : Any
24+ args : argparse .Namespace ,
25+ command : List [str ],
26+ exit_on_error : bool = True ,
27+ ** kwargs : Any ,
2328) -> Optional [CompletedProcess ]:
2429 if args .verbose or args .dry_run :
2530 print (shlex .join (command ))
@@ -36,15 +41,25 @@ def run(
3641
3742def main () -> None :
3843 parser = argparse .ArgumentParser (description = "Build the project" )
39- parser .add_argument ("--verbose" , action = "store_true" , help = "Display the Docker build commands" )
40- parser .add_argument ("--no-cache" , action = "store_true" , help = "Disable docker cache on build" )
4144 parser .add_argument (
42- "--dry-run" , action = "store_true" , help = "Display the docker build commands without executing them"
45+ "--verbose" , action = "store_true" , help = "Display the Docker build commands"
46+ )
47+ parser .add_argument (
48+ "--no-cache" , action = "store_true" , help = "Disable docker cache on build"
49+ )
50+ parser .add_argument (
51+ "--dry-run" ,
52+ action = "store_true" ,
53+ help = "Display the docker build commands without executing them" ,
4354 )
4455 parser .add_argument ("--service" , help = "Build only the specified service" )
4556 parser .add_argument ("--env" , action = "store_true" , help = "Build only the .env file" )
46- parser .add_argument ("--simple" , action = "store_true" , help = "Force simple application mode" )
47- parser .add_argument ("--not-simple" , action = "store_true" , help = "Force not simple application mode" )
57+ parser .add_argument (
58+ "--simple" , action = "store_true" , help = "Force simple application mode"
59+ )
60+ parser .add_argument (
61+ "--not-simple" , action = "store_true" , help = "Force not simple application mode"
62+ )
4863 parser .add_argument ("--upgrade" , help = "Start upgrading the project to version" )
4964 parser .add_argument (
5065 "--reload" ,
@@ -60,9 +75,12 @@ def main() -> None:
6075 help = "Do not pull external or base images for faster rebuild during development." ,
6176 )
6277 parser .add_argument (
63- "--debug" , help = "Path to c2cgeoportal source folder to be able to debug the upgrade procedure"
78+ "--debug" ,
79+ help = "Path to c2cgeoportal source folder to be able to debug the upgrade procedure" ,
80+ )
81+ parser .add_argument (
82+ "--stack-trace" , action = "store_true" , help = "Display the stack trace on error"
6483 )
65- parser .add_argument ("--stack-trace" , action = "store_true" , help = "Display the stack trace on error" )
6684 parser .add_argument ("env_files" , nargs = "*" , help = "The environment config" )
6785 args = parser .parse_args ()
6886
@@ -124,7 +142,11 @@ def main() -> None:
124142 if args .not_simple :
125143 simple = False
126144
127- git_hash = run (args , ["git" , "rev-parse" , "HEAD" ], stdout = subprocess .PIPE ).stdout .decode ().strip ()
145+ git_hash = (
146+ run (args , ["git" , "rev-parse" , "HEAD" ], stdout = subprocess .PIPE )
147+ .stdout .decode ()
148+ .strip ()
149+ )
128150
129151 dest .write (f"SIMPLE={ str (simple ).upper ()} \n " )
130152 dest .write (f"GIT_HASH={ git_hash } \n " )
@@ -143,7 +165,9 @@ def main() -> None:
143165 if not args .no_pull :
144166 # Pull all the images
145167 if not args .service :
146- run (args , [* docker_compose_command , "pull" , "--ignore-buildable" ]) # nosec
168+ run (
169+ args , [* docker_compose_command , "pull" , "--ignore-buildable" ]
170+ ) # nosec
147171 docker_compose_build_cmd .append ("--pull" )
148172
149173 if args .service :
@@ -181,7 +205,16 @@ def main() -> None:
181205 if args .reload is not None :
182206 run (args , [* docker_compose_command , "rm" , "--force" , "-v" , "config" ])
183207 for service in services :
184- run (args , [* docker_compose_command , "up" , "--detach" , "--force-recreate" , service ])
208+ run (
209+ args ,
210+ [
211+ * docker_compose_command ,
212+ "up" ,
213+ "--detach" ,
214+ "--force-recreate" ,
215+ service ,
216+ ],
217+ )
185218
186219
187220if __name__ == "__main__" :
0 commit comments