Skip to content

Commit ecc45ae

Browse files
committed
Using latest build/test/publish pattern
1 parent 4ea6583 commit ecc45ae

File tree

5 files changed

+97
-55
lines changed

5 files changed

+97
-55
lines changed

Dockerfile.artful

Lines changed: 0 additions & 18 deletions
This file was deleted.

Dockerfile.zesty

Lines changed: 0 additions & 18 deletions
This file was deleted.

build.sh

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
#!/bin/bash
2+
set -e
23

3-
targets=( alpine centos trusty xenial zesty artful bionic)
4+
declare -r PV_DOCKER_REGISTRY="polyverse"
5+
declare -r PV_GIT_COMMIT="$(git rev-parse --verify HEAD)"
6+
declare -r PV_NAME="tcp-echo-server"
47

5-
buildtarget()
6-
{
7-
command="pv build -f Dockerfile.$1 -n tcp-echo-server.$1 ${@:2} docker"
8-
echo $command
9-
$command
10-
}
8+
declare -r PV_TARGETS="alpine centos trusty xenial bionic"
119

12-
buildtargets()
13-
{
14-
for target in "${targets[@]}"
15-
do
16-
buildtarget $target ${@:1}
10+
main() {
11+
for PV_TARGET in ${PV_TARGETS}; do
12+
build ${PV_TARGET}
13+
[ $? -ne 0 ] && return 1
1714
done
15+
16+
return 0
17+
}
18+
19+
build() {
20+
declare -r PV_TARGET="${1}"
21+
22+
# Build the image
23+
docker build -f Dockerfile.${PV_TARGET} -t "${PV_NAME}" -t "${PV_DOCKER_REGISTRY}/${PV_NAME}.${PV_TARGET}:latest" -t "${PV_DOCKER_REGISTRY}/${PV_NAME}.${PV_TARGET}:${PV_GIT_COMMIT}" .
24+
[ $? -ne 0 ] && return 1
25+
26+
return 0
1827
}
1928

20-
# Special keyword "all" means build and push to both polyverse and jfrog repos
21-
if [ "$1" == "all" ]; then
22-
buildtargets -s -r polyverse
23-
buildtargets -s -r internal.hub.polyverse.io
24-
else
25-
buildtarget "$@"
26-
fi
29+
main "$@"
30+
exit $?

publish.sh

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/bin/bash
2+
set -e
3+
4+
declare -r PV_DOCKER_REGISTRY="polyverse"
5+
declare -r PV_GIT_COMMIT="$(git rev-parse --verify HEAD)"
6+
declare -r PV_NAME="tcp-echo-server"
7+
8+
declare -r PV_TARGETS="alpine centos trusty xenial bionic"
9+
10+
main() {
11+
for PV_TARGET in ${PV_TARGETS}; do
12+
publish ${PV_TARGET}
13+
[ $? -ne 0 ] && return 1
14+
done
15+
16+
return 0
17+
}
18+
19+
publish() {
20+
declare -r PV_TARGET="${1}"
21+
22+
# Don't publish when there are uncommitted changes.
23+
if [ ! -z "$(git status -s -uno)" ]; then
24+
echo "COMMIT IS DIRTY, aborting"
25+
exit 1
26+
fi
27+
28+
docker push "${PV_DOCKER_REGISTRY}/${PV_NAME}.${PV_TARGET}:latest"
29+
[ $? -ne 0 ] && return 1
30+
31+
docker push "${PV_DOCKER_REGISTRY}/${PV_NAME}.${PV_TARGET}:${PV_GIT_COMMIT}"
32+
[ $? -ne 0 ] && return 1
33+
34+
return 0
35+
}
36+
37+
build() {
38+
# Build the image
39+
[ $? -ne 0 ] && return 1
40+
41+
return 0
42+
}
43+
44+
main "$@"
45+
exit $?
46+
47+
48+
49+
50+
#!/bin/bash
51+
set -e
52+
53+
declare -r PV_DOCKER_REGISTRY="polyverse"
54+
declare -r PV_GIT_COMMIT="$(git rev-parse --verify HEAD)"
55+
declare -r PV_NAME="readhook-node-echo-server"
56+
57+
main() {
58+
publish
59+
[ $? -ne 0 ] && return 1
60+
61+
return 0
62+
}
63+
64+
main "$@"
65+
exit $?

test.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
set -e
3+
4+
main() {
5+
return 0
6+
}
7+
8+
main "$@"
9+
exit $?

0 commit comments

Comments
 (0)