diff --git a/platypush/platydock/__init__.py b/platypush/platydock/__init__.py index e2acabff6d..8f4591edaa 100755 --- a/platypush/platydock/__init__.py +++ b/platypush/platydock/__init__.py @@ -36,6 +36,31 @@ class DockerfileGenerator: BaseImage.UBUNTU: PackageManagers.APT, } + _header = textwrap.dedent( + """ + # This Dockerfile was automatically generated by Platydock. + # + # You can build a Platypush image from it by running + # `docker build -t platypush .` in the same folder as this file, + # or copy it to the root a Platypush source folder to install the + # checked out version instead of downloading it first. + # + # You can then run your new image through: + # docker run --rm --name platypush \\ + # -v /path/to/your/config/dir:/etc/platypush \\ + # -v /path/to/your/workdir:/var/lib/platypush \\ + # -p 8080:8080 \\ + # platypush\n + """ + ) + + _footer = textwrap.dedent( + """ + # You can customize the name of your installation by passing + # --device-id=... to the launched command. + """ + ) + def __init__(self, cfgfile: str, image: BaseImage, gitref: str) -> None: self.cfgfile = os.path.abspath(os.path.expanduser(cfgfile)) self.image = image @@ -72,6 +97,8 @@ class DockerfileGenerator: with open(base_file, 'r') as f: file_lines = [line.rstrip() for line in f.readlines()] + new_file_lines.extend(self._header.split('\n')) + for line in file_lines: if re.match( r'RUN /install/platypush/install/scripts/[A-Za-z0-9_-]+/install.sh', @@ -96,6 +123,8 @@ class DockerfileGenerator: is_after_expose_cmd = True continue + elif line.startswith('CMD'): + new_file_lines.extend(self._footer.split('\n')) new_file_lines.append(line)