-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmytekton-demo.yaml
165 lines (158 loc) · 4.19 KB
/
mytekton-demo.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
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: dockerhub-service
secrets:
- name: dockercreds # Create secret for your container registry
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: spring-webflux-demo-git
spec:
type: git
params:
- name: revision
value: master
- name: url
value: https://github.com/vyom-soft/spring-webflux-demo.git
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: spring-webflux-tekton-demo-image
spec:
type: image
params:
- name: url
value: vyomsoft/spring-webflux-tekton-demo
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: my-docker-image-from-git-source
spec:
params:
- name: pathToDockerFile
type: string
description: The path to the dockerfile to build
default: /workspace/docker-source/Dockerfile
- name: pathToContext
type: string
description: |
The build context used by Kaniko
(https://github.com/GoogleContainerTools/kaniko#kaniko-build-contexts)
#default: $(resources.inputs.docker-source.path)
default: /workspace/source
resources:
inputs:
- name: docker-source
type: git
outputs:
- name: builtImage
type: image
steps:
- name: build-sources
image: vyomsoft/spring-webflux-tekton-demo:latest
workingDir: "/workspace/source/$(inputs.params.contextDir)"
args:
- mvn
- -DskipTests
- clean
- package
env:
- name: MAVEN_MIRROR_URL
value: "$(inputs.params.mavenMirrorUrl)"
- name: build-image
image: quay.io/buildah/stable
workingDir: "/workspace/docker-source/$(inputs.params.contextDir)"
command: [ 'buildah', 'bud', '--tls-verify=false', '--layers','-f', '$(inputs.params.dockerFile)', '-t', '$(inputs.params.destinationImage)', '.' ]
volumeMounts:
- name: varlibcknative-tutorial-greeter-image
mountPath: /var/lib/containers
# override security context as container image build need to run as root
securityContext:
allowPrivilegeEscalation: true
runAsUser: 0
privileged: true
- name: build-and-push
image: gcr.io/kaniko-project/executor:debug
# specifying DOCKER_CONFIG is required to allow kaniko to detect docker credential
securityContext:
runAsUser: 0
privileged: true
env:
- name: "DOCKER_CONFIG"
value: "/tekton/home/.docker/"
command:
- /kaniko/executor
args:
- --dockerfile=$(params.pathToDockerFile)
- --destination=$(resources.outputs.builtImage.url)
- --context=$(params.pathToContext)
---
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: my-demo-pipeline
spec:
resources:
- name: spring-webflux-demo-git
type: git
- name: spring-webflux-tekton-demo-image
type: image
tasks:
- name: my-docker-image-from-git-source
taskRef:
name: my-docker-image-from-git-source
params:
- name: pathToDockerFile
value: /workspace/docker-source/Dockerfile
- name: pathToContext
value: /workspace/docker-source
resources:
inputs:
- name: docker-source
resource: docker-source
outputs:
- name: builtImage
resource: builtImage
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineRun
metadata:
name: my-docker-image-from-git-source-pl-run
spec:
pipelineRef:
name: my-demo-pipeline
resources:
- name: docker-source
resourceRef:
name: docker-source
- name: builtImage
resourceRef:
name: builtImage
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
name: my-docker-image-from-git-source-task-run
spec:
serviceAccountName: dockerhub-service
taskRef:
name: my-docker-image-from-git-source
params:
- name: pathToDockerFile
value: Dockerfile
- name: pathToContext
value: /workspace/docker-source
resources:
inputs:
- name: docker-source
resourceRef:
name: spring-webflux-demo-git
outputs:
- name: builtImage
resourceRef:
name: spring-webflux-tekton-demo-image