Make docker installation equivalent to regular install
Summary: This puts the whole installation and packaging under a single point of entry. (Docker, DEB, RPM, etc.) Rename alpha.dockerfile to beta.dockerfile Use Debian Stretch for docker Remove building old hardcoded compiler Rename build_interpreter to build_memgraph Remove unused config-file Reviewers: mferencevic, buda Reviewed By: mferencevic, buda Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D857
This commit is contained in:
parent
f6a8d0e910
commit
4c25123d83
.gitignoreCMakeLists.txt
docs/user_technical
experimental/distributed/tests
poc
release
.gitignorealpha.dockerfilebuild_compilerbuild_interpretercommunity.dockerfilepackage_deploypackage_docker
src
tests
tools/apollo
9
.gitignore
vendored
9
.gitignore
vendored
@ -20,15 +20,6 @@ build/
|
||||
cmake-build-*
|
||||
cmake/DownloadProject/
|
||||
dist/
|
||||
memgraph
|
||||
release/barrier/
|
||||
release/barrier_*
|
||||
release/config/
|
||||
release/libs/
|
||||
release/memgraph_*
|
||||
release/websockify/
|
||||
release/neo4j-browser/
|
||||
release/bundle-report.html
|
||||
src/query/frontend/opencypher/generated/
|
||||
tags
|
||||
ve/
|
||||
|
@ -30,12 +30,7 @@ set(CMAKE_C_COMPILER "clang")
|
||||
set(CMAKE_CXX_COMPILER "clang++")
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# set project name
|
||||
# get directory name
|
||||
get_filename_component(project_name ${CMAKE_SOURCE_DIR} NAME)
|
||||
# replace whitespaces with underscores
|
||||
string(REPLACE " " "_" project_name ${project_name})
|
||||
project(${project_name} VERSION 0.7.0)
|
||||
project(memgraph VERSION 0.7.0)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# setup CMake module path, defines path for include() and find_package()
|
||||
@ -85,7 +80,7 @@ set(tests_dir ${CMAKE_SOURCE_DIR}/tests)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# Generate a version.hpp file
|
||||
set(VERSION_STRING ${${project_name}_VERSION})
|
||||
set(VERSION_STRING ${memgraph_VERSION})
|
||||
configure_file(${src_dir}/version.hpp.in include/version.hpp @ONLY)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||
|
||||
@ -293,23 +288,12 @@ add_subdirectory(tests)
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# memgraph build name
|
||||
execute_process(
|
||||
OUTPUT_VARIABLE COMMIT_BRANCH
|
||||
COMMAND git rev-parse --abbrev-ref HEAD
|
||||
)
|
||||
execute_process(
|
||||
OUTPUT_VARIABLE COMMIT_HASH
|
||||
COMMAND git rev-parse --short HEAD
|
||||
)
|
||||
execute_process(
|
||||
OUTPUT_VARIABLE COMMIT_NO
|
||||
COMMAND git rev-list --count HEAD
|
||||
)
|
||||
string(STRIP ${COMMIT_BRANCH} COMMIT_BRANCH)
|
||||
string(STRIP ${COMMIT_NO} COMMIT_NO)
|
||||
string(STRIP ${COMMIT_HASH} COMMIT_HASH)
|
||||
set(MEMGRAPH_BUILD_NAME
|
||||
"memgraph_${COMMIT_NO}_${COMMIT_HASH}_${COMMIT_BRANCH}_${CMAKE_BUILD_TYPE}")
|
||||
set(MEMGRAPH_BUILD_NAME "memgraph-${memgraph_VERSION}-${COMMIT_HASH}_${CMAKE_BUILD_TYPE}")
|
||||
add_custom_target(memgraph_link_target ALL
|
||||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/${MEMGRAPH_BUILD_NAME} ${CMAKE_BINARY_DIR}/memgraph DEPENDS ${MEMGRAPH_BUILD_NAME})
|
||||
# -----------------------------------------------------------------------------
|
||||
@ -355,10 +339,11 @@ set(CPACK_PACKAGE_NAME memgraph)
|
||||
set(CPACK_PACKAGE_VENDOR "Memgraph Ltd.")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
||||
"High performance, in-memory, transactional graph database")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${${project_name}_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${${project_name}_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${${project_name}_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VERSION_TWEAK ${${project_name}_VERSION_TWEAK})
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${memgraph_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${memgraph_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${memgraph_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VERSION_TWEAK ${memgraph_VERSION_TWEAK})
|
||||
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${memgraph_VERSION}-${COMMIT_HASH}${CPACK_SYSTEM_NAME})
|
||||
# TODO: Longer description, readme and license files.
|
||||
# DEB specific
|
||||
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Memgraph Ltd.")
|
||||
|
@ -1,10 +1,10 @@
|
||||
## Installation
|
||||
|
||||
Memgraph is a 64-bit Linux compatible database management system. For the
|
||||
purpose of Alpha testing Memgraph has been packed into a
|
||||
[Docker](https://www.docker.com) image based on Ubuntu 16.04. Before
|
||||
proceeding with the installation, please install the Docker engine on your
|
||||
system. Instructions how to install Docker can be found on the
|
||||
Memgraph is a 64-bit Linux compatible database management system. Currently,
|
||||
the Memgraph binary is offered only as a [Docker](https://www.docker.com)
|
||||
image based on Debian Stretch. Before proceeding with the installation, please
|
||||
install the Docker engine on the system. Instructions how to install Docker
|
||||
can be found on the
|
||||
[official Docker website](https://docs.docker.com/engine/installation).
|
||||
Memgraph Docker image was built with Docker version `1.12` and should be
|
||||
compatible with all latter versions.
|
||||
@ -15,7 +15,7 @@ After a successful download the Memgraph Docker image
|
||||
can be imported into Docker:
|
||||
|
||||
```
|
||||
docker load -i /path/to/memgraph_alpha_v0.7.0.tar.gz
|
||||
docker load -i /path/to/memgraph-<version>-docker.tar.gz
|
||||
```
|
||||
|
||||
### Image Configuration & Running Memgraph
|
||||
@ -23,38 +23,65 @@ docker load -i /path/to/memgraph_alpha_v0.7.0.tar.gz
|
||||
Memgraph can be started by executing:
|
||||
|
||||
```
|
||||
docker run -it -p 7687:7687 memgraph_alpha_v0.7.0
|
||||
docker run -it -p 7687:7687 memgraph:<version>
|
||||
```
|
||||
|
||||
The `-it` option enables displaying Memgraph's logs inside the current shell.
|
||||
The `-p` option is used to specify the port on which Memgraph will listen for
|
||||
requests. Memgraph uses the Bolt protocol for network communication, which
|
||||
uses port `7687` by default.
|
||||
uses port `7687` by default. The `<version>` part are 3 numbers specifying the
|
||||
version, e.g. `1.2.3`.
|
||||
|
||||
It is recommended to perform some additional Docker configuration. Memgraph is
|
||||
currently an in-memory database management system, but it periodically stores
|
||||
all data to the hard drive. These storages are referred to as *snapshots* and
|
||||
are used for recovering data in case of a restart. When starting Memgraph, a
|
||||
folder for snapshots needs to be created and mounted on the host file system.
|
||||
It is also recommended to run the Docker container in the background. On a
|
||||
Linux system all of that can be achieved with the following shell commands:
|
||||
are used for recovering data in case of a restart.
|
||||
|
||||
When starting Memgraph, a folder for snapshots needs to be created and mounted on the host file system.
|
||||
This can be easily done using Docker's named volumes. For example:
|
||||
|
||||
```
|
||||
# Run Memgraph.
|
||||
docker run -p 7687:7687 -v mg_data:/var/lib/memgraph memgraph:<version>
|
||||
```
|
||||
|
||||
The `-v` option will make a named volume directory called `mg_data` and
|
||||
Memgraph will store snapshots there. Named volumes are usually found in
|
||||
`/var/lib/docker/volumes`.
|
||||
|
||||
The same can be achieved for logs and configuration. All supported volumes
|
||||
which can be mounted are:
|
||||
|
||||
* `/var/lib/memgraph`, for storing snapshots;
|
||||
* `/var/log/memgraph`, for storing logs and
|
||||
* `/etc/memgraph`, for Memgraph configuration.
|
||||
|
||||
Another way to expose the configuration and data is to use a full path to some
|
||||
directory on the system. In such a case, the directory first needs to be
|
||||
created and allow docker image to write inside. For example, to create a
|
||||
snapshots volume in the current directory:
|
||||
|
||||
```
|
||||
# Create the snapshots folder on the host.
|
||||
mkdir -p memgraph
|
||||
mkdir -m 777 mg_data
|
||||
# Docker expects full path to the created folder.
|
||||
FULL_OUTPUT_PATH=$PWD/memgraph
|
||||
FULL_OUTPUT_PATH=$PWD/mg_data
|
||||
# Run Memgraph.
|
||||
docker run -d -p 7687:7687 -v ${FULL_OUTPUT_PATH}:/var/lib/memgraph --name <memgraph_docker_container_name> memgraph_alpha_v0.7.0
|
||||
docker run -p 7687:7687 -v ${FULL_OUTPUT_PATH}:/var/lib/memgraph memgraph:<version>
|
||||
```
|
||||
|
||||
In the commands above `-d` means that the container will be detached (run in
|
||||
the background). `-v` mounts a host folder to a path inside the Docker
|
||||
container. The output folder contains Memgraph's periodical snapshots and log
|
||||
file. The log file should be uploaded to Memgraph's issue tracking system in
|
||||
case of an error. With `--name` a custom name for the container can be set
|
||||
(useful for easier container management). `<memgraph_docker_container_name>`
|
||||
could be any convenient name e.g. `memgraph_alpha`.
|
||||
In this example, `-v` mounts a host folder `$PWD/mg_data` to a path inside the Docker
|
||||
container.
|
||||
|
||||
Other than setting the configuration, it is also recommended to run the Docker
|
||||
container in the background. This is achieved with `-d` option. In such a
|
||||
case, the name should be set for the running container, so that it can be
|
||||
easily found and shut down when needed. For example:
|
||||
|
||||
```
|
||||
# Run Memgraph.
|
||||
docker run -p 7687:7687 -d --name <memgraph_docker_container_name> memgraph:<version>
|
||||
```
|
||||
|
||||
### Memgraph Configuration Parameters
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(${project_name}_tests)
|
||||
project(memgraph_tests)
|
||||
|
||||
enable_testing()
|
||||
|
||||
@ -19,8 +19,7 @@ foreach(test_cpp ${test_type_cpps})
|
||||
# get exec name (remove extension from the abs path)
|
||||
get_filename_component(exec_name ${test_cpp} NAME_WE)
|
||||
|
||||
# set target name in format {project_name}__{test_type}__{exec_name}
|
||||
set(target_name ${project_name}__${test_type}__${exec_name})
|
||||
set(target_name memgraph__${test_type}__${exec_name})
|
||||
|
||||
# build exec file
|
||||
add_executable(${target_name} ${test_cpp})
|
||||
|
@ -14,8 +14,7 @@ foreach(poc_cpp ${poc_cpps})
|
||||
# get exec name (remove extension from the abs path)
|
||||
get_filename_component(exec_name ${poc_cpp} NAME_WE)
|
||||
|
||||
# set target name in format {project_name}_{test_type}_{exec_name}
|
||||
set(target_name ${project_name}_poc_${exec_name})
|
||||
set(target_name memgraph_poc_${exec_name})
|
||||
|
||||
# build exe file
|
||||
add_executable(${target_name} ${poc_cpp})
|
||||
|
1
release/.gitignore
vendored
Normal file
1
release/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
memgraph-*.tar.gz
|
@ -1,16 +0,0 @@
|
||||
FROM ubuntu:16.04
|
||||
# FROM ubuntu 16.04 # 130MB
|
||||
# FROM phusion/baseimage # 220MB
|
||||
# FROM debian:jessie-slim # doesn't work because CXXABI_1.3.9 & GLIBCXX_3.4.21 not found
|
||||
# FROM debian:jessie # doesn't work because CXXABI_1.3.9 & GLIBCXX_3.4.21 not found
|
||||
|
||||
ENV MEMGRAPH_CONFIG /memgraph/config/memgraph.conf
|
||||
ARG build_name
|
||||
RUN mkdir -p /var/lib/memgraph
|
||||
|
||||
COPY ${build_name} /memgraph
|
||||
|
||||
WORKDIR /memgraph
|
||||
|
||||
ENTRYPOINT ["./memgraph"]
|
||||
CMD [""]
|
@ -1,38 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Initial version of script that is going to be used for release builds.
|
||||
|
||||
echo "Memgraph Release Building..."
|
||||
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
echo "This script must NOT be run as root!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# compile memgraph
|
||||
cd ../build
|
||||
rm -rf ./*
|
||||
cmake -DCMAKE_BUILD_TYPE:String=debug ..
|
||||
make -j8
|
||||
make copy_hardcoded_queries
|
||||
|
||||
# get the most recent version of memgraph exe
|
||||
exe_name=`ls -t memgraph_* | head -1`
|
||||
|
||||
# create dst directory
|
||||
mkdir -p ../release/${exe_name}
|
||||
|
||||
# copy all relevant files
|
||||
cp ${exe_name} ../release/${exe_name}/memgraph
|
||||
cp libmemgraph_pic.a ../release/${exe_name}/libmemgraph_pic.a
|
||||
rm -rf ../release/${exe_name}/include
|
||||
cp -r include ../release/${exe_name}/include
|
||||
cp -r template ../release/${exe_name}/template
|
||||
cp -r ../config ../release/${exe_name}/config
|
||||
cp -r ../libs ../release/${exe_name}/libs
|
||||
|
||||
# copy the hardcoded query plan
|
||||
# TODO: minimise the header files
|
||||
cp -r compiled ../release/${exe_name}/
|
||||
|
||||
echo "Memgraph Release Building DONE"
|
@ -1,96 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Initial version of script that is going to be used for release builds.
|
||||
# Build & package (collect all required files in a folder).
|
||||
|
||||
function print_help () {
|
||||
echo "Usage: $0 [OPTION] --version MAJOR.MINOR.PATCH"
|
||||
echo "Optional arguments:"
|
||||
echo -e " -h|--help Print help."
|
||||
echo -e " --skip-compile Skip compilation process."
|
||||
echo -e " --build-type CMAKE_BUILD_TYPE options are: Debug|Release|RelWithDebInfo|MinSizeRel|Coverage|None (default is Debug)."
|
||||
echo -e " --config-file Memgraph config file name (default is testing.conf)"
|
||||
}
|
||||
|
||||
if [[ $EUID -eq 0 ]]; then
|
||||
echo "This script must NOT be run as root!" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
release_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
project_dir="${release_dir}/.."
|
||||
|
||||
skip_compile=false
|
||||
build_type="Debug"
|
||||
config_file="alpha.conf"
|
||||
version=""
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
print_help
|
||||
exit 1
|
||||
;;
|
||||
--skip-compile)
|
||||
skip_compile=true
|
||||
;;
|
||||
--build-type)
|
||||
build_type=$2
|
||||
shift
|
||||
;;
|
||||
--config-file)
|
||||
config_file=$2
|
||||
shift
|
||||
;;
|
||||
--version)
|
||||
version=$2
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
# unknown option
|
||||
;;
|
||||
esac
|
||||
shift # past argument or value
|
||||
done
|
||||
|
||||
if [[ ! ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo -e "Something is wrong with your version number. Semantic version number is required (MAJOR.MINOR.PATCH).\n"
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# TODO: Somehow check the correct value. One solution would be to create
|
||||
# a file with the current version number value. It's not required for now.
|
||||
|
||||
echo "Memgraph Release Building (${version})"
|
||||
|
||||
echo "Skip compile: ${skip_compile}"
|
||||
|
||||
if [[ "${skip_compile}" == false ]]; then
|
||||
# init (download libraries)
|
||||
cd ${project_dir}
|
||||
./init
|
||||
|
||||
# compile memgraph
|
||||
cd ${project_dir}/build
|
||||
rm -rf ./*
|
||||
cmake -DCMAKE_BUILD_TYPE:String=${build_type} ..
|
||||
make -j8
|
||||
fi
|
||||
|
||||
# get the most recent version of memgraph exe
|
||||
cd ${project_dir}/build
|
||||
exe_name=`ls -t memgraph_* | head -1`
|
||||
release_folder=${release_dir}/${exe_name}
|
||||
|
||||
# extract only required files
|
||||
# create dst directory
|
||||
cd ${release_dir}
|
||||
mkdir -p ${release_folder}/config
|
||||
echo "Full build name: ${exe_name}" > ${release_folder}/build.info
|
||||
echo "${version}" > ${release_folder}/VERSION
|
||||
# copy binary & config
|
||||
cp ${project_dir}/build/${exe_name} ${release_folder}/memgraph
|
||||
cp ${project_dir}/config/${config_file} ${release_folder}/config/memgraph.conf
|
||||
|
||||
echo "Memgraph Build ${exe_name} DONE"
|
28
release/community.dockerfile
Normal file
28
release/community.dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
FROM debian:stretch
|
||||
# FROM debian:stretch # 104MB
|
||||
# FROM ubuntu 16.04 # 130MB
|
||||
# FROM phusion/baseimage # 220MB
|
||||
|
||||
ARG build_name
|
||||
|
||||
COPY ${build_name} /
|
||||
|
||||
# Setup memgraph user and group
|
||||
RUN groupadd -r memgraph
|
||||
RUN useradd -lrm -g memgraph memgraph
|
||||
RUN chown -R memgraph:memgraph /var/log/memgraph
|
||||
RUN chown -R memgraph:memgraph /var/lib/memgraph
|
||||
|
||||
# Memgraph listens for Bolt Protocol on this port by default.
|
||||
EXPOSE 7687
|
||||
# Snapshots and logging volumes
|
||||
VOLUME /var/log/memgraph
|
||||
VOLUME /var/lib/memgraph
|
||||
# Configuration volume
|
||||
VOLUME /etc/memgraph
|
||||
|
||||
USER memgraph
|
||||
WORKDIR /home/memgraph
|
||||
|
||||
ENTRYPOINT ["memgraph"]
|
||||
CMD [""]
|
@ -1,126 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Build, Package (docker image) & Deploy Memgraph
|
||||
|
||||
function print_help () {
|
||||
echo "Usage: $0 [OPTION] --version MAJOR.MINOR.PATCH"
|
||||
echo "Optional arguments:"
|
||||
echo -e " -h|--help Print help."
|
||||
echo -e " --skip-compile Skip compilation process."
|
||||
echo -e " --skip-deploy Skip deployment process."
|
||||
echo -e " --docker-image-name Custom docker image name, otherwise the image name will be the same as the package name."
|
||||
echo -e " -s|--server Deployment server address. -|"
|
||||
echo -e " -u|--user Deployment server user. -| -> Required if deployment isn't skipped."
|
||||
echo -e " -k|--key Deployment server SSH key. -|"
|
||||
}
|
||||
|
||||
working_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
project_dir="${working_dir}/.."
|
||||
|
||||
# argument parsing
|
||||
required_args_no=0
|
||||
skip_compile=false
|
||||
skip_deploy=false
|
||||
version=0
|
||||
docker_image_name=""
|
||||
while [[ $# -gt 0 ]]
|
||||
do
|
||||
case $1 in
|
||||
-h|--help)
|
||||
print_help
|
||||
exit -1
|
||||
;;
|
||||
-s|--server)
|
||||
deploy_server="$2"
|
||||
required_args_no=$((required_args_no+1))
|
||||
shift # past argument
|
||||
;;
|
||||
-u|--user)
|
||||
deploy_user="$2"
|
||||
required_args_no=$((required_args_no+1))
|
||||
shift # past argument
|
||||
;;
|
||||
-k|--key)
|
||||
deploy_key="$2"
|
||||
required_args_no=$((required_args_no+1))
|
||||
shift # past argument
|
||||
;;
|
||||
--skip-compile)
|
||||
skip_compile=true
|
||||
;;
|
||||
--skip-deploy)
|
||||
skip_deploy=true
|
||||
;;
|
||||
--docker-image-name)
|
||||
docker_image_name="$2"
|
||||
shift
|
||||
;;
|
||||
--version)
|
||||
version=$2
|
||||
required_args_no=$((required_args_no+1))
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
# unknown option
|
||||
;;
|
||||
esac
|
||||
shift # past argument or value
|
||||
done
|
||||
|
||||
# arguments validation
|
||||
# version validation (semantic versioning)
|
||||
if [[ ! ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo -e "Something is wrong with your version number. Semantic version number is required (MAJOR.MINOR.PATCH).\n"
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
# validate --skip-deploy, --version, --server, --user, --key
|
||||
if [[ "${skip_deploy}" == false ]]; then
|
||||
if [[ ${required_args_no} -ne 4 ]]; then
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
else # if deploy is skipped server, user and key are not required
|
||||
if [[ ${required_args_no} -ne 1 ]]; then
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Skip compile: ${skip_compile}"
|
||||
echo "Skip deploy: ${skip_deploy}"
|
||||
if [[ "${skip_deploy}" == false ]]; then
|
||||
echo "Deploy server: ${deploy_server}"
|
||||
echo "Deploy user: ${deploy_user}"
|
||||
echo "Deploy key: ${deploy_key}"
|
||||
fi
|
||||
|
||||
## build binary
|
||||
if [[ "${skip_compile}" == true ]]; then
|
||||
${working_dir}/build_interpreter --skip-compile --version ${version}
|
||||
else
|
||||
${working_dir}/build_interpreter --build-type Release --version ${version}
|
||||
fi
|
||||
|
||||
## build package (docker image)
|
||||
cd ${working_dir}
|
||||
package_name=`ls -t -d memgraph_*/ | head -1 | sed 's/.$//'`
|
||||
# for some reason docker image has to be lowercase string
|
||||
# and because our package name is based on the cmake build type
|
||||
# string (which can be camel case) the package name has to be transformed
|
||||
if [[ "${docker_image_name}" == "" ]] ; then
|
||||
docker_image_name=$(echo "${package_name}"| tr '[:upper:]' '[:lower:]')
|
||||
fi
|
||||
docker build -t ${docker_image_name} -f ${working_dir}/alpha.dockerfile --build-arg build_name=${package_name} .
|
||||
docker save ${docker_image_name} > ${docker_image_name}.tar.gz
|
||||
|
||||
if [[ "${skip_deploy}" == false ]]; then
|
||||
## deploy
|
||||
# copy package
|
||||
scp -i ${deploy_key} ${docker_image_name}.tar.gz ${deploy_user}@${deploy_server}:/home/${deploy_user}
|
||||
# load package
|
||||
ssh -i ${deploy_key} ${deploy_user}@${deploy_server} docker load -i /home/${deploy_user}/${docker_image_name}.tar.gz
|
||||
# spin up the instance
|
||||
public_port=$(echo ${package_name} | grep -o "memgraph_[0-9]*_" | sed 's/[^0-9]*//g')
|
||||
ssh -i ${deploy_key} ${deploy_user}@${deploy_server} docker run -d --name ${docker_image_name} -p ${public_port}:7687 ${docker_image_name}
|
||||
fi
|
40
release/package_docker
Executable file
40
release/package_docker
Executable file
@ -0,0 +1,40 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
# Build and Package (docker image) Memgraph
|
||||
|
||||
function print_help () {
|
||||
echo "Usage: $0 BINARY_PACKAGE.tar.gz"
|
||||
echo "Optional arguments:"
|
||||
echo -e " -h|--help Print help."
|
||||
}
|
||||
|
||||
working_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
project_dir="${working_dir}/.."
|
||||
|
||||
if [[ $# -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} -f ${working_dir}/community.dockerfile --build-arg build_name=${package_name} .
|
||||
docker save ${image_name} > ${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'"
|
@ -1,84 +0,0 @@
|
||||
//
|
||||
// Created by buda on 27/02/17.
|
||||
//
|
||||
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
#include <glog/logging.h>
|
||||
#include "gflags/gflags.h"
|
||||
|
||||
#include "query/frontend/stripped.hpp"
|
||||
#include "utils/exceptions.hpp"
|
||||
#include "utils/file.hpp"
|
||||
#include "utils/string.hpp"
|
||||
|
||||
/**
|
||||
* Reads a query from the file specified by the path argument.
|
||||
* The first line of a query should start with "// Query: ". Query can be
|
||||
* in more than one line but every line has to start with "//".
|
||||
*
|
||||
* @param path to the query file.
|
||||
* @return query as a string.
|
||||
*/
|
||||
|
||||
DEFINE_string(src, "tests/integration/hardcoded_queries",
|
||||
"Path to sources of hardcoded queries.");
|
||||
DEFINE_string(dst, "build/compiled/hardcode",
|
||||
"Destination path of hardcoded queries");
|
||||
|
||||
std::string ExtractQuery(const fs::path &path) {
|
||||
auto comment_mark = std::string("// ");
|
||||
auto query_mark = comment_mark + std::string("Query: ");
|
||||
auto lines = utils::ReadLines(path);
|
||||
// find the line with a query (the query can be split across multiple
|
||||
// lines)
|
||||
for (int i = 0; i < static_cast<int>(lines.size()); ++i) {
|
||||
// find query in the line
|
||||
auto &line = lines[i];
|
||||
auto pos = line.find(query_mark);
|
||||
// if query doesn't exist pass
|
||||
if (pos == std::string::npos) continue;
|
||||
auto query = utils::Trim(line.substr(pos + query_mark.size()));
|
||||
while (i + 1 < static_cast<int>(lines.size()) &&
|
||||
lines[i + 1].find(comment_mark) != std::string::npos) {
|
||||
query += lines[i + 1].substr(lines[i + 1].find(comment_mark) +
|
||||
comment_mark.length());
|
||||
++i;
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
throw utils::BasicException("Unable to find query!");
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, false);
|
||||
google::InitGoogleLogging(argv[0]);
|
||||
|
||||
auto src_path = FLAGS_src;
|
||||
LOG(INFO) << "Src path is: " << src_path;
|
||||
permanent_assert(fs::exists(src_path), "src folder must exist");
|
||||
|
||||
auto dst_path = FLAGS_dst;
|
||||
LOG(INFO) << "Dst path is: " << dst_path;
|
||||
fs::create_directories(dst_path);
|
||||
|
||||
auto src_files = utils::LoadFilePaths(src_path, "cpp");
|
||||
|
||||
for (auto &src_file : src_files) {
|
||||
auto query = ExtractQuery(src_file);
|
||||
auto query_hash = query::StrippedQuery(query).hash();
|
||||
auto dst_file = dst_path / fs::path(std::to_string(query_hash) + ".cpp");
|
||||
fs::copy(src_file, dst_file, fs::copy_options::overwrite_existing);
|
||||
LOG(INFO) << src_file << "- {(copy) -> " << dst_file;
|
||||
}
|
||||
|
||||
auto hpp_files = utils::LoadFilePaths(src_path, "hpp");
|
||||
for (auto &hpp_file : hpp_files) {
|
||||
fs::copy(hpp_file, dst_path / hpp_file.filename(),
|
||||
fs::copy_options::overwrite_existing);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(${project_name}_tests)
|
||||
project(memgraph_tests)
|
||||
|
||||
enable_testing()
|
||||
|
||||
|
@ -14,8 +14,8 @@ foreach(test_cpp ${test_type_cpps})
|
||||
# get exec name (remove extension from the abs path)
|
||||
get_filename_component(exec_name ${test_cpp} NAME_WE)
|
||||
|
||||
# set target name in format {project_name}__{test_type}__{exec_name}
|
||||
set(target_name ${project_name}__${test_type}__${exec_name})
|
||||
# set target name in format {PROJECT_NAME}__{test_type}__{exec_name}
|
||||
set(target_name ${PROJECT_NAME}__${test_type}__${exec_name})
|
||||
|
||||
# build exec file
|
||||
add_executable(${target_name} ${test_cpp})
|
||||
|
@ -13,8 +13,7 @@ foreach(test_cpp ${test_type_cpps})
|
||||
# get exec name (remove extension from the abs path)
|
||||
get_filename_component(exec_name ${test_cpp} NAME_WE)
|
||||
|
||||
# set target name in format {project_name}__{test_type}__{exec_name}
|
||||
set(target_name ${project_name}__${test_type}__${exec_name})
|
||||
set(target_name memgraph__${test_type}__${exec_name})
|
||||
|
||||
# build exec file
|
||||
add_executable(${target_name} ${test_cpp})
|
||||
|
@ -11,7 +11,7 @@ message(STATUS "Available ${test_type} cpp files are: ${test_type_cpps}")
|
||||
set(postgres_dir ${libs_dir}/postgresql)
|
||||
|
||||
# add target that depends on all other targets
|
||||
set(all_targets_target ${project_name}__${test_type})
|
||||
set(all_targets_target memgraph__${test_type})
|
||||
add_custom_target(${all_targets_target})
|
||||
|
||||
# for each cpp file build binary and register test
|
||||
@ -20,8 +20,7 @@ foreach(test_cpp ${test_type_cpps})
|
||||
# get exec name (remove extension from the abs path)
|
||||
get_filename_component(exec_name ${test_cpp} NAME_WE)
|
||||
|
||||
# set target name in format {project_name}__{test_type}__{exec_name}
|
||||
set(target_name ${project_name}__${test_type}__${exec_name})
|
||||
set(target_name memgraph__${test_type}__${exec_name})
|
||||
|
||||
# build exec file
|
||||
add_executable(${target_name} ${test_cpp})
|
||||
|
@ -11,8 +11,7 @@ foreach(test_cpp ${test_type_cpps})
|
||||
# get exec name (remove extension from the abs path)
|
||||
get_filename_component(exec_name ${test_cpp} NAME_WE)
|
||||
|
||||
# set target name in format {project_name}__{test_type}__{exec_name}
|
||||
set(target_name ${project_name}__${test_type}__${exec_name})
|
||||
set(target_name memgraph__${test_type}__${exec_name})
|
||||
|
||||
# build exec file
|
||||
add_executable(${target_name} ${test_cpp})
|
||||
|
@ -11,8 +11,7 @@ foreach(test_cpp ${test_type_cpps})
|
||||
# get exec name (remove extension from the abs path)
|
||||
get_filename_component(exec_name ${test_cpp} NAME_WE)
|
||||
|
||||
# set target name in format {project_name}__{test_type}__{exec_name}
|
||||
set(target_name ${project_name}__${test_type}__${exec_name})
|
||||
set(target_name memgraph__${test_type}__${exec_name})
|
||||
|
||||
# build exec file
|
||||
add_executable(${target_name} ${test_cpp})
|
||||
|
1
tests/qa/.gitignore
vendored
1
tests/qa/.gitignore
vendored
@ -5,3 +5,4 @@
|
||||
*.pyc
|
||||
ve3/
|
||||
.quality_assurance_status
|
||||
latency/memgraph
|
||||
|
@ -8,7 +8,7 @@ file(GLOB_RECURSE test_type_cpps *.cpp)
|
||||
message(STATUS "Available ${test_type} cpp files are: ${test_type_cpps}")
|
||||
|
||||
# add target that depends on all other targets
|
||||
set(all_targets_target ${project_name}__${test_type})
|
||||
set(all_targets_target memgraph__${test_type})
|
||||
add_custom_target(${all_targets_target})
|
||||
|
||||
# for each cpp file build binary and register test
|
||||
@ -17,8 +17,7 @@ foreach(test_cpp ${test_type_cpps})
|
||||
# get exec name (remove extension from the abs path)
|
||||
get_filename_component(exec_name ${test_cpp} NAME_WE)
|
||||
|
||||
# set target name in format {project_name}__{test_type}__{exec_name}
|
||||
set(target_name ${project_name}__${test_type}__${exec_name})
|
||||
set(target_name memgraph__${test_type}__${exec_name})
|
||||
|
||||
# build exec file
|
||||
add_executable(${target_name} ${test_cpp})
|
||||
|
@ -11,8 +11,7 @@ foreach(test_cpp ${test_type_cpps})
|
||||
# get exec name (remove extension from the abs path)
|
||||
get_filename_component(exec_name ${test_cpp} NAME_WE)
|
||||
|
||||
# set target name in format {project_name}__{test_type}__{exec_name}
|
||||
set(target_name ${project_name}__${test_type}__${exec_name})
|
||||
set(target_name memgraph__${test_type}__${exec_name})
|
||||
|
||||
# build exec file
|
||||
add_executable(${target_name} ${test_cpp})
|
||||
|
@ -30,7 +30,7 @@ TIMEOUT=600 ./init
|
||||
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=release ..
|
||||
TIMEOUT=1000 make -j$THREADS memgraph_link_target parent__macro_benchmark
|
||||
TIMEOUT=1000 make -j$THREADS memgraph_link_target memgraph__macro_benchmark
|
||||
|
||||
cd ../../memgraph/tools/apollo
|
||||
|
||||
|
@ -11,6 +11,8 @@ bash -c "doxygen Doxyfile >/dev/null 2>/dev/null"
|
||||
cd build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_READLINE=OFF ..
|
||||
TIMEOUT=1000 make -j$THREADS
|
||||
# Create a binary package (which can then be used for Docker image).
|
||||
cpack -D CPACK_SET_DESTDIR=ON -G TGZ
|
||||
|
||||
cd ../tools
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user