-
Notifications
You must be signed in to change notification settings - Fork 339
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: docker automation #265
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 $@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM alpine:3.10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docker image should run under a non- |
||
|
||
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"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# using Envoy's base to inherit the Envoy binary | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docker image should run under a non- |
||
FROM envoyproxy/envoy-alpine:latest | ||
gszr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine:3.10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docker image should run under a non- |
||
|
||
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"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine:3.10 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docker image should run under a non- |
||
|
||
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"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change the message to
Pushing $component ...
?