-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathTaskfileBuild.yml
More file actions
85 lines (77 loc) · 3.08 KB
/
Copy pathTaskfileBuild.yml
File metadata and controls
85 lines (77 loc) · 3.08 KB
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
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
version: '3'
vars:
# taken from the tag - overridable with OPERATOR_TAG env var
OPERATOR_TAG:
sh: echo "${OPERATOR_TAG:-$(git describe --tags --abbrev=0 2>/dev/null || git rev-parse --short HEAD)}"
# taken from the Dockerfile - overridable with MY_OPERATOR_IMAGE env var
OPERATOR_IMAGE:
sh: echo "${MY_OPERATOR_IMAGE:-$(awk -F= '/ARG OPERATOR_IMAGE_DEFAULT=/ { print $2 ; exit }' Dockerfile)}"
tasks:
image:
cmds:
- echo "Operator=${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}}"
silent: true
docker-login: >
echo $GITHUB_TOKEN | docker login ghcr.io -u $GITHUB_USER --password-stdin
build:
- >
docker build .
-t ${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}}
--build-arg OPERATOR_IMAGE_DEFAULT=${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}
--build-arg OPERATOR_TAG_DEFAULT={{.OPERATOR_TAG}} --load
build-and-push:
- task: docker-login
- task: build
- docker push ${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}}
build-and-load:
silent: true
desc: Build the image and loads it to the local Kind, k3s, microk8s cluster
vars:
KUB_TYPE:
sh: ./detect.sh
cmds:
- task: build
- |
IMG="${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}}"
if [ "{{.KUB_TYPE}}" = "kind" ]; then
echo "Loading image to kind"
kind load docker-image $IMG --name=nuvolaris
elif [ "{{.KUB_TYPE}}" = "k3s" ]; then
echo "Loading image to k3s"
docker save $IMG | sudo k3s ctr images import -
elif [ "{{.KUB_TYPE}}" = "microk8s" ]; then
echo "Loading image to microk8s"
docker save $IMG | microk8s ctr images import -
else
echo "Error: unsupported KUB_TYPE '{{.KUB_TYPE}}' for loading images"
exit 1
fi
k3s:build-and-load:
- task: build
- >
docker save ${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}} | sudo k3s ctr images import -
buildx-and-push:
- >
docker buildx build
--platform linux/amd64,linux/arm64
-t ${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}:{{.OPERATOR_TAG}}
--build-arg OPERATOR_IMAGE_DEFAULT=${MY_OPERATOR_IMAGE:-{{.OPERATOR_IMAGE}}}
--build-arg OPERATOR_TAG_DEFAULT={{.OPERATOR_TAG}}
. --push