2
0
mirror of https://github.com/linka-cloud/d2vm.git synced 2024-11-21 23:36:25 +00:00

centos-stream-9: fix Dockerfile template

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
Adphi 2024-07-09 18:32:19 +02:00
parent f711f8919d
commit e31bc93074
Signed by: adphi
GPG Key ID: F2159213400E50AB
6 changed files with 26 additions and 12 deletions

View File

@ -56,6 +56,7 @@ jobs:
- kalilinux
- alpine
- centos
- quay.io/centos/centos:stream9
steps:
- name: Checkout
@ -104,6 +105,7 @@ jobs:
- debian:10
- debian:11
- centos:8
- quay.io/centos/centos:stream9
steps:
- name: Checkout
uses: actions/checkout@v3

View File

@ -120,6 +120,10 @@ func TestConfig(t *testing.T) {
image: "centos:latest",
config: configCentOS,
},
{
image: "quay.io/centos/centos:stream9",
config: configCentOS,
},
}
exec.SetDebug(true)

View File

@ -18,6 +18,7 @@ import (
_ "embed"
"fmt"
"io"
"strconv"
"text/template"
"github.com/sirupsen/logrus"
@ -36,10 +37,10 @@ var alpineDockerfile string
var centOSDockerfile string
var (
ubuntuDockerfileTemplate = template.Must(template.New("ubuntu.Dockerfile").Parse(ubuntuDockerfile))
debianDockerfileTemplate = template.Must(template.New("debian.Dockerfile").Parse(debianDockerfile))
alpineDockerfileTemplate = template.Must(template.New("alpine.Dockerfile").Parse(alpineDockerfile))
centOSDockerfileTemplate = template.Must(template.New("centos.Dockerfile").Parse(centOSDockerfile))
ubuntuDockerfileTemplate = template.Must(template.New("ubuntu.Dockerfile").Funcs(tplFuncs).Parse(ubuntuDockerfile))
debianDockerfileTemplate = template.Must(template.New("debian.Dockerfile").Funcs(tplFuncs).Parse(debianDockerfile))
alpineDockerfileTemplate = template.Must(template.New("alpine.Dockerfile").Funcs(tplFuncs).Parse(alpineDockerfile))
centOSDockerfileTemplate = template.Must(template.New("centos.Dockerfile").Funcs(tplFuncs).Parse(centOSDockerfile))
)
type NetworkManager string
@ -117,3 +118,7 @@ func NewDockerfile(release OSRelease, img, password string, networkManager Netwo
}
return d, nil
}
var tplFuncs = template.FuncMap{
"atoi": strconv.Atoi,
}

View File

@ -53,6 +53,7 @@ var (
{name: "debian:10", luks: "Please unlock disk root:"},
{name: "debian:11", luks: "Please unlock disk root:"},
{name: "centos:8", luks: "Please enter passphrase for disk"},
{name: "quay.io/centos/centos:stream9", luks: "Please enter passphrase for disk"},
}
imgNames = func() []string {
var imgs []string
@ -126,7 +127,7 @@ imgs:
require := require2.New(t)
out := filepath.Join(dir, strings.NewReplacer(":", "-", ".", "-").Replace(img.name)+".qcow2")
out := filepath.Join(dir, strings.NewReplacer(":", "-", ".", "-", "/", "-").Replace(img.name)+".qcow2")
if _, err := os.Stat(out); err == nil {
require.NoError(os.Remove(out))

View File

@ -203,12 +203,10 @@ func (c *config) buildQemuCmdline() ([]string, error) {
// Need to specify the vcpu type when running qemu on arm64 platform, for security reason,
// the vcpu should be "host" instead of other names such as "cortex-a53"...
if c.arch == "aarch64" {
if runtime.GOARCH == "arm64" {
qemuArgs = append(qemuArgs, "-cpu", "host")
} else {
qemuArgs = append(qemuArgs, "-cpu", "cortex-a57")
}
if c.arch == "aarch64" && runtime.GOARCH != "arm64" {
qemuArgs = append(qemuArgs, "-cpu", "cortex-a57")
} else {
qemuArgs = append(qemuArgs, "-cpu", "host")
}
// goArch is the GOARCH equivalent of config.Arch

View File

@ -2,8 +2,12 @@ FROM {{ .Image }}
USER root
{{ $version := atoi .Release.Version }}
{{ if le $version 8 }}
RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
{{ end }}
RUN yum update -y
@ -36,7 +40,7 @@ RUN dracut --no-hostonly --regenerate-all --force
{{- if not .Grub }}
RUN cd /boot && \
mv $(find . -name 'vmlinuz-*') /boot/vmlinuz && \
mv $(find {{ if le $version 8 }}.{{ else }}/{{ end }} -name 'vmlinuz*') /boot/vmlinuz && \
mv $(find . -name 'initramfs-*.img') /boot/initrd.img
{{- end }}