-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·84 lines (69 loc) · 1.72 KB
/
build.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
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
#!/bin/bash
#
# Script to run a build for a specific microservice and platform.
#
# SYNTAX
#
# docker.sh imagename microservice arch version
#
# Where arch is one of the following: amd64 arm32v6 arm32v7 arm64v8
#
# image should be the full name, e.g. area51/nre-feeds:latest or area51/nre-feeds:0.2
# This script will append -{microservice}-{arch} to that name
#
IMAGE=$1
ARCH=$2
VERSION=$3
MODULE=$4
# The actual image being built
if [ "$MODULE" = "Build" ]
then
TAG=${IMAGE}:${ARCH}-${VERSION}
else
TAG=${IMAGE}:${MODULE}-${ARCH}-${VERSION}
fi
. functions.sh
CMD="docker build --force-rm=true"
CMD="$CMD -t ${TAG}"
CMD="$CMD --build-arg arch=${ARCH}"
# For now just support linux
CMD="$CMD --build-arg goos=linux"
CMD="$CMD --build-arg goarch=$(goarch $ARCH)"
CMD="$CMD --build-arg goarm=$(goarm $ARCH)"
# Multiple module support
if [ "$MODULE" != "Build" ]
then
CMD="$CMD --build-arg module=$MODULE"
fi
# Upload a tar file as part of the build
if [ -n "${UPLOAD_CRED}" -a -n "${JOB_NAME}" ]
then
CMD="$CMD --build-arg uploadCred=${UPLOAD_CRED}"
if [ -z "${UPLOAD_PATH}" ]
then
UPLOAD_PATH=https://nexus.area51.onl/repository/snapshots/
fi
repoPath=$JOB_NAME
if [ "$(basename $repoPath)" = "${BRANCH_NAME}" ]
then
repoPath=$(dirname $repoPath)
fi
repoName="$(basename $repoPath)"
if [ "$MODULE" != "Build" ]
then
repoName="${repoName}-${MODULE}"
fi
repoName="${repoName}-${ARCH}"
if [ -n "${BRANCH_NAME}" ]
then
repoName="${repoName}-${BRANCH_NAME}"
fi
if [ -n "${BUILD_NUMBER}" ]
then
repoName="${repoName}.${BUILD_NUMBER}"
fi
CMD="$CMD --build-arg uploadPath=${UPLOAD_PATH}/${repoPath}/${BRANCH_NAME}"
CMD="$CMD --build-arg uploadName=${repoName}"
fi
CMD="$CMD ."
execute $CMD