forked from platypush/platypush
Adapted Platydock to the new Dockerfile format.
This commit is contained in:
parent
254604e404
commit
7d8a00696c
1 changed files with 8 additions and 40 deletions
|
@ -71,7 +71,7 @@ class DockerBuilder(BaseBuilder):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.image = image
|
self.image = image
|
||||||
self.tag = tag
|
self.tag = tag
|
||||||
self.print_only = print_only # TODO
|
self.print_only = print_only
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_name(cls):
|
def get_name(cls):
|
||||||
|
@ -151,23 +151,9 @@ class DockerBuilder(BaseBuilder):
|
||||||
nonlocal is_after_expose_cmd
|
nonlocal is_after_expose_cmd
|
||||||
|
|
||||||
for line in self._read_base_dockerfile_lines():
|
for line in self._read_base_dockerfile_lines():
|
||||||
if re.match(
|
if re.search(r'\s*rm -rf /install\s*', line):
|
||||||
r'RUN /install/platypush/install/scripts/[A-Za-z0-9_-]+/install.sh',
|
for new_line in [*deps.to_pip_install_commands(), *deps.after]:
|
||||||
line.strip(),
|
yield f'\t{new_line} && \\'
|
||||||
):
|
|
||||||
yield self._generate_git_clone_command()
|
|
||||||
elif line.startswith('RUN cd /install '):
|
|
||||||
for new_line in deps.before:
|
|
||||||
yield 'RUN ' + new_line
|
|
||||||
|
|
||||||
for new_line in deps.to_pkg_install_commands():
|
|
||||||
yield 'RUN ' + new_line
|
|
||||||
elif line == 'RUN rm -rf /install':
|
|
||||||
for new_line in deps.to_pip_install_commands():
|
|
||||||
yield 'RUN ' + new_line
|
|
||||||
|
|
||||||
for new_line in deps.after:
|
|
||||||
yield 'RUN' + new_line
|
|
||||||
elif line.startswith('EXPOSE ') and ports:
|
elif line.startswith('EXPOSE ') and ports:
|
||||||
if not is_after_expose_cmd:
|
if not is_after_expose_cmd:
|
||||||
yield from [f'EXPOSE {port}' for port in ports]
|
yield from [f'EXPOSE {port}' for port in ports]
|
||||||
|
@ -179,6 +165,10 @@ class DockerBuilder(BaseBuilder):
|
||||||
|
|
||||||
yield line
|
yield line
|
||||||
|
|
||||||
|
if line.startswith('RUN /install/platypush/install/scripts/'):
|
||||||
|
for new_line in [*deps.before, *deps.to_pkg_install_commands()]:
|
||||||
|
yield f'\t{new_line} && \\'
|
||||||
|
|
||||||
if line.startswith('CMD') and self.device_id:
|
if line.startswith('CMD') and self.device_id:
|
||||||
yield f'\t--device-id {self.device_id} \\'
|
yield f'\t--device-id {self.device_id} \\'
|
||||||
|
|
||||||
|
@ -265,28 +255,6 @@ class DockerBuilder(BaseBuilder):
|
||||||
for line in parser():
|
for line in parser():
|
||||||
f.write(line + '\n')
|
f.write(line + '\n')
|
||||||
|
|
||||||
def _generate_git_clone_command(self) -> str:
|
|
||||||
"""
|
|
||||||
Generates a git clone command in Dockerfile that checks out the repo
|
|
||||||
and the right git reference, if the application sources aren't already
|
|
||||||
available under /install.
|
|
||||||
"""
|
|
||||||
install_cmd = ' '.join(self.pkg_manager.value.install)
|
|
||||||
uninstall_cmd = ' '.join(self.pkg_manager.value.uninstall)
|
|
||||||
return textwrap.dedent(
|
|
||||||
f"""
|
|
||||||
RUN if [ ! -f "/install/setup.py" ]; then \\
|
|
||||||
echo "Platypush source not found under the current directory, downloading it" && \\
|
|
||||||
{install_cmd} git && \\
|
|
||||||
rm -rf /install && \\
|
|
||||||
git clone --recursive https://github.com/BlackLight/platypush.git /install && \\
|
|
||||||
cd /install && \\
|
|
||||||
git checkout {self.gitref} && \\
|
|
||||||
{uninstall_cmd} git; \\
|
|
||||||
fi
|
|
||||||
"""
|
|
||||||
)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _get_arg_parser(cls) -> argparse.ArgumentParser:
|
def _get_arg_parser(cls) -> argparse.ArgumentParser:
|
||||||
parser = super()._get_arg_parser()
|
parser = super()._get_arg_parser()
|
||||||
|
|
Loading…
Reference in a new issue