-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·47 lines (36 loc) · 960 Bytes
/
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
#!/bin/sh
set -u
# Dockerhub base image
BASE=sncegroup/alpine-aws-docker
# Image Tag passed as argument
VERSION=$1
# Target image
TARGET=${2:-base}
# Check all the published tags
TAGS=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/sncegroup/alpine-aws-docker/tags?page_size=1024' |jq -r '[ .results[].name ]| @text')
# Asks for confirmation before tagging
echo ""
echo "Building new image version!"
echo "---------------------------"
echo
echo "Current available tags: $TAGS"
echo "You are going to tag this image as $BASE:$VERSION using stage \"$TARGET\""
echo
read -p "Are you sure? [yn] " -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Skipped, bye!"
exit 1
fi
# Building the Docker image
echo "Building..."
TAG=${BASE}:${VERSION}
docker build . \
-f ./Dockerfile \
-t ${TAG} \
--target ${TARGET}
docker tag ${BASE}:${VERSION} ${BASE}:latest
docker push ${BASE}:${VERSION}
docker push ${BASE}:latest
echo "Done!"