diff options
| author | Sean Mooney <sean.k.mooney@intel.com> | 2017-05-19 00:20:41 +0000 |
|---|---|---|
| committer | Sean Mooney <sean.k.mooney@intel.com> | 2017-07-10 18:20:05 +0000 |
| commit | 79a234239516b94b1b79c7ddafcc4fbe4e3ba155 (patch) | |
| tree | 4d8220f1c2e0f373da3a4b0cd9d93d25b3dd4d83 /kolla | |
| parent | c2c457c28201f551d9bc401f562c17ba2ac6eb36 (diff) | |
| download | kolla-79a234239516b94b1b79c7ddafcc4fbe4e3ba155.tar.gz kolla-79a234239516b94b1b79c7ddafcc4fbe4e3ba155.zip | |
enable the kolla build system to use out of tree docker files
- This change introduces a docker-dir config option to enable
specifying an out of tree additional docker file
root dir for use with kolla build.
- This change allows kolla's build system to be reused by non kolla
or external project to build arbitrary docker images using jinja2
templatized docker files.
Co-Authored-By: Michal (inc0) Jastrzebski <inc007@gmail.com>
Change-Id: Idbba02a8910866ef1b838e5cbac3ab230551b7e5
Diffstat (limited to 'kolla')
| -rwxr-xr-x | kolla/common/config.py | 3 | ||||
| -rwxr-xr-x | kolla/image/build.py | 16 |
2 files changed, 18 insertions, 1 deletions
diff --git a/kolla/common/config.py b/kolla/common/config.py index 2db6f5e7d..a214c1b37 100755 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -246,6 +246,9 @@ _CLI_OPTS = [ help='Time in seconds after which any operation times out'), cfg.MultiOpt('template-override', types.String(), help='Path to template override file'), + cfg.MultiOpt('docker-dir', types.String(), + help='Path to additional docker file template directory', + short='D', default=[]), cfg.StrOpt('logs-dir', help='Path to logs directory'), cfg.BoolOpt('pull', default=True, help='Attempt to pull a newer version of the base image'), diff --git a/kolla/image/build.py b/kolla/image/build.py index 262513a2e..db218e7a6 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -643,6 +643,18 @@ class KollaWorker(object): os.path.join(self.working_dir, "base", "apt_preferences") ) + def copy_dir(self, src, dest): + if not os.path.isdir(dest): + shutil.copytree(src, dest) + else: + for file in os.listdir(src): + src_path = os.path.join(src, file) + dest_path = os.path.join(dest, file) + if os.path.isdir(src_path): + self.copy_dir(src_path, dest_path) + else: + shutil.copy2(src_path, dest_path) + def setup_working_dir(self): """Creates a working directory for use while building.""" if self.conf.work_dir: @@ -653,7 +665,9 @@ class KollaWorker(object): '%Y-%m-%d_%H-%M-%S_') self.temp_dir = tempfile.mkdtemp(prefix='kolla-' + ts) self.working_dir = os.path.join(self.temp_dir, 'docker') - shutil.copytree(self.images_dir, self.working_dir) + self.copy_dir(self.images_dir, self.working_dir) + for dir in self.conf.docker_dir: + self.copy_dir(dir, self.working_dir) self.copy_apt_files() LOG.debug('Created working dir: %s', self.working_dir) |
