in plugins/docker/base-image/src/main/java/co/elastic/gradle/dockerbase/DockerLockfileTask.java [136:188]
public List<ContainerImageBuildInstruction> getActualInstructions() {
// Use the last available digest for this image
return Stream.concat(
getInputInstructions().get().stream()
.map(instruction -> {
if (instruction instanceof From from) {
if (from.getReference().get().contains("@")) {
throw new IllegalStateException("Input instruction can't have a digest");
}
return new From(getProviderFactory().provider(() ->
{
final String[] split = from.getReference().get().split(":");
return String.format(
"%s:%s@%s",
split[0],
split[1],
getManifestDigest(from.getReference().get())
);
}));
} else {
return instruction;
}
}),
Stream.concat(
getInputInstructions().get().stream().flatMap(i -> {
if (i instanceof RepoInstall repoInstall) {
final String packages = repoInstall.getPackages().stream().collect(Collectors.joining(" "));
return Stream.of(
new SetUser("root"),
switch (getOSDistribution().get()) {
case UBUNTU, DEBIAN -> new Run(List.of("apt-get -y --auto-remove purge " + packages));
case CENTOS -> new Run(List.of("yum -y --remove-leaves remove " + packages));
case WOLFI -> throw new GradleException("Wolfi images don't support repoInstall") ;
}
);
}
return Stream.empty();
}),
Stream.of(
new SetUser("root"),
DockerDaemonActions.wrapInstallCommand(
this,
switch (getOSDistribution().get()) {
case UBUNTU, DEBIAN -> "apt-get -y --allow-unauthenticated upgrade";
case CENTOS -> "yum -y upgrade";
case WOLFI -> "apk upgrade --no-cache";
}
)
)
)
)
.toList();
}