diff --git a/platypush/platydock/__init__.py b/platypush/platydock/__init__.py index a39969a2..59d2e342 100755 --- a/platypush/platydock/__init__.py +++ b/platypush/platydock/__init__.py @@ -66,13 +66,25 @@ def generate_dockerfile(deps, ports, cfgfile, devdir): RUN mkdir -p /usr/local/share/platypush\n ''').lstrip() + srcdir = os.path.dirname(cfgfile) cfgfile_copy = os.path.join(devdir, 'config.yaml') - with open(cfgfile) as src_f: - with open(cfgfile_copy, 'w') as dest_f: - for line in src_f: - dest_f.write(line) + subprocess.call(['cp', cfgfile, cfgfile_copy]) + content += 'COPY config.yaml /etc/platypush/\n' + + for include in Config._included_files: + incdir = os.path.relpath(os.path.dirname(include), srcdir) + destdir = os.path.join(devdir, incdir) + + try: + os.makedirs(destdir) + except FileExistsError: + pass + + subprocess.call(['cp', include, destdir]) + content += 'RUN mkdir -p /etc/platypush/' + incdir + '\n' + content += 'COPY ' + os.path.relpath(include, srcdir) + \ + ' /etc/platypush/' + incdir + '\n' - content += 'COPY config.yaml /etc/platypush/' content += textwrap.dedent( '''