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: daemonless
This commit is contained in:
@@ -2,7 +2,6 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/SAP/jenkins-library/pkg/command"
|
||||
piperhttp "github.com/SAP/jenkins-library/pkg/http"
|
||||
@@ -38,27 +37,13 @@ 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 mode...")
|
||||
log.Entry().Info("Starting buildkit execution with buildctl-daemonless.sh...")
|
||||
log.Entry().Infof("Using Dockerfile at: %s", config.DockerfilePath)
|
||||
|
||||
// Wait for buildkit daemon to be available
|
||||
maxRetries := 30
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
err := execRunner.RunExecutable("buildctl", "debug", "workers")
|
||||
if err == nil {
|
||||
break
|
||||
}
|
||||
if i == maxRetries-1 {
|
||||
return errors.Wrap(err, "Buildkit daemon not available after max retries")
|
||||
}
|
||||
log.Entry().Info("Waiting for rootless buildkit daemon to be available...")
|
||||
time.Sleep(2 * time.Second)
|
||||
}
|
||||
|
||||
// Verify buildctl version after daemon is available
|
||||
err := execRunner.RunExecutable("buildctl", "--version")
|
||||
// Verify buildctl version - using daemonless script which handles daemon startup
|
||||
err := execRunner.RunExecutable("buildctl-daemonless.sh", "--version")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to execute buildctl command")
|
||||
return errors.Wrap(err, "Failed to execute buildctl-daemonless.sh command")
|
||||
}
|
||||
|
||||
dockerConfigDir := "/home/user/.docker"
|
||||
@@ -103,8 +88,8 @@ func runBuildkitExecute(config *buildkitExecuteOptions, telemetryData *telemetry
|
||||
buildOpts = append(buildOpts, "--output", "type=docker")
|
||||
}
|
||||
|
||||
log.Entry().Info("Executing buildkit build...")
|
||||
err = execRunner.RunExecutable("buildctl", buildOpts...)
|
||||
log.Entry().Info("Executing buildkit build with daemonless script...")
|
||||
err = execRunner.RunExecutable("buildctl-daemonless.sh", buildOpts...)
|
||||
if err != nil {
|
||||
return fmt.Errorf("buildkit build failed: %w", err)
|
||||
}
|
||||
|
@@ -111,40 +111,26 @@ spec:
|
||||
containers:
|
||||
- name: buildkitd
|
||||
image: moby/buildkit:master-rootless
|
||||
entrypoint:
|
||||
- buildctl-daemonless.sh
|
||||
args:
|
||||
- buildkitd
|
||||
- --oci-worker-no-process-sandbox
|
||||
- --debug
|
||||
shell: /bin/sh
|
||||
readinessProbe:
|
||||
exec:
|
||||
command:
|
||||
- buildctl
|
||||
- debug
|
||||
- workers
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 30
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- buildctl
|
||||
- debug
|
||||
- workers
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 30
|
||||
securityContext:
|
||||
# Needs Kubernetes >= 1.19
|
||||
seccompProfile:
|
||||
type: Unconfined
|
||||
# To change UID/GID, you need to rebuild the image
|
||||
runAsUser: 1000
|
||||
runAsGroup: 1000
|
||||
volumeMounts:
|
||||
# Dockerfile has `VOLUME /home/user/.local/share/buildkit` by default too,
|
||||
# but the default VOLUME does not work with rootless on Google's Container-Optimized OS
|
||||
# as it is mounted with `nosuid,nodev`.
|
||||
# https://github.com/moby/buildkit/issues/879#issuecomment-1240347038
|
||||
- mountPath: /home/user/.local/share/buildkit
|
||||
name: buildkitd
|
||||
- name: volume
|
||||
mountPath: /home/user/.local/share/buildkit
|
||||
subPath: buildkitd
|
||||
- name: volume
|
||||
mountPath: /workspace
|
||||
subPath: workspace
|
||||
- name: volume
|
||||
mountPath: /home/user/.docker
|
||||
subPath: docker-config
|
||||
volumes:
|
||||
- name: buildkitd
|
||||
- name: volume
|
||||
emptyDir: {}
|
||||
|
Reference in New Issue
Block a user