forked from platypush/platypush
Added header and footer to generated Dockerfile.
This commit is contained in:
parent
f66c4aa071
commit
700b8e1d16
1 changed files with 29 additions and 0 deletions
|
@ -36,6 +36,31 @@ class DockerfileGenerator:
|
||||||
BaseImage.UBUNTU: PackageManagers.APT,
|
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:
|
def __init__(self, cfgfile: str, image: BaseImage, gitref: str) -> None:
|
||||||
self.cfgfile = os.path.abspath(os.path.expanduser(cfgfile))
|
self.cfgfile = os.path.abspath(os.path.expanduser(cfgfile))
|
||||||
self.image = image
|
self.image = image
|
||||||
|
@ -72,6 +97,8 @@ class DockerfileGenerator:
|
||||||
with open(base_file, 'r') as f:
|
with open(base_file, 'r') as f:
|
||||||
file_lines = [line.rstrip() for line in f.readlines()]
|
file_lines = [line.rstrip() for line in f.readlines()]
|
||||||
|
|
||||||
|
new_file_lines.extend(self._header.split('\n'))
|
||||||
|
|
||||||
for line in file_lines:
|
for line in file_lines:
|
||||||
if re.match(
|
if re.match(
|
||||||
r'RUN /install/platypush/install/scripts/[A-Za-z0-9_-]+/install.sh',
|
r'RUN /install/platypush/install/scripts/[A-Za-z0-9_-]+/install.sh',
|
||||||
|
@ -96,6 +123,8 @@ class DockerfileGenerator:
|
||||||
is_after_expose_cmd = True
|
is_after_expose_cmd = True
|
||||||
|
|
||||||
continue
|
continue
|
||||||
|
elif line.startswith('CMD'):
|
||||||
|
new_file_lines.extend(self._footer.split('\n'))
|
||||||
|
|
||||||
new_file_lines.append(line)
|
new_file_lines.append(line)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue