kszucs commented on a change in pull request #7021: URL: https://github.com/apache/arrow/pull/7021#discussion_r420016943
########## File path: dev/archery/archery/docker.py ########## @@ -0,0 +1,186 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import os +import subprocess + +from dotenv import dotenv_values +from ruamel.yaml import YAML + +from .utils.command import Command, default_bin +from .compat import _ensure_path + + +def flatten(node, parents=None): + parents = list(parents or []) + if isinstance(node, str): + yield (node, parents) + elif isinstance(node, list): + for value in node: + yield from flatten(value, parents=parents) + elif isinstance(node, dict): + for key, value in node.items(): + yield (key, parents) + yield from flatten(value, parents=parents + [key]) + else: + raise TypeError(node) + + +class UndefinedImage(Exception): + pass + + +class Docker(Command): + + def __init__(self, docker_bin=None): + self.bin = default_bin(docker_bin, "docker") + + +class DockerCompose(Command): + + def __init__(self, config_path, dotenv_path=None, compose_bin=None, + params=None): + self.config_path = _ensure_path(config_path) + if dotenv_path: + self.dotenv_path = _ensure_path(dotenv_path) + else: + self.dotenv_path = self.config_path.parent / '.env' + + yaml = YAML() + with self.config_path.open() as fp: + self.config = yaml.load(fp) + + self.bin = default_bin(compose_bin, 'docker-compose') + self.nodes = dict(flatten(self.config['x-hierarchy'])) + self.dotenv = dotenv_values(str(self.dotenv_path)) + if params is None: + self.params = {} + else: + self.params = {k: v for k, v in params.items() if k in self.dotenv} + + # forward the process' environment variables Review comment: Try `UBUNTU=20.04 archery docker run ubuntu-cpp`. The `conda-cpp` image always depend on ubuntu 18.04 so the `UBUNTU` env variable is ignored. Raising a warning about it would need to parse out the arguments used in that particular docker-compose service. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org