This repository has been archived by the owner on Sep 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds template for Cloud Native Buildpacks (#67)
* Add Cloud Native Buildpacks build-template Signed-off-by: Emily Casey <ecasey@pivotal.io> * Update CNB build template to use updated lifecycle and v3alpaha2 images Signed-off-by: Emily Casey <ecasey@pivotal.io> * Fixes buildpacks/README-CF.md Signed-off-by: Emily Casey <ecasey@pivotal.io> * Writes group.toml and plan.toml in layers dir Signed-off-by: Emily Casey <ecasey@pivotal.io> * Chown app dir in prepare step Signed-off-by: Emily Casey <ecasey@pivotal.io>
- Loading branch information
1 parent
b296278
commit 0091c3b
Showing
7 changed files
with
185 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Buildpack V3 | ||
|
||
This build template builds source into a container image using [Cloud Native Buildpacks](https://buildpacks.io). | ||
|
||
The Cloud Native Buildpacks website describes v3 buildpacks as: | ||
|
||
> ... pluggable, modular tools that translate source code into container-ready artifacts | ||
> such as OCI images. They replace Dockerfiles in the app development lifecycle with a higher level | ||
> of abstraction. ... Cloud Native Buildpacks embrace modern container standards, such as the OCI | ||
> image format. They take advantage of the latest capabilities of these standards, such as remote | ||
> image layer rebasing on Docker API v2 registries. | ||
**Note**: The current Cloud Foundry buildpacks are available in the [CF template](README-CF.md). | ||
|
||
## Create the template | ||
|
||
``` | ||
kubectl apply -f https://raw.githubusercontent.com/knative/build-templates/master/buildpacks/cnb.yaml | ||
``` | ||
|
||
## Parameters | ||
|
||
* **IMAGE:** The image you wish to create. For example, "repo/example", or "example.com/repo/image". (_required_) | ||
* **RUN_IMAGE:** The run image buildpacks will use as the base for IMAGE. (_default:_ `packs/run:v3alpha2`) | ||
* **BUILDER_IMAGE** The image on which builds will run. ( default: `packs/samples:v3alpha2`) | ||
* **USE_CRED_HELPERS:** Use Docker credential helpers. Set to `"true"` or `"false"` as string values. (_default:_ `"true"`) | ||
* **CACHE** The name of the persistent app cache volume (_default:_ an empty directory -- effectively no cache) | ||
* **USER_ID** The user ID of the builder image user (_default:_ 1000) | ||
* **GROUP_ID** The group ID of the builder image user (_default:_ 1000) | ||
|
||
## Usage | ||
|
||
``` | ||
apiVersion: build.knative.dev/v1alpha1 | ||
kind: Build | ||
metadata: | ||
name: cnb-example-build | ||
spec: | ||
source: | ||
git: | ||
url: https://github.com/my-user/my-repo | ||
revision: master | ||
template: | ||
name: buildpacks-cnb | ||
arguments: | ||
- name: IMAGE | ||
value: us.gcr.io/my-project/my-app | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
--- | ||
apiVersion: build.knative.dev/v1alpha1 | ||
kind: BuildTemplate | ||
metadata: | ||
name: buildpacks-cnb | ||
spec: | ||
parameters: | ||
- name: IMAGE | ||
description: The image you wish to create. For example, "repo/example", or "example.com/repo/image". | ||
- name: RUN_IMAGE | ||
description: The run image buildpacks will use as the base for IMAGE. | ||
default: packs/run:v3alpha2 | ||
- name: BUILDER_IMAGE | ||
description: The builder image (must include v3 lifecycle and compatible buildpacks). | ||
default: packs/samples:v3alpha2 | ||
- name: USE_CRED_HELPERS | ||
description: Use Docker credential helpers for Google's GCR, Amazon's ECR, or Microsoft's ACR. | ||
default: 'true' | ||
- name: CACHE | ||
description: The name of the persistent app cache volume | ||
default: empty-dir | ||
- name: USER_ID | ||
description: The user ID of the builder image user | ||
default: "1000" | ||
- name: GROUP_ID | ||
description: The group ID of the builder image user | ||
default: "1000" | ||
|
||
steps: | ||
- name: prepare | ||
image: alpine | ||
command: ["/bin/sh"] | ||
args: | ||
- "-c" | ||
- > | ||
chown -R "${USER_ID}:${GROUP_ID}" "/builder/home" && | ||
chown -R "${USER_ID}:${GROUP_ID}" /layers && | ||
chown -R "${USER_ID}:${GROUP_ID}" /workspace | ||
volumeMounts: | ||
- name: "${CACHE}" | ||
mountPath: /layers | ||
imagePullPolicy: Always | ||
- name: detect | ||
image: ${BUILDER_IMAGE} | ||
command: ["/lifecycle/detector"] | ||
args: | ||
- "-app=/workspace" | ||
- "-group=/layers/group.toml" | ||
- "-plan=/layers/plan.toml" | ||
volumeMounts: | ||
- name: "${CACHE}" | ||
mountPath: /layers | ||
imagePullPolicy: Always | ||
- name: analyze | ||
image: ${BUILDER_IMAGE} | ||
command: ["/lifecycle/analyzer"] | ||
args: | ||
- "-layers=/layers" | ||
- "-helpers=${USE_CRED_HELPERS}" | ||
- "-group=/layers/group.toml" | ||
- "${IMAGE}" | ||
volumeMounts: | ||
- name: "${CACHE}" | ||
mountPath: /layers | ||
imagePullPolicy: Always | ||
- name: build | ||
image: ${BUILDER_IMAGE} | ||
command: ["/lifecycle/builder"] | ||
args: | ||
- "-layers=/layers" | ||
- "-app=/workspace" | ||
- "-group=/layers/group.toml" | ||
- "-plan=/layers/plan.toml" | ||
volumeMounts: | ||
- name: "${CACHE}" | ||
mountPath: /layers | ||
imagePullPolicy: Always | ||
- name: export | ||
image: ${BUILDER_IMAGE} | ||
command: ["/lifecycle/exporter"] | ||
args: | ||
- "-layers=/layers" | ||
- "-helpers=${USE_CRED_HELPERS}" | ||
- "-app=/workspace" | ||
- "-image=${RUN_IMAGE}" | ||
- "-group=/layers/group.toml" | ||
- "${IMAGE}" | ||
volumeMounts: | ||
- name: "${CACHE}" | ||
mountPath: /layers | ||
imagePullPolicy: Always | ||
|
||
volumes: | ||
- name: empty-dir | ||
emptyDir: {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
apiVersion: build.knative.dev/v1alpha1 | ||
kind: Build | ||
metadata: | ||
name: cf-build | ||
spec: | ||
source: | ||
git: | ||
url: https://github.com/my-user/my-repo | ||
revision: v1.0 | ||
template: | ||
name: buildpacks-cloudfoundry | ||
arguments: | ||
- name: IMAGE | ||
value: us.gcr.io/my-project/my-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
apiVersion: build.knative.dev/v1alpha1 | ||
kind: Build | ||
metadata: | ||
name: buildpack-build | ||
name: cnb-build | ||
spec: | ||
source: | ||
git: | ||
url: https://github.com/my-user/my-repo | ||
revision: v1.0 | ||
template: | ||
name: buildpack | ||
name: buildpacks-cnb | ||
arguments: | ||
- name: IMAGE | ||
value: us.gcr.io/my-project/my-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters