Skip to content

Commit

Permalink
Renaming the pack build builder PR
Browse files Browse the repository at this point in the history
Signed-off-by: cmoulliard <[email protected]>
  • Loading branch information
cmoulliard committed Aug 29, 2024
1 parent f2c6703 commit 983ca42
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 25 deletions.
46 changes: 22 additions & 24 deletions configurations/konflux/build-bash-pack-cfg.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# The type will be used by the application to generate the resources for the selected provider: konflux, tekton
type: konflux
domain: build
namespace: user-ns1
namespace: cmoullia

repository:
url: https://github.com/ch007m/new-quarkus-app-1
dockerfilePath: src/main/docker/Dockerfile.jvm
url: https://github.com/paketo-community/builder-ubi-base

# To generate the Application and/or Component CR
application:
Expand All @@ -17,8 +16,8 @@ component:

job:
resourceType: PipelineRun
name: quarkus-1-on-push
description: PipelineRun performing a build of a Quarkus application using a bash script
name: pack-build-builder-image
description: PipelineRun using the pack cli to build the builder image

workspaces:
- name: workspace
Expand All @@ -33,35 +32,29 @@ job:
- IMAGE_URL: "$(tasks.build-container.results.IMAGE_URL)"
- IMAGE_DIGEST: "$(tasks.build-container.results.IMAGE_DIGEST)"
- BASE_IMAGES_DIGESTS: "$(tasks.build-container.results.BASE_IMAGES_DIGESTS)"
#- JAVA_COMMUNITY_DEPENDENCIES: "$(tasks.build-container.results.JAVA_COMMUNITY_DEPENDENCIES)"
- CHAINS-GIT_URL: "$(tasks.clone-repository.results.url)"
- CHAINS-GIT_COMMIT: "$(tasks.clone-repository.results.commit)"

params:
- git-url: "{{source_url}}"
- revision: "{{revision}}"
- output-image: "quay.io/ch007m/user-ns1/my-quarkus/quarkus-1:{{revision}}"
- output-image: "quay.io/ch007m/builder-ubi-base:{{revision}}"
- image-expires-after: "5d"
- build-image-index: ""
# We need the following parameters when defined part of the PipelineSpec with default value and used by a task
- build-source-image: false
- prefetch-input: ""

# virt
- virtualMachineName: vm-podman
- virtualMachineNamespace: vm-services

# Buildpack params
- source-dir: "source"
- imageUrl: "buildpacksio/pack"
- imageTag: "latest"
- packCmdBuilderFlags:
- build
- -B
- quay.io/snowdrop/ubi-builder
- -e
- BP_JVM_VERSION=21
- quarkus-hello:1.0
- builder
- create
- builder
- --config
- $(workspaces.source.path)/$(params.SOURCE_SUBPATH)/builder.toml

actions:
# Finally
Expand All @@ -81,11 +74,11 @@ job:
- build-task-status: "$(tasks.build-container.status)"

# Tasks
- name: virtualmachine
params:
- name: $(params.virtualMachineName)
- namespace: $(params.virtualMachineNamespace)
ref: url://https://raw.githubusercontent.com/ch007m/pipeline-dsl-builder/faba87980ecb7cbc35aa925d9c9d3562bba4f783/bundles/virtualmachine.yaml
#- name: virtualmachine
# params:
# - name: $(params.virtualMachineName)
# - namespace: $(params.virtualMachineNamespace)
# ref: url://https://raw.githubusercontent.com/ch007m/pipeline-dsl-builder/faba87980ecb7cbc35aa925d9c9d3562bba4f783/bundles/virtualmachine.yaml

- name: pack
params:
Expand All @@ -94,14 +87,16 @@ job:
- DOCKER_HOST: $(tasks.virtualmachine.results.ip)
#- PACK_CMD_FLAGS:
# - "$(params.packCmdBuilderFlags)"
workspaces:
- name: source
workspace: workspace
results:
- IMAGE_URL: "Image repository where the built image was pushed"
- IMAGE_DIGEST: "Digest of the image just built"
- BASE_IMAGES_DIGESTS: "Digests of the base images used for build"

args:
- "$(params.packCmdBuilderFlags)"

script: |
#!/usr/bin/env bash
set -e
Expand All @@ -111,8 +106,10 @@ job:
echo "Checking pack ..."
pack --version
pack config experimental true
export DOCKER_HOST=tcp://$(params.DOCKER_HOST):2376
echo "DOCKER_HOST=tcp://$(params.DOCKER_HOST):2376"
# We cannot get the array from the params PACK_CMD_FLAGS within the bash script as substitution don't work in this case !!
echo "Getting the arguments ..."
Expand All @@ -125,7 +122,8 @@ job:
echo "arg: $i"
done
echo "Building the image ..."
echo "Building the builder image ..."
echo "pack ${CLI_ARGS[@]}"
pack "${CLI_ARGS[@]}"
echo -n "URL of the image build is : quarkus-hello:1.0" | tee "$(results.IMAGE_URL.path)"
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/dev/snowdrop/factory/TektonResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ public static HasMetadata create(Configurator cfg) {
public static PipelineTask createTaskWithEmbeddedScript(Action action, String runAfter, List<String> args, List<When> when, Map<String, Workspace> jobWorkspacesMap, List<TaskResult> results) {
String embeddedScript;

// List of workspaces's user defined part of the job / action definition
List<WorkspaceDeclaration> taskWorkspaces = new ArrayList<>();
if (action.getWorkspaces() != null && !action.getWorkspaces().isEmpty()) {
action.getWorkspaces().forEach(wks -> {
taskWorkspaces.add(new WorkspaceDeclarationBuilder()
.withName(wks.getName())
// TODO: Should we also uspport to define a volume to mount
.build());
});
}

if (action.getScript() != null) {
embeddedScript = action.getScript();
} else if (action.getScriptFileUrl() != null) {
Expand Down Expand Up @@ -73,7 +84,7 @@ public static PipelineTask createTaskWithEmbeddedScript(Action action, String ru
.build())
.toArray(WhenExpression[]::new))
.withParams(action.getParams() != null ? populatePipelineParams(action.getParams()) : null)
.withWorkspaces(populateTaskWorkspaces(action, jobWorkspacesMap, null))
.withWorkspaces(populateTaskWorkspaces(action, jobWorkspacesMap, taskWorkspaces))
.withTaskSpec(
new EmbeddedTaskBuilder()
.addNewStep()
Expand Down

0 comments on commit 983ca42

Please sign in to comment.