Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add paketo builder option for buildpack #190

Merged
merged 3 commits into from
May 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ This operator ships two CRDs(the `Build` and `BuildRun`) in order to register a
Examples of `Build` resource using the example strategies shipped with this operator.

* [`buildah`](samples/build/build_buildah_cr.yaml)
* [`buildpacks-v3-heroku`](samples/build/build_buildpacks-v3-heroku_cr.yaml)
* [`buildpacks-v3`](samples/build/build_buildpacks-v3_cr.yaml)
* [`kaniko`](samples/build/build_kaniko_cr.yaml)
* [`source-to-image`](samples/build/build_source-to-image_cr.yaml)
Expand Down Expand Up @@ -106,7 +107,8 @@ spec:
| Build Strategy | Alpha | Beta | GA |
| ------------------------------------------------------------------------------- | ----- | ---- | -- |
| [Source-to-Image](samples/buildstrategy/buildstrategy_source-to-image_cr.yaml) | ☑ | | |
| [Buildpacks-v3](samples/buildstrategy/buildstrategy_buildpacks-v3-cr.yaml) | ☑️ | | |
| [Buildpacks-v3-heroku](samples/buildstrategy/buildstrategy_buildpacks-v3-heroku_cr.yaml) | ☑️ | | |
| [Buildpacks-v3](samples/buildstrategy/buildstrategy_buildpacks-v3_cr.yaml) | ☑️ | | |
| [Kaniko](samples/buildstrategy/buildstrategy_kaniko_cr.yaml) | ☑️ | | |
| [Buildah](samples/buildstrategy/buildstrategy_buildah_cr.yaml) | ☑️ | | |

Expand Down
2 changes: 1 addition & 1 deletion docs/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ spec:
name: buildpacks-v3
kind: ClusterBuildStrategy
builder:
image: heroku/buildpacks:18
image: gcr.io/paketo-buildpacks/builder:latest
```

### Defining Resources
Expand Down
11 changes: 7 additions & 4 deletions docs/buildstrategies.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A `ClusterBuildStrategy` is available cluster-wide, while a `BuildStrategy` is a
Well-known strategies can be boostrapped from [here](samples/buildstrategy). The current supported Cluster BuildStrategy are:

- [buildah](../samples/buildstrategy/buildah/buildstrategy_buildah_cr.yaml)
- [buildpacks-v3-heroku](../samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3-heroku_cr.yaml)
- [buildpacks-v3](../samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3_cr.yaml)
- [kaniko](../samples/buildstrategy/kaniko/buildstrategy_kaniko_cr.yaml)
- [source-to-image](../samples/buildstrategy/source-to-image/buildstrategy_source-to-image_cr.yaml)
Expand All @@ -33,6 +34,7 @@ Well-known strategies can be boostrapped from [here](samples/buildstrategy). The

The current supported namespaces BuildStrategy are:

- [buildpacks-v3-heroku](../samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3-heroku_namespaced_cr.yaml)
- [buildpacks-v3](../samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3_namespaced_cr.yaml)

---
Expand All @@ -57,21 +59,22 @@ The [buildpacks-v3][buildpacks] BuildStrategy/ClusterBuildStrategy uses a Cloud

- [`heroku/buildpacks:18`][hubheroku]
- [`cloudfoundry/cnb:bionic`][hubcloudfoundry]
- [`gcr.io/paketo-buildpacks/builder:latest`](https://console.cloud.google.com/gcr/images/paketo-buildpacks/GLOBAL/builder?gcrImageListsize=30)

### Installing Buildpacks v3 Strategy

You can install the `BuildStrategy` in your namespace or install the `ClusterBuildStrategy` at cluster scope so that it can be shared across namespaces.

To install the cluster scope strategy, use:
To install the cluster scope strategy, use (below is a heroku example, you can also use paketo sample):

```sh
kubectl apply -f samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3_cr.yaml
kubectl apply -f samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3-heroku_cr.yaml
```

To install the namespaced scope strategy, use:

```sh
kubectl apply -f samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3_namespaced_cr.yaml
kubectl apply -f samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3-heroku_namespaced_cr.yaml
```

### Try it
Expand All @@ -93,7 +96,7 @@ To use this strategy follow this steps:
strategy:
name: buildpacks-v3
kind: ClusterBuildStrategy
builderImage: heroku/buildpacks:18
builderImage: gcr.io/paketo-buildpacks/builder:latest
output:
image: quay.io/yourorg/yourrepo
credentials: <your-kubernetes-container-registry-secret>
Expand Down
1 change: 1 addition & 0 deletions hack/crd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CRDS=(
deploy/crds/build.dev_builds_crd.yaml
deploy/crds/build.dev_buildruns_crd.yaml
# cluster scope build strategies
samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3-heroku_cr.yaml
samples/buildstrategy/buildpacks-v3/buildstrategy_buildpacks-v3_cr.yaml
samples/buildstrategy/buildah/buildstrategy_buildah_cr.yaml
samples/buildstrategy/kaniko/buildstrategy_kaniko_cr.yaml
Expand Down
15 changes: 15 additions & 0 deletions samples/build/build_buildpacks-v3-heroku_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: build.dev/v1alpha1
kind: Build
metadata:
name: buildpack-nodejs-build-heroku
spec:
source:
url: https:/sclorg/nodejs-ex
strategy:
name: buildpacks-v3-heroku
kind: ClusterBuildStrategy
builder:
image: heroku/buildpacks:18
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
22 changes: 22 additions & 0 deletions samples/build/build_buildpacks-v3-heroku_namespaced_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
apiVersion: build.dev/v1alpha1
kind: Build
metadata:
name: buildpack-nodejs-build-namespaced-heroku
spec:
source:
url: https:/sclorg/nodejs-ex
strategy:
name: buildpacks-v3-heroku
kind: BuildStrategy
builder:
image: heroku/buildpacks:18
resources:
limits:
cpu: "500m"
memory: "1Gi"
request:
cpu: "500m"
memory: "1Gi"
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
2 changes: 1 addition & 1 deletion samples/build/build_buildpacks-v3_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ spec:
name: buildpacks-v3
kind: ClusterBuildStrategy
builder:
image: heroku/buildpacks:18
image: gcr.io/paketo-buildpacks/builder:latest
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
2 changes: 1 addition & 1 deletion samples/build/build_buildpacks-v3_namespaced_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spec:
name: buildpacks-v3
kind: BuildStrategy
builder:
image: heroku/buildpacks:18
image: gcr.io/paketo-buildpacks/builder:latest
resources:
limits:
cpu: "500m"
Expand Down
11 changes: 11 additions & 0 deletions samples/buildrun/buildrun_buildpacks-v3-heroku_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: build.dev/v1alpha1
kind: BuildRun
metadata:
name: buildpack-nodejs-buildrun-heroku
spec:
buildRef:
name: buildpack-nodejs-build-heroku
serviceAccount:
name: pipeline
generate: true
SaschaSchwarze0 marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions samples/buildrun/buildrun_buildpacks-v3-heroku_namespaced_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: build.dev/v1alpha1
kind: BuildRun
metadata:
name: buildpack-nodejs-buildrun-namespaced-heroku
spec:
buildRef:
name: buildpack-nodejs-build-namespaced-heroku
serviceAccount:
name: pipeline
generate: true
SaschaSchwarze0 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
apiVersion: build.dev/v1alpha1
kind: ClusterBuildStrategy
metadata:
name: buildpacks-v3-heroku
spec:
buildSteps:
- name: step-prepare
image: $(build.builder.image)
securityContext:
runAsUser: 0
capabilities:
add: ["CHOWN"]
command:
- /bin/bash
args:
- -c
- chown -R "1000:1000" "/workspace/source"
- name: step-detect
image: $(build.builder.image)
securityContext:
runAsUser: 1000
command:
- /cnb/lifecycle/detector
args:
- -app=/workspace/source
- -group=/layers/group.toml
- -plan=/layers/plan.toml
volumeMounts:
- name: layers-dir
mountPath: /layers
- name: step-restore
image: $(build.builder.image)
securityContext:
runAsUser: 1000
command:
- /cnb/lifecycle/restorer
args:
- -layers=/layers
- -cache-dir=/cache
- -group=/layers/group.toml
volumeMounts:
- name: cache-dir
mountPath: /cache
- name: layers-dir
mountPath: /layers
- name: step-build
image: $(build.builder.image)
securityContext:
runAsUser: 1000
command:
- /cnb/lifecycle/builder
args:
- -app=/workspace/source
- -layers=/layers
- -group=/layers/group.toml
- -plan=/layers/plan.toml
volumeMounts:
- name: layers-dir
mountPath: /layers
- name: step-export
image: $(build.builder.image)
securityContext:
runAsUser: 0
command:
- /cnb/lifecycle/exporter
args:
- -app=/workspace/source
- -layers=/layers
- -cache-dir=/cache
- -group=/layers/group.toml
- -helpers=true
- $(build.output.image)
volumeMounts:
- name: cache-dir
mountPath: /cache
- name: layers-dir
mountPath: /layers
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
apiVersion: build.dev/v1alpha1
kind: BuildStrategy
metadata:
name: buildpacks-v3-heroku
spec:
buildSteps:
- name: step-prepare
image: $(build.builder.image)
securityContext:
runAsUser: 0
capabilities:
add: ["CHOWN"]
command:
- /bin/bash
args:
- -c
- chown -R "1000:1000" "/workspace/source"
- name: step-detect
image: $(build.builder.image)
securityContext:
runAsUser: 1000
command:
- /cnb/lifecycle/detector
args:
- -app=/workspace/source
- -group=/layers/group.toml
- -plan=/layers/plan.toml
volumeMounts:
- name: layers-dir
mountPath: /layers
- name: step-restore
image: $(build.builder.image)
securityContext:
runAsUser: 1000
command:
- /cnb/lifecycle/restorer
args:
- -layers=/layers
- -cache-dir=/cache
- -group=/layers/group.toml
volumeMounts:
- name: cache-dir
mountPath: /cache
- name: layers-dir
mountPath: /layers
- name: step-build
image: $(build.builder.image)
securityContext:
runAsUser: 1000
command:
- /cnb/lifecycle/builder
args:
- -app=/workspace/source
- -layers=/layers
- -group=/layers/group.toml
- -plan=/layers/plan.toml
volumeMounts:
- name: layers-dir
mountPath: /layers
- name: step-export
image: $(build.builder.image)
securityContext:
runAsUser: 0
command:
- /cnb/lifecycle/exporter
args:
- -app=/workspace/source
- -layers=/layers
- -cache-dir=/cache
- -group=/layers/group.toml
- -helpers=true
- $(build.output.image)
volumeMounts:
- name: cache-dir
mountPath: /cache
- name: layers-dir
mountPath: /layers
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ spec:
- /bin/bash
args:
- -c
- chown -R "1000:1000" "/workspace/source"
- >
chown -R "1000:1000" "/workspace/source" &&
chown -R "1000:1000" "/tekton/home"
- name: step-detect
image: $(build.builder.image)
securityContext:
Expand Down Expand Up @@ -61,15 +63,14 @@ spec:
- name: step-export
image: $(build.builder.image)
securityContext:
runAsUser: 0
runAsUser: 1000
command:
- /cnb/lifecycle/exporter
args:
- -app=/workspace/source
- -layers=/layers
- -cache-dir=/cache
- -group=/layers/group.toml
- -helpers=true
- $(build.output.image)
volumeMounts:
- name: cache-dir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ spec:
- /bin/bash
args:
- -c
- chown -R "1000:1000" "/workspace/source"
- >
chown -R "1000:1000" "/workspace/source" &&
chown -R "1000:1000" "/tekton/home"
- name: step-detect
image: $(build.builder.image)
securityContext:
Expand Down Expand Up @@ -61,15 +63,14 @@ spec:
- name: step-export
image: $(build.builder.image)
securityContext:
runAsUser: 0
runAsUser: 1000
command:
- /cnb/lifecycle/exporter
args:
- -app=/workspace/source
- -layers=/layers
- -cache-dir=/cache
- -group=/layers/group.toml
- -helpers=true
- $(build.output.image)
volumeMounts:
- name: cache-dir
Expand Down
15 changes: 15 additions & 0 deletions test/data/build_buildpacks-v3-heroku_cr_private_github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: build.dev/v1alpha1
kind: Build
metadata:
name: buildpack-nodejs-build-heroku
spec:
source:
url: [email protected]:qu1queee/new-nodejs-ex.git
strategy:
name: buildpacks-v3-heroku
kind: ClusterBuildStrategy
builder:
image: heroku/buildpacks:18
output:
image: image-registry.openshift-image-registry.svc:5000/build-examples/taxi-app
Loading