|
@ -168,6 +168,7 @@ class DockerConfig: |
|
|
self.image_provider, self.provider_type = get_provider(config, None, ImageSource.NONE) |
|
|
self.image_provider, self.provider_type = get_provider(config, None, ImageSource.NONE) |
|
|
self.tagger = Tagger(config.get("tag", {})) |
|
|
self.tagger = Tagger(config.get("tag", {})) |
|
|
self.commands = config.get("commands", []) |
|
|
self.commands = config.get("commands", []) |
|
|
|
|
|
self.env = config.get("env", {}) |
|
|
|
|
|
|
|
|
def copy(self, job_config={}): |
|
|
def copy(self, job_config={}): |
|
|
d = DockerConfig() |
|
|
d = DockerConfig() |
|
@ -176,6 +177,8 @@ class DockerConfig: |
|
|
d.image_provider, d.provider_type = get_provider(job_config, self.image_provider, self.provider_type) |
|
|
d.image_provider, d.provider_type = get_provider(job_config, self.image_provider, self.provider_type) |
|
|
d.tagger = self.tagger.copy(job_config.get("tag", {})) |
|
|
d.tagger = self.tagger.copy(job_config.get("tag", {})) |
|
|
d.commands = self.commands.copy() + job_config.get("commands", []) |
|
|
d.commands = self.commands.copy() + job_config.get("commands", []) |
|
|
|
|
|
d.env = self.env.copy() |
|
|
|
|
|
d.env.update(gen_dict(job_config.get("env", []))) |
|
|
return d |
|
|
return d |
|
|
|
|
|
|
|
|
def __str__(self) -> str: |
|
|
def __str__(self) -> str: |
|
@ -205,6 +208,8 @@ class DockerRunner(): |
|
|
logging.info(f"[DockerRunner] Image: {image.tags} ({image.id})") |
|
|
logging.info(f"[DockerRunner] Image: {image.tags} ({image.id})") |
|
|
|
|
|
|
|
|
if len(job_config.commands) > 0: |
|
|
if len(job_config.commands) > 0: |
|
|
|
|
|
if "PATH" in job_config.env: |
|
|
|
|
|
del job_config.env["PATH"] |
|
|
container = self.client.containers.run(image=image.id, |
|
|
container = self.client.containers.run(image=image.id, |
|
|
entrypoint=["sleep", "infinity"], |
|
|
entrypoint=["sleep", "infinity"], |
|
|
detach=True, |
|
|
detach=True, |
|
@ -213,7 +218,8 @@ class DockerRunner(): |
|
|
for i in job_config.commands: |
|
|
for i in job_config.commands: |
|
|
command = ["/bin/sh", "-c", i] |
|
|
command = ["/bin/sh", "-c", i] |
|
|
logging.debug(f"[DockerRunner] Command array: {command}") |
|
|
logging.debug(f"[DockerRunner] Command array: {command}") |
|
|
code, output = container.exec_run(cmd=command) |
|
|
code, output = container.exec_run(cmd=command, |
|
|
|
|
|
environment=job_config.env) |
|
|
for line in output.decode("UTF-8").splitlines(): |
|
|
for line in output.decode("UTF-8").splitlines(): |
|
|
print(f"[{job_spec['name']}] {line}") |
|
|
print(f"[{job_spec['name']}] {line}") |
|
|
if code != 0: |
|
|
if code != 0: |
|
|