-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask.yaml
51 lines (50 loc) · 1.28 KB
/
task.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
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: build-and-push
namespace: nanjun
spec:
inputs:
resources:
- name: golang-resource
type: git
params:
- name: dockerfile-path
type: string
default: $(inputs.resources.golang-resource.path)/
description: dockerfile path
outputs:
resources:
- name: builtImage
type: image
steps:
- name: build-with-golangenv
image: golang
script: |
#!/usr/bin/env sh
cd $(inputs.resources.golang-resource.path)/
export GO111MODULE=on
export GOPROXY=https://goproxy.io
env
go mod download
go build -o main .
ls
- name: image-build-and-push
image: docker:stable
script: |
#!/usr/bin/env sh
docker login registry.nanjun
docker build --rm --label buildNumber=1 -t $(outputs.resources.builtImage.url) $(inputs.params.dockerfile-path)
docker push $(outputs.resources.builtImage.url)
volumeMounts:
- name: docker-sock
mountPath: /var/run/docker.sock
- name: hosts
mountPath: /etc/hosts
volumes:
- name: docker-sock
hostPath:
path: /var/run/docker.sock
- name: hosts
hostPath:
path: /etc/hosts