feat: implement basic debian container image
This commit is contained in:
parent
17295cad89
commit
9e8a381de0
@ -2,6 +2,7 @@ package debian
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@ -202,3 +203,54 @@ func MatchImagePkg(km config.KernelMask) (pkgs []string, err error) {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DockerEnvs(km config.KernelMask) (envs []string) {
|
||||||
|
envs = append(envs, "DEBIAN_FRONTEND=noninteractive")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func DockerCommands(km config.KernelMask) (commands []string) {
|
||||||
|
release := releaseFromString(km.DistroRelease)
|
||||||
|
|
||||||
|
var snapshot string
|
||||||
|
|
||||||
|
switch release {
|
||||||
|
case Wheezy:
|
||||||
|
snapshot = "20160605T173546Z"
|
||||||
|
case Jessie:
|
||||||
|
snapshot = "20190212T020859Z"
|
||||||
|
case Stretch:
|
||||||
|
snapshot = "20200719T110630Z"
|
||||||
|
case Buster:
|
||||||
|
snapshot = "20220911T180237Z"
|
||||||
|
case Bullseye:
|
||||||
|
snapshot = "20221218T103830Z"
|
||||||
|
default:
|
||||||
|
log.Fatal().Msgf("%s not supported", release)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
params := "[check-valid-until=no trusted=yes]"
|
||||||
|
mirror := "http://snapshot.debian.org"
|
||||||
|
repourl := fmt.Sprintf("%s/archive/debian/%s/", mirror, snapshot)
|
||||||
|
|
||||||
|
cmdf := func(f string, s ...interface{}) {
|
||||||
|
commands = append(commands, fmt.Sprintf(f, s...))
|
||||||
|
}
|
||||||
|
|
||||||
|
repo := fmt.Sprintf("deb %s %s %s main contrib",
|
||||||
|
params, repourl, release)
|
||||||
|
|
||||||
|
cmdf("echo '%s' > /etc/apt/sources.list", repo)
|
||||||
|
|
||||||
|
repo = fmt.Sprintf("deb %s %s %s-updates main contrib",
|
||||||
|
params, repourl, release)
|
||||||
|
|
||||||
|
cmdf("echo '%s' >> /etc/apt/sources.list", repo)
|
||||||
|
|
||||||
|
cmdf("apt-get update")
|
||||||
|
cmdf("apt-get install -y wget")
|
||||||
|
cmdf("mkdir -p /lib/modules")
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@ -288,6 +288,13 @@ func GenerateBaseDockerImage(registry string, commands []config.DockerCommand,
|
|||||||
packages += " libdtrace-ctf"
|
packages += " libdtrace-ctf"
|
||||||
}
|
}
|
||||||
d += fmt.Sprintf("RUN yum -y install %s\n", packages)
|
d += fmt.Sprintf("RUN yum -y install %s\n", packages)
|
||||||
|
case config.Debian:
|
||||||
|
for _, e := range debian.DockerEnvs(sk) {
|
||||||
|
d += "ENV " + e + "\n"
|
||||||
|
}
|
||||||
|
for _, c := range debian.DockerCommands(sk) {
|
||||||
|
d += "RUN " + c + "\n"
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("%s not yet supported", sk.DistroType.String())
|
err = fmt.Errorf("%s not yet supported", sk.DistroType.String())
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user