2
0
mirror of https://github.com/linka-cloud/d2vm.git synced 2024-11-10 18:16:24 +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 - kalilinux
- alpine - alpine
- centos - centos
- quay.io/centos/centos:stream9
steps: steps:
- name: Checkout - name: Checkout
@ -104,6 +105,7 @@ jobs:
- debian:10 - debian:10
- debian:11 - debian:11
- centos:8 - centos:8
- quay.io/centos/centos:stream9
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3

View File

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

View File

@ -18,6 +18,7 @@ import (
_ "embed" _ "embed"
"fmt" "fmt"
"io" "io"
"strconv"
"text/template" "text/template"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
@ -36,10 +37,10 @@ var alpineDockerfile string
var centOSDockerfile string var centOSDockerfile string
var ( var (
ubuntuDockerfileTemplate = template.Must(template.New("ubuntu.Dockerfile").Parse(ubuntuDockerfile)) ubuntuDockerfileTemplate = template.Must(template.New("ubuntu.Dockerfile").Funcs(tplFuncs).Parse(ubuntuDockerfile))
debianDockerfileTemplate = template.Must(template.New("debian.Dockerfile").Parse(debianDockerfile)) debianDockerfileTemplate = template.Must(template.New("debian.Dockerfile").Funcs(tplFuncs).Parse(debianDockerfile))
alpineDockerfileTemplate = template.Must(template.New("alpine.Dockerfile").Parse(alpineDockerfile)) alpineDockerfileTemplate = template.Must(template.New("alpine.Dockerfile").Funcs(tplFuncs).Parse(alpineDockerfile))
centOSDockerfileTemplate = template.Must(template.New("centos.Dockerfile").Parse(centOSDockerfile)) centOSDockerfileTemplate = template.Must(template.New("centos.Dockerfile").Funcs(tplFuncs).Parse(centOSDockerfile))
) )
type NetworkManager string type NetworkManager string
@ -117,3 +118,7 @@ func NewDockerfile(release OSRelease, img, password string, networkManager Netwo
} }
return d, nil 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:10", luks: "Please unlock disk root:"},
{name: "debian:11", luks: "Please unlock disk root:"}, {name: "debian:11", luks: "Please unlock disk root:"},
{name: "centos:8", luks: "Please enter passphrase for disk"}, {name: "centos:8", luks: "Please enter passphrase for disk"},
{name: "quay.io/centos/centos:stream9", luks: "Please enter passphrase for disk"},
} }
imgNames = func() []string { imgNames = func() []string {
var imgs []string var imgs []string
@ -126,7 +127,7 @@ imgs:
require := require2.New(t) 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 { if _, err := os.Stat(out); err == nil {
require.NoError(os.Remove(out)) 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, // 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"... // the vcpu should be "host" instead of other names such as "cortex-a53"...
if c.arch == "aarch64" { if c.arch == "aarch64" && runtime.GOARCH != "arm64" {
if runtime.GOARCH == "arm64" { qemuArgs = append(qemuArgs, "-cpu", "cortex-a57")
qemuArgs = append(qemuArgs, "-cpu", "host") } else {
} else { qemuArgs = append(qemuArgs, "-cpu", "host")
qemuArgs = append(qemuArgs, "-cpu", "cortex-a57")
}
} }
// goArch is the GOARCH equivalent of config.Arch // goArch is the GOARCH equivalent of config.Arch

View File

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