From 8aed31e41b70644209fae601664b98605b98741e Mon Sep 17 00:00:00 2001
From: Mikhail Klementev <blame@dumpstack.io>
Date: Thu, 6 Apr 2023 20:03:07 +0000
Subject: [PATCH] Install a single kernel to ensure all dependencies are cached

---
 kernel.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel.go b/kernel.go
index ee7286f..580e3d1 100644
--- a/kernel.go
+++ b/kernel.go
@@ -305,6 +305,8 @@ func generateBaseDockerImage(registry string, commands []config.DockerCommand,
 		d += "RUN apt-get update\n"
 		d += "RUN apt-get install -y build-essential libelf-dev\n"
 		d += "RUN apt-get install -y wget git\n"
+		// Install a single kernel to ensure all dependencies are cached
+		d += "RUN apt-get install -y $(apt-cache search --names-only '^linux-image-[0-9\\.\\-]*-generic' | awk '{ print $1 }' | head -n 1)\n"
 		if sk.DistroRelease >= "14.04" {
 			d += "RUN apt-get install -y libseccomp-dev\n"
 		}