-
Notifications
You must be signed in to change notification settings - Fork 72
/
build_container.sh
executable file
·55 lines (43 loc) · 1.71 KB
/
build_container.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
source test/util.sh
set -e
DOCKER_BUILD_ARGS=()
if [ "$RESTY_IMAGE_BASE" == "src" ]; then
exit 0
fi
image_id=$(docker image inspect -f '{{.ID}}' "$KONG_TEST_IMAGE_NAME" || true)
if [ -n "$image_id" ]; then
msg_test "Tests image ID: $image_id"
exit 0;
fi
rm -rf docker-kong || true
git clone --single-branch --branch $DOCKER_KONG_VERSION https://github.com/Kong/docker-kong.git docker-kong
if [ "$RESTY_IMAGE_BASE" == "ubuntu" ] || [ "$RESTY_IMAGE_BASE" == "debian" ]; then
cp output/*${RESTY_IMAGE_TAG}.${ARCHITECTURE}.deb docker-kong/ubuntu/kong.deb
BUILD_DIR="ubuntu"
elif [ "$RESTY_IMAGE_BASE" == "alpine" ]; then
cp output/*.${ARCHITECTURE}.apk.tar.gz docker-kong/alpine/kong.tar.gz
BUILD_DIR="alpine"
elif [ "$RESTY_IMAGE_BASE" == "centos" ] || [ "$RESTY_IMAGE_BASE" == "amazonlinux" ]; then
cp output/*.${ARCHITECTURE}.rpm docker-kong/centos/kong.rpm
BUILD_DIR="centos"
fi
if [ "$RESTY_IMAGE_TAG" == "stretch" ] || [ "$RESTY_IMAGE_TAG" == "jessie" ]; then
sed -i 's/apt install --yes /gdebi -n /g' docker-kong/ubuntu/Dockerfile
sed -i 's/unzip git/unzip git gdebi/g' docker-kong/ubuntu/Dockerfile
fi
if [ "$RESTY_IMAGE_BASE" == "rhel" ]; then
cp output/*.rhel${RESTY_IMAGE_TAG}.${ARCHITECTURE}.rpm docker-kong/rhel/kong.rpm
BUILD_DIR="rhel"
DOCKER_BUILD_ARGS+=(--build-arg RHEL_VERSION=$RESTY_IMAGE_TAG)
else
sed -i 's/^FROM .*/FROM '${RESTY_IMAGE_BASE}:${RESTY_IMAGE_TAG}'/' docker-kong/${BUILD_DIR}/Dockerfile
fi
pushd docker-kong/${BUILD_DIR}
DOCKER_BUILD_ARGS+=(--no-cache)
DOCKER_BUILD_ARGS+=(--build-arg ASSET=local .)
docker build -t $KONG_TEST_IMAGE_NAME \
"${DOCKER_BUILD_ARGS[@]}"
docker run -t $KONG_TEST_IMAGE_NAME kong version
popd
rm -rf docker-kong || true