-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from Kong/ci/docker-automation
ci: docker automation
- Loading branch information
Showing
7 changed files
with
178 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
KUMA_DOCKER_REPO="kong-docker-kuma-docker.bintray.io" | ||
KUMA_COMPONENTS=("kuma-cp" "kuma-dp" "kuma-injector" "kuma-tcp-echo") | ||
|
||
function msg_green { | ||
builtin echo -en "\033[1;32m" | ||
echo "$@" | ||
builtin echo -en "\033[0m" | ||
} | ||
|
||
|
||
function msg_red() { | ||
builtin echo -en "\033[1;31m" >&2 | ||
echo "$@" >&2 | ||
builtin echo -en "\033[0m" >&2 | ||
} | ||
|
||
|
||
function msg_yellow() { | ||
builtin echo -en "\033[1;33m" | ||
echo "$@" | ||
builtin echo -en "\033[0m" | ||
} | ||
|
||
|
||
function msg() { | ||
builtin echo -en "\033[1m" | ||
echo "$@" | ||
builtin echo -en "\033[0m" | ||
} | ||
|
||
|
||
function msg_err() { | ||
msg_red $@ | ||
exit 1 | ||
} | ||
|
||
|
||
function build { | ||
for component in "${KUMA_COMPONENTS[@]}"; do | ||
msg "Building $component..." | ||
docker build --build-arg KUMA_ROOT=$(pwd) -t $KUMA_DOCKER_REPO/$component:$KUMA_VERSION \ | ||
-f tools/releases/dockerfiles/Dockerfile.$component . | ||
docker tag $KUMA_DOCKER_REPO/$component:$KUMA_VERSION $KUMA_DOCKER_REPO/$component:latest | ||
msg_green "... done!" | ||
done | ||
} | ||
|
||
|
||
function docker_login { | ||
docker login -u "$BINTRAY_USERNAME" -p "$BINTRAY_API_KEY" $KUMA_DOCKER_REPO | ||
} | ||
|
||
|
||
function docker_logout { | ||
docker logout $KUMA_DOCKER_REPO | ||
} | ||
|
||
|
||
function push { | ||
docker_login | ||
|
||
for component in "${KUMA_COMPONENTS[@]}"; do | ||
msg "Pushing kuma-cp..." | ||
docker push $KUMA_DOCKER_REPO/$component:$KUMA_VERSION | ||
docker push $KUMA_DOCKER_REPO/$component:latest | ||
msg_green "... done!" | ||
done | ||
|
||
docker_logout | ||
} | ||
|
||
|
||
function usage { | ||
echo "Usage: $0 [--build | --push ] --version <Kuma version>" | ||
exit 0 | ||
} | ||
|
||
function main { | ||
while [[ $# -gt 0 ]]; do | ||
flag=$1 | ||
case $flag in | ||
--help) | ||
usage | ||
;; | ||
--build) | ||
op="build" | ||
;; | ||
--push) | ||
op="push" | ||
;; | ||
--version) | ||
KUMA_VERSION=$2 | ||
shift | ||
;; | ||
*) | ||
usage | ||
break | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
[ -z "$BINTRAY_USERNAME" ] && msg_err "BINTRAY_USERNAME required" | ||
[ -z "$BINTRAY_API_KEY" ] && msg_err "BINTRAY_API_KEY required" | ||
[ -z "$KUMA_VERSION" ] && msg_err "Error: --version required" | ||
|
||
case $op in | ||
build) | ||
build | ||
;; | ||
push) | ||
push | ||
;; | ||
esac | ||
} | ||
|
||
|
||
main $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM alpine:3.10 | ||
|
||
ADD $KUMA_ROOT/build/artifacts-linux-amd64/kuma-cp/kuma-cp /usr/bin | ||
|
||
RUN mkdir -p /etc/kuma | ||
ADD $KUMA_ROOT/pkg/config/app/kuma-cp/kuma-cp.defaults.yaml /etc/kuma | ||
|
||
RUN mkdir /kuma | ||
COPY $KUMA_ROOT/tools/releases/templates/LICENSE /kuma | ||
COPY $KUMA_ROOT/tools/releases/templates/README /kuma | ||
|
||
ENTRYPOINT ["kuma-cp"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# using Envoy's base to inherit the Envoy binary | ||
FROM envoyproxy/envoy-alpine:latest | ||
|
||
ADD $KUMA_ROOT/build/artifacts-linux-amd64/kuma-dp/kuma-dp /usr/bin | ||
|
||
RUN mkdir /kuma | ||
COPY $KUMA_ROOT/tools/releases/templates/LICENSE /kuma | ||
COPY $KUMA_ROOT/tools/releases/templates/README /kuma | ||
|
||
ENTRYPOINT ["kuma-dp"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine:3.10 | ||
|
||
ADD $KUMA_ROOT/build/artifacts-linux-amd64/kuma-injector/kuma-injector /usr/bin | ||
|
||
RUN mkdir /kuma | ||
COPY $KUMA_ROOT/tools/releases/templates/LICENSE /kuma | ||
COPY $KUMA_ROOT/tools/releases/templates/README /kuma | ||
|
||
ENTRYPOINT ["kuma-injector"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine:3.10 | ||
|
||
ADD $KUMA_ROOT/build/artifacts-linux-amd64/kuma-tcp-echo/kuma-tcp-echo /usr/bin | ||
|
||
RUN mkdir /kuma | ||
COPY $KUMA_ROOT/tools/releases/templates/LICENSE /kuma | ||
COPY $KUMA_ROOT/tools/releases/templates/README /kuma | ||
|
||
ENTRYPOINT ["kuma-tcp-echo"] |