mirror of https://github.com/knative/func.git
feat: caching for on cluster s2i build (#1406)
* feat: s2i cache /tmp/artifacts
Signed-off-by: Matej Vasek <mvasek@redhat.com>
* feat: s2i build caches buildah container storage
Signed-off-by: Matej Vasek <mvasek@redhat.com>
* Revert "feat: s2i build caches buildah container storage"
This reverts commit ec52609814.
Reverting since it lead up to eating all storage.
Signed-off-by: Matej Vasek <mvasek@redhat.com>
Signed-off-by: Matej Vasek <mvasek@redhat.com>
This commit is contained in:
parent
11616840b9
commit
5746968b6d
|
|
@ -42,6 +42,9 @@ spec:
|
|||
default: "image:///usr/libexec/s2i"
|
||||
workspaces:
|
||||
- name: source
|
||||
- name: cache
|
||||
description: Directory where cache is stored (e.g. local mvn repo).
|
||||
optional: true
|
||||
- name: sslcertdir
|
||||
optional: true
|
||||
- name: dockerconfig
|
||||
|
|
@ -82,11 +85,14 @@ spec:
|
|||
- mountPath: /env-vars
|
||||
name: env-vars
|
||||
- name: build
|
||||
image: quay.io/buildah/stable:v1.17.0
|
||||
image: quay.io/buildah/stable:v1.27.0
|
||||
workingDir: /gen-source
|
||||
script: |
|
||||
[[ "$(workspaces.sslcertdir.bound)" == "true" ]] && CERT_DIR_FLAG="--cert-dir $(workspaces.sslcertdir.path)"
|
||||
ARTIFACTS_CACHE_PATH="$(workspaces.cache.path)/mvn-artifacts"
|
||||
[ -d "${ARTIFACTS_CACHE_PATH}" ] || mkdir "${ARTIFACTS_CACHE_PATH}"
|
||||
buildah ${CERT_DIR_FLAG} bud --storage-driver=vfs --tls-verify=$(params.TLSVERIFY) --layers \
|
||||
-v "${ARTIFACTS_CACHE_PATH}:/tmp/artifacts/:rw,z,U" \
|
||||
-f /gen-source/Dockerfile.gen -t $(params.IMAGE) .
|
||||
|
||||
[[ "$(workspaces.dockerconfig.bound)" == "true" ]] && export DOCKER_CONFIG="$(workspaces.dockerconfig.path)"
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ func generatePipeline(f fn.Function, labels map[string]string) *pplnv1beta1.Pipe
|
|||
|
||||
workspaces := []pplnv1beta1.PipelineWorkspaceDeclaration{
|
||||
{Name: "source-workspace", Description: "Directory where function source is located."},
|
||||
{Name: "cache-workspace", Description: "Directory where build cache is stored."},
|
||||
{Name: "dockerconfig-workspace", Description: "Directory containing image registry credentials stored in `config.json` file.", Optional: true},
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +91,6 @@ func generatePipeline(f fn.Function, labels map[string]string) *pplnv1beta1.Pipe
|
|||
|
||||
if f.Build.Builder == builders.Pack {
|
||||
// ----- Buildpacks related properties
|
||||
workspaces = append(workspaces, pplnv1beta1.PipelineWorkspaceDeclaration{Name: "cache-workspace", Description: "Directory where Buildpacks cache is stored."})
|
||||
taskBuild = taskBuildpacks(buildPreReq)
|
||||
|
||||
} else if f.Build.Builder == builders.S2I {
|
||||
|
|
@ -181,6 +181,13 @@ func generatePipelineRun(f fn.Function, labels map[string]string) *pplnv1beta1.P
|
|||
},
|
||||
SubPath: "source",
|
||||
},
|
||||
{
|
||||
Name: "cache-workspace",
|
||||
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
|
||||
ClaimName: getPipelinePvcName(f),
|
||||
},
|
||||
SubPath: "cache",
|
||||
},
|
||||
{
|
||||
Name: "dockerconfig-workspace",
|
||||
Secret: &corev1.SecretVolumeSource{
|
||||
|
|
@ -189,17 +196,7 @@ func generatePipelineRun(f fn.Function, labels map[string]string) *pplnv1beta1.P
|
|||
},
|
||||
}
|
||||
|
||||
if f.Build.Builder == builders.Pack {
|
||||
// ----- Buildpacks related properties
|
||||
|
||||
workspaces = append(workspaces, pplnv1beta1.WorkspaceBinding{
|
||||
Name: "cache-workspace",
|
||||
PersistentVolumeClaim: &corev1.PersistentVolumeClaimVolumeSource{
|
||||
ClaimName: getPipelinePvcName(f),
|
||||
},
|
||||
SubPath: "cache",
|
||||
})
|
||||
} else if f.Build.Builder == builders.S2I {
|
||||
if f.Build.Builder == builders.S2I {
|
||||
if f.Runtime == "quarkus" {
|
||||
params = append(params, pplnv1beta1.Param{Name: "s2iImageScriptsUrl", Value: *pplnv1beta1.NewArrayOrString("image:///usr/local/s2i")})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,10 @@ func taskS2iBuild(runAfter []string) pplnv1beta1.PipelineTask {
|
|||
Name: "source",
|
||||
Workspace: "source-workspace",
|
||||
},
|
||||
{
|
||||
Name: "cache",
|
||||
Workspace: "cache-workspace",
|
||||
},
|
||||
{
|
||||
Name: "dockerconfig",
|
||||
Workspace: "dockerconfig-workspace",
|
||||
|
|
|
|||
Loading…
Reference in New Issue