Commit ce34a36c authored by Elijah Grubb's avatar Elijah Grubb

Implemented runit service for docker entrypoint

parent 22f3f0f0
......@@ -4513,6 +4513,60 @@ sub emulabizeImage($;$$$$$$$$)
}
}
mkdir("$hdir/etc/service/dockerentrypoint");
open(my $runitfile, ">", "$hdir/etc/service/dockerentrypoint/run");
print $runitfile "#!/bin/sh\n";
print $runitfile "\n";
print $runitfile "# This is an automatically generated runit file based on the docker image's entrypoint and cmd\n\n";
my $dockerenvironmentvars;
# TODO: print out environment variables?
if (exists($iattrs{DOCKER_ENV})) {
$dockerenvironmentvars = $iattrs{DOCKER_ENV};
foreach my $elem (@$dockerenvironmentvars) {
print $runitfile $elem;
print $runitfile "\n";
}
}
print $runitfile "\n";
my $dockerentrypoint;
my $dockercmd;
if (exists($iattrs{DOCKER_ENTRYPOINT})) {
$dockerentrypoint = $iattrs{DOCKER_ENTRYPOINT};
# check if first arg is /bin/sh
if ($dockerentrypoint->[0] ne "/bin/sh") {
print $runitfile "exec ";
}
# print whole thing to file
# need to be careful about variables to be expanded
foreach my $elem (@$dockerentrypoint) {
print $runitfile $elem;
print $runitfile " ";
}
}
if (exists($iattrs{DOCKER_CMD})) {
$dockercmd = $iattrs{DOCKER_CMD};
if ($dockercmd->[0] ne "/bin/sh" and !defined($dockerentrypoint)) {
print $runitfile "exec ";
}
foreach my $elem (@$dockercmd) {
print $runitfile $elem;
print $runitfile " ";
}
}
print $runitfile "\n\n";
print $runitfile "exit 0";
close $runitfile;
#
# Before we start setting up the new image Dockerfile, run
# all the artifact build scripts.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment