@@ -114,6 +114,7 @@ def get_argparser():
114
114
115
115
argparser .add_argument (
116
116
"--ref" ,
117
+ default = None ,
117
118
help = (
118
119
"Reference to build instead of default reference. For example"
119
120
" branch name or commit for a Git repository."
@@ -129,6 +130,14 @@ def get_argparser():
129
130
help = "Do not actually build the image. Useful in conjunction with --debug." ,
130
131
)
131
132
133
+ argparser .add_argument (
134
+ "--build" ,
135
+ dest = "build" ,
136
+ action = "store_true" ,
137
+ help = "Build the image (default)" ,
138
+ )
139
+ argparser .set_defaults (build = None )
140
+
132
141
argparser .add_argument (
133
142
"--build-memory-limit" ,
134
143
help = "Total Memory that can be used by the docker build process" ,
@@ -147,6 +156,14 @@ def get_argparser():
147
156
help = "Do not run container after it has been built" ,
148
157
)
149
158
159
+ argparser .add_argument (
160
+ "--run" ,
161
+ dest = "run" ,
162
+ action = "store_true" ,
163
+ help = "Run container after it has been built (default)." ,
164
+ )
165
+ argparser .set_defaults (run = None )
166
+
150
167
argparser .add_argument (
151
168
"--publish" ,
152
169
"-p" ,
@@ -181,6 +198,13 @@ def get_argparser():
181
198
action = "store_true" ,
182
199
help = "Push docker image to repository" ,
183
200
)
201
+ argparser .add_argument (
202
+ "--no-push" ,
203
+ dest = "push" ,
204
+ action = "store_false" ,
205
+ help = "Don't push docker image to repository (default)." ,
206
+ )
207
+ argparser .set_defaults (push = None )
184
208
185
209
argparser .add_argument (
186
210
"--volume" ,
@@ -298,8 +322,14 @@ def make_r2d(argv=None):
298
322
key , _ , val = a .partition ("=" )
299
323
r2d .extra_build_args [key ] = val
300
324
325
+ # repo is a required arg, and should never come from config:
326
+ if "repo" in r2d .config .Repo2Docker :
327
+ r2d .log .warning (
328
+ f"Ignoring Repo2Docker.repo={ r2d .repo !r} configuration, using { args .repo !r} from CLI."
329
+ )
301
330
r2d .repo = args .repo
302
- r2d .ref = args .ref
331
+ if args .ref is not None :
332
+ r2d .ref = args .ref
303
333
304
334
# user wants to mount a local directory into the container for
305
335
# editing
@@ -320,22 +350,22 @@ def make_r2d(argv=None):
320
350
321
351
if args .image_name :
322
352
r2d .output_image_spec = args .image_name
323
- else :
324
- # we will pick a name after fetching the repository
325
- r2d .output_image_spec = ""
326
353
327
354
if args .json_logs is not None :
328
355
r2d .json_logs = args .json_logs
329
356
330
- r2d .dry_run = not args .build
357
+ if args .build is not None :
358
+ r2d .dry_run = not args .build
331
359
332
360
if r2d .dry_run :
333
361
# Can't push nor run if we aren't building
334
362
args .run = False
335
363
args .push = False
336
364
337
- r2d .run = args .run
338
- r2d .push = args .push
365
+ if args .run is not None :
366
+ r2d .run = args .run
367
+ if args .push is not None :
368
+ r2d .push = args .push
339
369
340
370
# check against r2d.run and not args.run as r2d.run is false on
341
371
# --no-build. Also r2d.volumes and not args.volumes since --editable
0 commit comments