Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Build and publish ClickHouse docker images
#!/usr/bin/env bash
# Each step could be separate build configuration (in terms of TeamCity) with proper dependencies between them
# STEP 0
# Init variables
version="1.1.54343"
server_tag="yandex/clickhouse-server:$version"
client_tag="yandex/clickhouse-client:$version"
# STEP 1
# Build image
# TODO: Uncomment and fix if needed
#pushd docker/server
#docker build --pull --build-arg version=$version --tag "$server_tag"
#popd
#pushd docker/client
#docker build --pull --build-arg version=$version --tag "$client_tag"
#popd
# Perform some tests
die() {
echo "$@" 1>&2
exit 1
}
# STEP 2
# E.g. check version
if docker ps -a --filter 'name=test' --format '{{.Names}}' | grep -q 'test'; then
docker stop test && docker rm test || die "Failed to cleanup"
fi
docker run -d --name test "$server_tag" || die "Cannot start server"
version_full=$(docker run --rm --link test:test $client_tag --host test \
--query "select value from system.build_options where name == 'VERSION_FULL'")
[[ $? -ne 0 ]] && die "Failed to run client"
docker stop test && docker rm test || die "Failed to cleanup"
echo "$version_full" | grep -q "$version" || die "Version mismatch: expected: $version, got: $version_full"
# STEP 3
# Tag image
tag_all() {
base="$1"
from="$1:$2"
shift; shift;
while [ $# -gt 0 ]
do
target="$base:$1"
docker images --filter reference="$target" | grep -q "$base" && docker rmi "$target"
docker tag "$from" "$target" && echo "Tagged: $target -> $from"
shift
done
}
tag_all 'yandex/clickhouse-server' "$version" '1' '1.1' 'latest'
tag_all 'yandex/clickhouse-client' "$version" '1' '1.1' 'latest'
# STEP 4
# Deploy
# TODO: Insert command to login into hub.docker.com
# docker login -u username -p password
push_all() {
base="$1"
shift;
while [ $# -gt 0 ]
do
tag="$base:$1"
docker push "$tag" && echo "Pushed $tag"
shift
done
}
push_all 'yandex/clickhouse-server' "$version" '1' '1.1' 'latest'
push_all 'yandex/clickhouse-client' "$version" '1' '1.1' 'latest'
docker logout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment