-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-build.sh
executable file
·71 lines (59 loc) · 1.71 KB
/
start-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
#!/usr/bin/env sh
# -----------------------------------------------------------------------------
# Docker Build Container (Linux/AMD64)
# -----------------------------------------------------------------------------
# Author : Dwi Fahni Denni
# License : Apache v2
# -----------------------------------------------------------------------------
set -e
export AWS_ACCOUNT_ID=$1
export AWS_DEFAULT_REGION="us-west-2"
export CI_REGISTRY="$AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com"
export CI_PROJECT_PATH="devopscorner"
export CI_PROJECT_NAME="golang-bedrock"
export IMAGE="$CI_PROJECT_PATH/$CI_PROJECT_NAME"
export ECR_IMAGE="$CI_REGISTRY/$CI_PROJECT_PATH/$CI_PROJECT_NAME"
export TARGETPLATFORM="linux/amd64"
export ARCH="amd64"
export VERSION=`git describe --tags`
build_golang_bedrock() {
TAGS="3.18 \
alpine-3.18 \
alpine-latest \
alpine \
latest \
$VERSION "
### DockerHub Build Images ###
for TAG in $TAGS; do
echo " Build Image => $IMAGE:$TAG"
docker build --no-cache \
-f Dockerfile \
-t $IMAGE:$TAG .
echo ''
done
### ECR Build Images ###
for TAG in $TAGS; do
echo " Build Image => $ECR_IMAGE:$TAG"
docker build --no-cache \
-f Dockerfile \
-t $ECR_IMAGE:$TAG .
echo ''
done
}
docker_build() {
build_golang_bedrock
}
docker_clean() {
echo "Cleanup Unknown Tags"
echo "docker images -a | grep none | awk '{ print $3; }' | xargs docker rmi"
docker images -a | grep none | awk '{ print $3; }' | xargs docker rmi
echo ''
}
main() {
docker_build
docker_clean
echo ''
echo '-- ALL DONE --'
}
### START HERE ###
main