-
Notifications
You must be signed in to change notification settings - Fork 579
/
Copy pathbuildpacks-phases.yaml
183 lines (170 loc) · 5.64 KB
/
buildpacks-phases.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: buildpacks-phases
labels:
app.kubernetes.io/version: "0.1"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/tags: image-build
tekton.dev/displayName: "buildpacks-phases"
spec:
description: >-
The Buildpacks-Phases task builds source into a container image and pushes it to
a registry, using Cloud Native Buildpacks. This command separately calls the aspects of the
Cloud Native Buildpacks lifecycle, to provide more granular control over the construction of
the image.
Cloud Native Buildpacks are pluggable, modular tools that transform application source code
into OCI images. They replace Dockerfiles in the app development lifecycle, and allow for swift
rebasing of images, and give modular control over images through the use of builders, among other
benefits. This command uses a builder to construct the image, and pushes it to the registry provided.
params:
- name: BUILDER_IMAGE
description: The image on which builds will run (must include lifecycle and compatible buildpacks).
- name: CACHE
description: The name of the persistent app cache volume.
default: empty-dir
- name: PLATFORM_DIR
description: The name of the platform directory.
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"
- name: PROCESS_TYPE
description: The default process type to set on the image.
default: "web"
- name: SOURCE_SUBPATH
description: A subpath within the `source` input where the source to build is located.
default: ""
resources:
outputs:
- name: image
type: image
workspaces:
- name: source
stepTemplate:
env:
- name: CNB_PLATFORM_API
value: "0.3"
steps:
# Ensure the builder's user has read/write permissions for needed directories.
- name: prepare
image: alpine
imagePullPolicy: Always
command: ["/bin/sh"]
args:
- "-c"
- >
chown -R "$(params.USER_ID):$(params.GROUP_ID)" "/tekton/home" &&
chown -R "$(params.USER_ID):$(params.GROUP_ID)" "/layers" &&
chown -R "$(params.USER_ID):$(params.GROUP_ID)" "/cache" &&
chown -R "$(params.USER_ID):$(params.GROUP_ID)" "$(workspaces.source.path)"
volumeMounts:
- name: layers-dir
mountPath: /layers
- name: $(params.CACHE)
mountPath: /cache
securityContext:
privileged: true
# Copy stack.toml so that it will be accessible to the exporter, since the lifecycle image will not contain it.
- name: copy-stack-toml
image: $(params.BUILDER_IMAGE)
imagePullPolicy: Always
command: ["/bin/sh"]
args:
- "-c"
- >
cp /cnb/stack.toml /layers/
volumeMounts:
- name: layers-dir
mountPath: /layers
- name: detect
image: $(params.BUILDER_IMAGE)
imagePullPolicy: Always
command: ["/cnb/lifecycle/detector"]
args:
- "-app=$(workspaces.source.path)/$(params.SOURCE_SUBPATH)"
- "-group=/layers/group.toml"
- "-plan=/layers/plan.toml"
volumeMounts:
- name: layers-dir
mountPath: /layers
- name: $(params.PLATFORM_DIR)
mountPath: /platform
- name: empty-dir
mountPath: /tekton/home
- name: analyze
image: buildpacksio/lifecycle:0.8.1
imagePullPolicy: Always
command: ["/cnb/lifecycle/analyzer"]
args:
- "-layers=/layers"
- "-group=/layers/group.toml"
- "-cache-dir=/cache"
- "-uid=$(params.USER_ID)"
- "-gid=$(params.GROUP_ID)"
- "$(resources.outputs.image.url)"
volumeMounts:
- name: $(params.CACHE)
mountPath: /cache
- name: layers-dir
mountPath: /layers
- name: restore
image: buildpacksio/lifecycle:0.8.1
imagePullPolicy: Always
command: ["/cnb/lifecycle/restorer"]
args:
- "-group=/layers/group.toml"
- "-layers=/layers"
- "-cache-dir=/cache"
- "-uid=$(params.USER_ID)"
- "-gid=$(params.GROUP_ID)"
volumeMounts:
- name: $(params.CACHE)
mountPath: /cache
- name: layers-dir
mountPath: /layers
- name: build
image: $(params.BUILDER_IMAGE)
imagePullPolicy: Always
command: ["/cnb/lifecycle/builder"]
args:
- "-app=$(workspaces.source.path)/$(params.SOURCE_SUBPATH)"
- "-layers=/layers"
- "-group=/layers/group.toml"
- "-plan=/layers/plan.toml"
volumeMounts:
- name: layers-dir
mountPath: /layers
- name: $(params.PLATFORM_DIR)
mountPath: /platform
- name: empty-dir
mountPath: /tekton/home
- name: export
image: buildpacksio/lifecycle:0.8.1
imagePullPolicy: Always
command: ["/cnb/lifecycle/exporter"]
args:
- "-app=$(workspaces.source.path)/$(params.SOURCE_SUBPATH)"
- "-layers=/layers"
- "-group=/layers/group.toml"
- "-cache-dir=/cache"
- "-process-type=$(params.PROCESS_TYPE)"
- "-uid=$(params.USER_ID)"
- "-gid=$(params.GROUP_ID)"
- "-stack=/layers/stack.toml"
- "$(resources.outputs.image.url)"
volumeMounts:
- name: layers-dir
mountPath: /layers
- name: $(params.CACHE)
mountPath: /cache
volumes:
- name: empty-dir
emptyDir: {}
- name: layers-dir
emptyDir: {}