diff --git a/builder/build/code_build.go b/builder/build/code_build.go index 267859510..0db936297 100644 --- a/builder/build/code_build.go +++ b/builder/build/code_build.go @@ -188,14 +188,30 @@ func (s *slugBuild) stopPreBuildJob(re *Request) error { func (s *slugBuild) createVolumeAndMount(re *Request, sourceTarFileName string, buildNoCache bool) (volumes []corev1.Volume, volumeMounts []corev1.VolumeMount) { cacheSubPath := strings.TrimPrefix(re.CacheDir, "/cache/") hostPathType := corev1.HostPathDirectoryOrCreate - volumeMounts = []corev1.VolumeMount{} - volumes = []corev1.Volume{} + volumeMounts = []corev1.VolumeMount{ + { + Name: "slug", + MountPath: "/tmp/slug", + }, + } + volumes = []corev1.Volume{ + { + Name: "slug", + VolumeSource: corev1.VolumeSource{ + HostPath: &corev1.HostPathVolumeSource{ + Path: path.Join("/opt/rainbond/", re.TGZDir), + Type: &hostPathType, + }, + }, + }, + } + logrus.Infof("look ------- %v------%v", re.CachePath, cacheSubPath) if !buildNoCache { volumes = append(volumes, corev1.Volume{ Name: "cache", VolumeSource: corev1.VolumeSource{ HostPath: &corev1.HostPathVolumeSource{ - Path: path.Join(re.CachePath, cacheSubPath), + Path: path.Join("/opt/rainbond/", re.CacheDir), Type: &hostPathType, }, }, diff --git a/builder/build/dockerfile_build.go b/builder/build/dockerfile_build.go index e596d1d44..b06c42a51 100644 --- a/builder/build/dockerfile_build.go +++ b/builder/build/dockerfile_build.go @@ -209,7 +209,16 @@ func (d *dockerfileBuild) createVolumeAndMount(secretName string, buildKitTomlCM Name: "dockerfile-build", VolumeSource: corev1.VolumeSource{ HostPath: &corev1.HostPathVolumeSource{ - Path: "/cache", + Path: "/opt/rainbond/cache", + Type: &hostPathType, + }, + }, + }, + { + Name: "grdata", + VolumeSource: corev1.VolumeSource{ + HostPath: &corev1.HostPathVolumeSource{ + Path: "/opt/rainbond/grdata", Type: &hostPathType, }, }, @@ -253,6 +262,10 @@ func (d *dockerfileBuild) createVolumeAndMount(secretName string, buildKitTomlCM }, } volumeMounts = []corev1.VolumeMount{ + { + Name: "grdata", + MountPath: "/grdata", + }, { Name: "dockerfile-build", MountPath: "/cache", diff --git a/builder/sources/image.go b/builder/sources/image.go index 8e94383dd..78ae786e5 100644 --- a/builder/sources/image.go +++ b/builder/sources/image.go @@ -817,8 +817,6 @@ func PrepareBuildKitTomlCM(ctx context.Context, kubeClient kubernetes.Interface, // CreateVolumeAndMounts - func CreateVolumeAndMounts(contextDir, buildType string, buildKitTomlCMName string) (volumes []corev1.Volume, volumeMounts []corev1.VolumeMount) { - pathSplit := strings.Split(contextDir, "/") - subPath := strings.Join(pathSplit[2:], "/") hostPathType := corev1.HostPathDirectoryOrCreate hostsFilePathType := corev1.HostPathFile // buildkit volumes volumeMounts config @@ -875,44 +873,21 @@ func CreateVolumeAndMounts(contextDir, buildType string, buildKitTomlCMName stri MountPath: "/etc/buildkit", }, } - if buildType == "plug-build" { - volume := corev1.Volume{ - Name: "plug-build", - VolumeSource: corev1.VolumeSource{ - HostPath: &corev1.HostPathVolumeSource{ - Path: contextDir, - Type: &hostPathType, - }, + volume := corev1.Volume{ + Name: "plug-build", + VolumeSource: corev1.VolumeSource{ + HostPath: &corev1.HostPathVolumeSource{ + Path: path.Join("/opt/rainbond", contextDir), + Type: &hostPathType, }, - } - volumes = append(volumes, volume) - volumeMount := corev1.VolumeMount{ - Name: "plug-build", - MountPath: "/workspace", - } - volumeMounts = append(volumeMounts, volumeMount) - } - if buildType == "nc-build" { - volume := corev1.Volume{ - Name: "nc-build", - VolumeSource: corev1.VolumeSource{ - HostPath: &corev1.HostPathVolumeSource{ - Path: "/cache", - Type: &hostPathType, - }, - }, - } - volumes = append(volumes, volume) - volumeMount := corev1.VolumeMount{ - Name: "nc-build", - MountPath: "/workspace", - SubPath: subPath, - } - volumeMounts = append(volumeMounts, volumeMount) + }, } - if buildType == "run-build" || buildType == "vm-build" { - logrus.Infof("look ------------ %v", subPath) + volumes = append(volumes, volume) + volumeMount := corev1.VolumeMount{ + Name: "plug-build", + MountPath: "/workspace", } + volumeMounts = append(volumeMounts, volumeMount) return volumes, volumeMounts }