@@ -15,16 +15,11 @@ from typing import TYPE_CHECKING, Any, List, Optional
1515
1616import yaml
1717
18- CompletedProcess = (
19- subprocess .CompletedProcess [str ] if TYPE_CHECKING else subprocess .CompletedProcess
20- )
18+ CompletedProcess = subprocess .CompletedProcess [str ] if TYPE_CHECKING else subprocess .CompletedProcess
2119
2220
2321def run (
24- args : argparse .Namespace ,
25- command : List [str ],
26- exit_on_error : bool = True ,
27- ** kwargs : Any ,
22+ args : argparse .Namespace , command : List [str ], exit_on_error : bool = True , ** kwargs : Any
2823) -> Optional [CompletedProcess ]:
2924 if args .verbose or args .dry_run :
3025 print (shlex .join (command ))
@@ -41,25 +36,15 @@ def run(
4136
4237def main () -> None :
4338 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" )
4441 parser .add_argument (
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" ,
42+ "--dry-run" , action = "store_true" , help = "Display the docker build commands without executing them"
5443 )
5544 parser .add_argument ("--service" , help = "Build only the specified service" )
5645 parser .add_argument ("--env" , action = "store_true" , help = "Build only the .env file" )
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- )
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" )
6348 parser .add_argument ("--upgrade" , help = "Start upgrading the project to version" )
6449 parser .add_argument (
6550 "--reload" ,
@@ -75,12 +60,9 @@ def main() -> None:
7560 help = "Do not pull external or base images for faster rebuild during development." ,
7661 )
7762 parser .add_argument (
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"
63+ "--debug" , help = "Path to c2cgeoportal source folder to be able to debug the upgrade procedure"
8364 )
65+ parser .add_argument ("--stack-trace" , action = "store_true" , help = "Display the stack trace on error" )
8466 parser .add_argument ("env_files" , nargs = "*" , help = "The environment config" )
8567 args = parser .parse_args ()
8668
@@ -142,11 +124,7 @@ def main() -> None:
142124 if args .not_simple :
143125 simple = False
144126
145- git_hash = (
146- run (args , ["git" , "rev-parse" , "HEAD" ], stdout = subprocess .PIPE )
147- .stdout .decode ()
148- .strip ()
149- )
127+ git_hash = run (args , ["git" , "rev-parse" , "HEAD" ], stdout = subprocess .PIPE ).stdout .decode ().strip ()
150128
151129 dest .write (f"SIMPLE={ str (simple ).upper ()} \n " )
152130 dest .write (f"GIT_HASH={ git_hash } \n " )
@@ -165,9 +143,7 @@ def main() -> None:
165143 if not args .no_pull :
166144 # Pull all the images
167145 if not args .service :
168- run (
169- args , [* docker_compose_command , "pull" , "--ignore-buildable" ]
170- ) # nosec
146+ run (args , [* docker_compose_command , "pull" , "--ignore-buildable" ]) # nosec
171147 docker_compose_build_cmd .append ("--pull" )
172148
173149 if args .service :
@@ -205,16 +181,7 @@ def main() -> None:
205181 if args .reload is not None :
206182 run (args , [* docker_compose_command , "rm" , "--force" , "-v" , "config" ])
207183 for service in services :
208- run (
209- args ,
210- [
211- * docker_compose_command ,
212- "up" ,
213- "--detach" ,
214- "--force-recreate" ,
215- service ,
216- ],
217- )
184+ run (args , [* docker_compose_command , "up" , "--detach" , "--force-recreate" , service ])
218185
219186
220187if __name__ == "__main__" :
0 commit comments