@@ -46,10 +46,19 @@ def _execute(self, *args, **kwargs):
46
46
callback = validate_arrow_sources ,
47
47
help = "Specify Arrow source directory." )
48
48
@click .option ('--dry-run/--execute' , default = False ,
49
- help = "Display the docker-compose commands instead of executing "
50
- "them." )
49
+ help = "Display the docker commands instead of executing them." )
50
+ @click .option ('--using-docker-cli' , default = False , is_flag = True ,
51
+ envvar = 'ARCHERY_USE_DOCKER_CLI' ,
52
+ help = "Use docker CLI directly for building instead of calling "
53
+ "docker-compose. This may help to reuse cached layers." )
54
+ @click .option ('--using-docker-buildx' , default = False , is_flag = True ,
55
+ envvar = 'ARCHERY_USE_DOCKER_BUILDX' ,
56
+ help = "Use buildx with docker CLI directly for building instead "
57
+ "of calling docker-compose or the plain docker build "
58
+ "command. This option makes the build cache reusable "
59
+ "across hosts." )
51
60
@click .pass_context
52
- def docker (ctx , src , dry_run ):
61
+ def docker (ctx , src , dry_run , using_docker_cli , using_docker_buildx ):
53
62
"""
54
63
Interact with docker-compose based builds.
55
64
"""
@@ -64,7 +73,10 @@ def docker(ctx, src, dry_run):
64
73
65
74
# take the docker-compose parameters like PYTHON, PANDAS, UBUNTU from the
66
75
# environment variables to keep the usage similar to docker-compose
76
+ using_docker_cli |= using_docker_buildx
67
77
compose = DockerCompose (config_path , params = os .environ ,
78
+ using_docker = using_docker_cli ,
79
+ using_buildx = using_docker_buildx ,
68
80
debug = ctx .obj .get ('debug' , False ))
69
81
if dry_run :
70
82
_mock_compose_calls (compose )
@@ -83,24 +95,19 @@ def check_config(obj):
83
95
84
96
@docker .command ('pull' )
85
97
@click .argument ('image' )
86
- @click .option ('--using-docker-cli' , default = False , is_flag = True ,
87
- envvar = 'ARCHERY_USE_DOCKER_CLI' ,
88
- help = "Use docker CLI directly for pulling instead of calling "
89
- "docker-compose. This may help to reuse cached layers." )
90
98
@click .option ('--pull-leaf/--no-leaf' , default = True ,
91
99
help = "Whether to pull leaf images too." )
92
100
@click .option ('--ignore-pull-failures/--no-ignore-pull-failures' , default = True ,
93
101
help = "Whether to ignore pull failures." )
94
102
@click .pass_obj
95
- def docker_pull (obj , image , * , using_docker_cli , pull_leaf ,
96
- ignore_pull_failures ):
103
+ def docker_pull (obj , image , * , pull_leaf , ignore_pull_failures ):
97
104
"""
98
105
Execute docker-compose pull.
99
106
"""
100
107
compose = obj ['compose' ]
101
108
102
109
try :
103
- compose .pull (image , pull_leaf = pull_leaf , using_docker = using_docker_cli ,
110
+ compose .pull (image , pull_leaf = pull_leaf ,
104
111
ignore_pull_failures = ignore_pull_failures )
105
112
except UndefinedImage as e :
106
113
raise click .ClickException (
@@ -115,16 +122,6 @@ def docker_pull(obj, image, *, using_docker_cli, pull_leaf,
115
122
@click .argument ('image' )
116
123
@click .option ('--force-pull/--no-pull' , default = True ,
117
124
help = "Whether to force pull the image and its ancestor images" )
118
- @click .option ('--using-docker-cli' , default = False , is_flag = True ,
119
- envvar = 'ARCHERY_USE_DOCKER_CLI' ,
120
- help = "Use docker CLI directly for building instead of calling "
121
- "docker-compose. This may help to reuse cached layers." )
122
- @click .option ('--using-docker-buildx' , default = False , is_flag = True ,
123
- envvar = 'ARCHERY_USE_DOCKER_BUILDX' ,
124
- help = "Use buildx with docker CLI directly for building instead "
125
- "of calling docker-compose or the plain docker build "
126
- "command. This option makes the build cache reusable "
127
- "across hosts." )
128
125
@click .option ('--use-cache/--no-cache' , default = True ,
129
126
help = "Whether to use cache when building the image and its "
130
127
"ancestor images" )
@@ -133,22 +130,17 @@ def docker_pull(obj, image, *, using_docker_cli, pull_leaf,
133
130
"passed as the argument. To disable caching for both the "
134
131
"image and its ancestors use --no-cache option." )
135
132
@click .pass_obj
136
- def docker_build (obj , image , * , force_pull , using_docker_cli ,
137
- using_docker_buildx , use_cache , use_leaf_cache ):
133
+ def docker_build (obj , image , * , force_pull , use_cache , use_leaf_cache ):
138
134
"""
139
135
Execute docker-compose builds.
140
136
"""
141
137
compose = obj ['compose' ]
142
138
143
- using_docker_cli |= using_docker_buildx
144
139
try :
145
140
if force_pull :
146
- compose .pull (image , pull_leaf = use_leaf_cache ,
147
- using_docker = using_docker_cli )
141
+ compose .pull (image , pull_leaf = use_leaf_cache )
148
142
compose .build (image , use_cache = use_cache ,
149
143
use_leaf_cache = use_leaf_cache ,
150
- using_docker = using_docker_cli ,
151
- using_buildx = using_docker_buildx ,
152
144
pull_parents = force_pull )
153
145
except UndefinedImage as e :
154
146
raise click .ClickException (
@@ -172,16 +164,6 @@ def docker_build(obj, image, *, force_pull, using_docker_cli,
172
164
help = "Whether to force build the image and its ancestor images" )
173
165
@click .option ('--build-only' , default = False , is_flag = True ,
174
166
help = "Pull and/or build the image, but do not run it" )
175
- @click .option ('--using-docker-cli' , default = False , is_flag = True ,
176
- envvar = 'ARCHERY_USE_DOCKER_CLI' ,
177
- help = "Use docker CLI directly for building instead of calling "
178
- "docker-compose. This may help to reuse cached layers." )
179
- @click .option ('--using-docker-buildx' , default = False , is_flag = True ,
180
- envvar = 'ARCHERY_USE_DOCKER_BUILDX' ,
181
- help = "Use buildx with docker CLI directly for building instead "
182
- "of calling docker-compose or the plain docker build "
183
- "command. This option makes the build cache reusable "
184
- "across hosts." )
185
167
@click .option ('--use-cache/--no-cache' , default = True ,
186
168
help = "Whether to use cache when building the image and its "
187
169
"ancestor images" )
@@ -191,16 +173,16 @@ def docker_build(obj, image, *, force_pull, using_docker_cli,
191
173
"image and its ancestors use --no-cache option." )
192
174
@click .option ('--resource-limit' , default = None ,
193
175
help = "A CPU/memory limit preset to mimic CI environments like "
194
- "GitHub Actions. Implies --using-docker-cli. Note that "
176
+ "GitHub Actions. Mandates --using-docker-cli. Note that "
195
177
"exporting ARCHERY_DOCKER_BIN=\" sudo docker\" is likely "
196
178
"required, unless Docker is configured with cgroups v2 "
197
179
"(else Docker will silently ignore the limits)." )
198
180
@click .option ('--volume' , '-v' , multiple = True ,
199
181
help = "Set volume within the container" )
200
182
@click .pass_obj
201
183
def docker_run (obj , image , command , * , env , user , force_pull , force_build ,
202
- build_only , using_docker_cli , using_docker_buildx , use_cache ,
203
- use_leaf_cache , resource_limit , volume ):
184
+ build_only , use_cache , use_leaf_cache , resource_limit ,
185
+ volume ):
204
186
"""
205
187
Execute docker-compose builds.
206
188
@@ -234,26 +216,21 @@ def docker_run(obj, image, command, *, env, user, force_pull, force_build,
234
216
archery docker run ubuntu-cpp bash
235
217
"""
236
218
compose = obj ['compose' ]
237
- using_docker_cli |= using_docker_buildx
238
219
239
220
env = dict (kv .split ('=' , 1 ) for kv in env )
240
221
try :
241
222
if force_pull :
242
- compose .pull (image , pull_leaf = use_leaf_cache ,
243
- using_docker = using_docker_cli )
223
+ compose .pull (image , pull_leaf = use_leaf_cache )
244
224
if force_build :
245
225
compose .build (image , use_cache = use_cache ,
246
- use_leaf_cache = use_leaf_cache ,
247
- using_docker = using_docker_cli ,
248
- using_buildx = using_docker_buildx )
226
+ use_leaf_cache = use_leaf_cache )
249
227
if build_only :
250
228
return
251
229
compose .run (
252
230
image ,
253
231
command = command ,
254
232
env = env ,
255
233
user = user ,
256
- using_docker = using_docker_cli ,
257
234
resource_limit = resource_limit ,
258
235
volumes = volume
259
236
)
@@ -273,15 +250,11 @@ def docker_run(obj, image, command, *, env, user, force_pull, force_build,
273
250
@click .option ('--password' , '-p' , required = False ,
274
251
envvar = 'ARCHERY_DOCKER_PASSWORD' ,
275
252
help = 'Docker repository password' )
276
- @click .option ('--using-docker-cli' , default = False , is_flag = True ,
277
- help = "Use docker CLI directly for building instead of calling "
278
- "docker-compose. This may help to reuse cached layers." )
279
253
@click .pass_obj
280
- def docker_compose_push (obj , image , user , password , using_docker_cli ):
254
+ def docker_compose_push (obj , image , user , password ):
281
255
"""Push the generated docker-compose image."""
282
256
compose = obj ['compose' ]
283
- compose .push (image , user = user , password = password ,
284
- using_docker = using_docker_cli )
257
+ compose .push (image , user = user , password = password )
285
258
286
259
287
260
@docker .command ('images' )
0 commit comments