forked from ricardbejarano/nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildx.sh
54 lines (45 loc) · 1.79 KB
/
buildx.sh
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
source /etc/profile
export |grep DOCKER_REG |grep -Ev "PASS|PW"
repo=registry.cn-shenzhen.aliyuncs.com
echo "${DOCKER_REGISTRY_PW_infrastSubUser2}" |docker login --username=${DOCKER_REGISTRY_USER_infrastSubUser2} --password-stdin $repo
repoHub=docker.io
echo "${DOCKER_REGISTRY_PW_dockerhub}" |docker login --username=${DOCKER_REGISTRY_USER_dockerhub} --password-stdin $repoHub
function doBuildx(){
local tag=$1
local dockerfile=$2
repo=registry-1.docker.io
# repo=registry.cn-shenzhen.aliyuncs.com
test ! -z "$REPO" && repo=$REPO #@gitac
img="build-nginx:$tag"
# cache
ali="registry.cn-shenzhen.aliyuncs.com"
cimg="build-nginx-cache:$tag"
cache="--cache-from type=registry,ref=$ali/$ns/$cimg --cache-to type=registry,ref=$ali/$ns/$cimg"
plat="--platform linux/amd64,linux/arm64,linux/arm"
# plat="--platform linux/amd64,linux/arm64" ##,linux/arm
compile="alpine-compile";
# test "$plat" != "--platform linux/amd64,linux/arm64,linux/arm" && compile="${compile}-dbg"
# --build-arg REPO=$repo/ #temp notes, just use dockerHub's
args="""
--provenance=false
--build-arg REPO=$repo/
--build-arg COMPILE_IMG=$compile
--build-arg NOCACHE=$(date +%Y-%m-%d_%H:%M:%S)
"""
# cd flux
# test "$plat" != "--platform linux/amd64,linux/arm64,linux/arm" && img="${img}-dbg"
# test "$plat" != "--platform linux/amd64,linux/arm64,linux/arm" && cimg="${cimg}-dbg"
cache="--cache-from type=registry,ref=$ali/$ns/$cimg --cache-to type=registry,ref=$ali/$ns/$cimg"
docker buildx build $cache $plat $args --push -t $repo/$ns/$img -f $dockerfile .
}
ns=infrastlabs
ver=v51 #base-v5 base-v5-slim
case "$1" in
nginx)
doBuildx latest Dockerfile
;;
*)
# doBuildx $1 src/Dockerfile.$1
echo "emp params"
;;
esac