You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-09-16 09:26:22 +02:00
fix: b
This commit is contained in:
@@ -37,11 +37,24 @@ func buildkitExecute(config buildkitExecuteOptions, telemetryData *telemetry.Cus
|
||||
}
|
||||
|
||||
func runBuildkitExecute(config *buildkitExecuteOptions, telemetryData *telemetry.CustomData, commonPipelineEnvironment *buildkitExecuteCommonPipelineEnvironment, execRunner command.ExecRunner, httpClient piperhttp.Sender, fileUtils piperutils.FileUtils) error {
|
||||
log.Entry().Info("Starting buildkit execution in rootless daemonless mode...")
|
||||
log.Entry().Info("Starting buildkit execution in privileged daemonless mode...")
|
||||
log.Entry().Infof("Using Dockerfile at: %s", config.DockerfilePath)
|
||||
|
||||
// Set minimal environment for privileged operation
|
||||
// Set environment for privileged operation
|
||||
os.Setenv("BUILDKIT_CLI_MODE", "daemonless")
|
||||
os.Setenv("BUILDKIT_PROGRESS", "plain")
|
||||
|
||||
// Setup paths and create directories
|
||||
basePath := "/home/user/.local/share/buildkit"
|
||||
cachePath := fmt.Sprintf("%s/cache", basePath)
|
||||
tmpPath := "/tmp"
|
||||
|
||||
// Create directories with proper permissions
|
||||
for _, path := range []string{basePath, cachePath, tmpPath} {
|
||||
if err := fileUtils.MkdirAll(path, 0777); err != nil {
|
||||
log.Entry().Warnf("Failed to create directory %s: %v", path, err)
|
||||
}
|
||||
}
|
||||
|
||||
// Debug info collection
|
||||
log.Entry().Info("Collecting debug information...")
|
||||
@@ -91,7 +104,8 @@ func runBuildkitExecute(config *buildkitExecuteOptions, telemetryData *telemetry
|
||||
// Build with buildkit using direct buildctl
|
||||
log.Entry().Info("BuildKit Configuration:")
|
||||
log.Entry().Info("- Using privileged mode")
|
||||
log.Entry().Info("- Cache location: /home/user/.local/share/buildkit/buildkit-storage/cache")
|
||||
log.Entry().Infof("- Cache location: %s", cachePath)
|
||||
log.Entry().Info("- Temp directory: /tmp")
|
||||
log.Entry().Info("- Environment variables:")
|
||||
for _, env := range os.Environ() {
|
||||
if len(env) > 9 && env[:9] == "BUILDKIT_" {
|
||||
@@ -104,16 +118,25 @@ func runBuildkitExecute(config *buildkitExecuteOptions, telemetryData *telemetry
|
||||
log.Entry().Warnf("Failed to get buildkit version: %v", err)
|
||||
}
|
||||
|
||||
// Set buildkit-specific env vars for mount and cache handling
|
||||
os.Setenv("BUILDKIT_SANDBOX_MOUNT_PATH", "/tmp")
|
||||
os.Setenv("BUILDKIT_STEP_MOUNT_PATH", "/tmp")
|
||||
os.Setenv("BUILDKIT_MOUNT_MODE", "0777")
|
||||
|
||||
buildOpts := []string{
|
||||
"build",
|
||||
"--frontend=dockerfile.v0",
|
||||
"--local", "context=.",
|
||||
"--local", fmt.Sprintf("dockerfile=%s", config.DockerfilePath),
|
||||
"--progress=plain",
|
||||
"--export-cache", "type=inline",
|
||||
"--import-cache", "type=local,src=/home/user/.local/share/buildkit/buildkit-storage/cache",
|
||||
fmt.Sprintf("--export-cache=type=local,mode=max,dest=%s", cachePath),
|
||||
fmt.Sprintf("--import-cache=type=local,src=%s", cachePath),
|
||||
"--allow-insecure-entitlement=network.host",
|
||||
fmt.Sprintf("--mount=type=bind,target=/tmp,source=/tmp,rw=true"),
|
||||
}
|
||||
|
||||
log.Entry().Info("Using build options:", buildOpts)
|
||||
|
||||
// Add build options from config
|
||||
buildOpts = append(buildOpts, config.BuildOptions...)
|
||||
|
||||
|
@@ -343,7 +343,7 @@ func buildkitExecuteMetadata() config.StepData {
|
||||
},
|
||||
},
|
||||
Containers: []config.Container{
|
||||
{Name: "buildkitd", Image: "moby/buildkit:latest", EnvVars: []config.EnvVar{{Name: "BUILDKITD_FLAGS", Value: "--oci-worker=true --containerd-worker=false"}}},
|
||||
{Name: "buildkitd", Image: "moby/buildkit:latest", EnvVars: []config.EnvVar{{Name: "BUILDKITD_FLAGS", Value: "--oci-worker=true --containerd-worker=false --oci-worker-snapshotter=overlayfs"}, {Name: "BUILDKIT_STEP_LOG_MAX_SIZE", Value: "10485760"}, {Name: "BUILDKIT_STEP_LOG_MAX_SPEED", Value: "10485760"}}},
|
||||
},
|
||||
Outputs: config.StepOutputs{
|
||||
Resources: []config.StepResources{
|
||||
|
@@ -113,9 +113,21 @@ spec:
|
||||
image: moby/buildkit:latest
|
||||
env:
|
||||
- name: BUILDKITD_FLAGS
|
||||
value: --oci-worker=true --containerd-worker=false
|
||||
value: --oci-worker=true --containerd-worker=false --oci-worker-snapshotter=overlayfs
|
||||
- name: BUILDKIT_STEP_LOG_MAX_SIZE
|
||||
value: "10485760"
|
||||
- name: BUILDKIT_STEP_LOG_MAX_SPEED
|
||||
value: "10485760"
|
||||
securityContext:
|
||||
privileged: true
|
||||
procMount: Unmasked
|
||||
volumeMounts:
|
||||
- mountPath: /home/user/.local/share/buildkit
|
||||
name: volume
|
||||
subPath: buildkit-storage
|
||||
- mountPath: /tmp
|
||||
name: volume
|
||||
subPath: buildkit-tmp
|
||||
volumeMounts:
|
||||
- mountPath: /home/user/.local/share/buildkit
|
||||
name: volume
|
||||
|
Reference in New Issue
Block a user