Skip to content

Commit 0b11750

Browse files
chrisplounclejack
authored andcommitted
contiv k8s container now tagged with git version (#1082)
* contiv k8s container now tagged with git version the container build can leverage other new tasks to simplify the build script considerably drive-by: found the release notes for the container release was wrong Signed-off-by: Chris Plock <[email protected]> * fix spelling typo for case-sensitive filesystems
1 parent ee9a859 commit 0b11750

File tree

3 files changed

+18
-61
lines changed

3 files changed

+18
-61
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ start-aci-gw:
253253
docker pull $(ACI_GW_IMAGE)
254254
docker run --net=host -itd -e "APIC_URL=SANITY" -e "APIC_USERNAME=IGNORE" -e "APIC_PASSWORD=IGNORE" --name=contiv-aci-gw $(ACI_GW_IMAGE)
255255

256-
host-build-docker-image:
257-
./scripts/netContain/build_image.sh
256+
host-build-docker-image: compile-with-docker binaries-from-container
257+
@./scripts/netContain/build_image.sh
258258

259259
host-cleanup:
260260
@echo dev: cleaning up services...

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@ release isn't made from the HEAD of master.
7070
## Build and upload container image (manual only)
7171

7272
1. cd scripts/netContain
73-
2. ./ReleaseContainer.sh -v <version> -u contiv -i contiv/netplugin
73+
2. ./release_image.sh -v <version> \[-i <image_name>] \[-t <image_tag>]
7474

7575
Here <version> is a version that has been released using steps above and exists on github.

scripts/netContain/build_image.sh

Lines changed: 15 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,31 @@
11
#!/bin/bash
22

3-
BUILD_ENV_IMAGE_NAME="contiv-netplugin-build"
4-
TEMPORARY_CONTAINER_NAME="contiv-netplugin-build-temporary"
5-
FINAL_IMAGE_NAME="contivbase"
3+
set -euo pipefail
64

5+
REPOSITORY="contivbase"
76
NETPLUGIN_BINARIES="netplugin netmaster netctl contivk8s"
7+
IMAGE=$REPOSITORY:${NETPLUGIN_CONTAINER_TAG}
88

99
function get_image_id() {
10-
docker inspect --format '{{.ID}}' $1
11-
return $?
10+
docker inspect --format '{{.ID}}' $IMAGE || :
1211
}
1312

14-
function build_image_from_path() {
15-
set +e
16-
old_image=$(get_image_id $2)
17-
set -e
18-
if [ "$?" -ne 0 ]; then
19-
old_image=
20-
fi
21-
22-
echo "Building image $2 from $1 ..."
23-
docker build -t $2 --force-rm $1
24-
if [ "$?" -ne 0 ]; then
25-
echo "Image $2 was not built properly"
26-
return 1
27-
fi
28-
29-
new_image=$(get_image_id $2)
30-
if [ "$old_image" != "" ] && [ "$old_image" != "$new_image" ]; then
31-
docker rmi $old_image >/dev/null 2>&1 || true
32-
fi
33-
34-
echo "Image $2 has been built"
35-
return 0
36-
}
37-
38-
set -x
39-
set -e
40-
41-
# ensure this script wasn't called from the directory where this script
42-
# lives; it should be called from the repository's top level
43-
script_dir="$(dirname -- "$0")"
44-
if [ "$script_dir" == "." ]; then
45-
echo "This script must be called from the top level of the repository"
46-
exit 1
47-
fi
48-
4913
rm -rf scripts/netContain/bin
5014
mkdir scripts/netContain/bin
5115

52-
build_image_from_path . $BUILD_ENV_IMAGE_NAME
53-
if [ "$?" -ne 0 ]; then
54-
echo "Failed to build the "
55-
exit 1
56-
fi
16+
# it's expected that makefile targets compile-with-docker and
17+
# binaries-from-container have already been run
18+
tar c -C bin $NETPLUGIN_BINARIES | tar x -C scripts/netContain/bin
5719

58-
docker run --name=$TEMPORARY_CONTAINER_NAME $BUILD_ENV_IMAGE_NAME || true
20+
old_image=$(get_image_id)
5921

60-
echo "Copying the Contiv binaries..."
61-
for f in $NETPLUGIN_BINARIES; do
62-
docker cp $TEMPORARY_CONTAINER_NAME:/go/bin/$f scripts/netContain/bin/
63-
done
22+
cd scripts/netContain
6423

65-
docker rm -fv $TEMPORARY_CONTAINER_NAME
24+
docker build -t $IMAGE -t $REPOSITORY:latest .
6625

67-
echo "Building the final Docker image..."
68-
build_image_from_path scripts/netContain contivbase
69-
if [ "$?" -ne 0 ]; then
70-
echo "Failed to build the final Docker image"
71-
exit 1
72-
fi
26+
new_image=$(get_image_id)
7327

74-
rm -rf scripts/netContain/bin
28+
if [ "$old_image" != "" ] && [ "$old_image" != "$new_image" ]; then
29+
echo Removing old image $old_image
30+
docker rmi -f $old_image >/dev/null 2>&1 || true
31+
fi

0 commit comments

Comments
 (0)