-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-production-containers.sh
executable file
·55 lines (47 loc) · 1.31 KB
/
build-production-containers.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
#!/usr/bin/env bash
if [ "$#" != 1 ] ; then
echo "Please provide a version number for these containers: e.g. 0.1.0"
exit -1
fi
VERSION="${1}"
read -p '>> Build the code? [y|N] ' resp
if [ "$resp" == "y" ] ; then
# Use buildx to build multiplatform containers
docker buildx create --use
echo '>> Building the API code'
docker buildx build --platform linux/amd64,linux/arm64 \
--rm \
-t rrkive/oni:latest \
-t rrkive/oni:${VERSION} \
-f Dockerfile .
docker buildx build --load \
-t rrkive/oni:latest \
-t rrkive/oni:${VERSION} \
-f Dockerfile .
echo
fi
read -p '>> Tag the containers? [y|N] ' resp
if [ "$resp" == "y" ] ; then
cd api
npm version --no-git-tag-version ${VERSION}
cd ..
git tag v${VERSION}
git commit -a -m "tag and bump version"
echo
fi
read -p '>> Push the containers to docker hub? [y|N] ' resp
if [ "$resp" == "y" ] ; then
docker login
echo "Pushing oni containers to docker hub"
docker buildx build --platform=linux/amd64,linux/arm64 \
--push \
--rm \
-t rrkive/oni:latest \
-t rrkive/oni:${VERSION} \
-f Dockerfile .
fi
read -p '>> Remove local container copies? [y|N] ' resp
if [ "$resp" == "y" ] ; then
docker rmi rrkive/oni:latest
docker rmi rrkive/oni:${VERSION}
fi