memgraph/release/package_docker
Teon Banek f85de1e8e1 Add tagging docker image as latest
Summary: Update technical documentation, installation

Reviewers: florijan, buda, mferencevic

Reviewed By: mferencevic

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D893
2017-10-11 13:05:18 +02:00

48 lines
1.4 KiB
Bash
Executable File

#!/bin/bash -e
# Build and Package (docker image) Memgraph
function print_help () {
echo "Usage: $0 [--latest] BINARY_PACKAGE.tar.gz"
echo "Optional arguments:"
echo -e " -h|--help Print help."
echo -e " --latest Tag image as latest version."
}
working_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
project_dir="${working_dir}/.."
latest_image=""
tag_latest=""
if [[ $# -eq 2 && "$1" == "--latest" ]]; then
latest_image="memgraph:latest"
tag_latest="-t memgraph:latest"
shift
elif [[ $# -ne 1 || "$1" == "-h" || "$1" == "--help" ]]; then
print_help
exit 1
fi
if [[ ! -f "$1" ]]; then
echo "File '$1' does not exist!"
exit 1
fi
tar_release=`realpath "$1"`
package_name=`echo $(basename $1) | sed 's/.tar.gz//'`
cd ${working_dir}
# Unpack the release package.
echo "Unpacking '$1' to '${working_dir}/${package_name}'"
tar xf ${tar_release}
version=`echo ${package_name} | sed 's/.*-\(.*\)-.*/\1/'`
image_name="memgraph:${version}"
# Build docker image.
docker build -t ${image_name} ${tag_latest} -f ${working_dir}/community.dockerfile --build-arg build_name=${package_name} .
docker save ${image_name} ${latest_image} > ${package_name}-docker.tar.gz
# Remove unpacked package.
echo "Removing '${working_dir}/${package_name}'"
rm -rf ${package_name}
echo "Built Docker imate at '${working_dir}/${package_name}-docker.tar.gz'"