Fix docker packaging and add for platform build (#257)

This commit is contained in:
antonio2368 2021-10-06 01:20:37 -07:00 committed by GitHub
parent 9551b6973a
commit 0ffb58b764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 22 deletions

View File

@ -19,7 +19,7 @@ jobs:
- name: "Upload package"
uses: actions/upload-artifact@v2
with:
name: centos-7_enterprise
name: centos-7
path: build/output/centos-7/memgraph*.rpm
centos-8:
@ -36,7 +36,7 @@ jobs:
- name: "Upload package"
uses: actions/upload-artifact@v2
with:
name: centos-8_enterprise
name: centos-8
path: build/output/centos-8/memgraph*.rpm
debian-9:
@ -53,7 +53,7 @@ jobs:
- name: "Upload package"
uses: actions/upload-artifact@v2
with:
name: debian-9_enterprise
name: debian-9
path: build/output/debian-9/memgraph*.deb
debian-10:
@ -70,7 +70,7 @@ jobs:
- name: "Upload package"
uses: actions/upload-artifact@v2
with:
name: debian-10_enterprise
name: debian-10
path: build/output/debian-10/memgraph*.deb
docker:
@ -89,7 +89,7 @@ jobs:
- name: "Upload package"
uses: actions/upload-artifact@v2
with:
name: docker_enterprise
name: docker
path: build/output/docker/memgraph*.tar.gz
ubuntu-1804:
@ -106,7 +106,7 @@ jobs:
- name: "Upload package"
uses: actions/upload-artifact@v2
with:
name: ubuntu-1804_enterprise
name: ubuntu-1804
path: build/output/ubuntu-18.04/memgraph*.deb
ubuntu-2004:
@ -123,5 +123,22 @@ jobs:
- name: "Upload package"
uses: actions/upload-artifact@v2
with:
name: ubuntu-2004_enterprise
name: ubuntu-2004
path: build/output/ubuntu-20.04/memgraph*.deb
debian-10-platform:
runs-on: [self-hosted, DockerMgBuild]
timeout-minutes: 60
steps:
- name: "Set up repository"
uses: actions/checkout@v2
with:
fetch-depth: 0 # Required because of release/get_version.py
- name: "Build package"
run: |
./release/package/run.sh package debian-10 --for-platform
- name: "Upload package"
uses: actions/upload-artifact@v2
with:
name: debian-10-platform
path: build/output/debian-10/memgraph*.deb

View File

@ -35,9 +35,6 @@ else()
message(FATAL_ERROR "Couldn't find clang and/or clang++!")
endif()
option(BUILD_FOR_DOCKER "Build Memgraph binary for docker." OFF)
message(STATUS "BUILD_FOR_DOCKER: ${BUILD_FOR_DOCKER}")
# -----------------------------------------------------------------------------
project(memgraph)

View File

@ -35,8 +35,7 @@ cd ${working_dir}
# Extract version and offering from deb name.
deb_name=`echo $(basename "$deb_path") | sed 's/.deb$//'`
version=`echo ${deb_name} | cut -d '_' -f 2 | rev | cut -d '-' -f 2- | rev | tr '+~' '__'`
offering=`echo ${version} | cut -d '-' -f 2`
dockerfile_path="${working_dir}/memgraph_${offering}.dockerfile"
dockerfile_path="${working_dir}/memgraph.dockerfile"
image_name="memgraph:${version}"
package_name="memgraph-${version}-docker.tar.gz"

View File

@ -10,7 +10,7 @@ ACTIVATE_TOOLCHAIN="source /opt/${TOOLCHAIN_VERSION}/activate"
HOST_OUTPUT_DIR="$PROJECT_ROOT/build/output"
print_help () {
echo "$0 init|package {os} [--for-docker]|docker|test"
echo "$0 init|package {os} [--for-docker|--for-platform]|docker|test"
echo ""
echo " OSs: ${SUPPORTED_OS[*]}"
exit 1
@ -28,10 +28,15 @@ make_package () {
if [[ "$os" =~ ^"ubuntu".* ]]; then
package_command=" cpack -G DEB --config ../CPackConfig.cmake "
fi
docker_flag=" -DBUILD_FOR_DOCKER=OFF "
if [[ "$#" -gt 2 ]]; then
if [[ "$3" == "--for-docker" ]]; then
docker_flag=" -DBUILD_FOR_DOCKER=ON "
telemetry_id_override_flag=""
if [[ "$#" -gt 1 ]]; then
if [[ "$2" == "--for-docker" ]]; then
telemetry_id_override_flag=" -DMG_TELEMETRY_ID_OVERRIDE=DOCKER "
elif [[ "$2" == "--for-platform" ]]; then
telemetry_id_override_flag=" -DMG_TELEMETRY_ID_OVERRIDE=DOCKER-PLATFORM"
else
print_help
exit
fi
fi
build_container="mgbuild_$os"
@ -64,7 +69,7 @@ make_package () {
echo "Building targeted package..."
docker exec "$build_container" bash -c "cd /memgraph && ./init"
docker exec "$build_container" bash -c "cd $container_build_dir && rm -rf ./*"
docker exec "$build_container" bash -c "cd $container_build_dir && $ACTIVATE_TOOLCHAIN && cmake -DCMAKE_BUILD_TYPE=release $docker_flag .."
docker exec "$build_container" bash -c "cd $container_build_dir && $ACTIVATE_TOOLCHAIN && cmake -DCMAKE_BUILD_TYPE=release $telemetry_id_override_flag .."
# ' is used instead of " because we need to run make within the allowed
# container resources.
# shellcheck disable=SC2016

View File

@ -5,6 +5,8 @@ set(telemetry_src_files
add_library(telemetry_lib STATIC ${telemetry_src_files})
target_link_libraries(telemetry_lib mg-requests mg-kvstore mg-utils)
if (BUILD_FOR_DOCKER)
target_compile_definitions(telemetry_lib PRIVATE DOCKER_BUILD)
option(MG_TELEMETRY_ID_OVERRIDE "Override for the telemetry ID" STRING)
if (MG_TELEMETRY_ID_OVERRIDE)
message(WARNING "Using telemetry ID override: ${MG_TELEMETRY_ID_OVERRIDE}")
target_compile_definitions(telemetry_lib PRIVATE MG_TELEMETRY_ID_OVERRIDE="${MG_TELEMETRY_ID_OVERRIDE}")
endif()

View File

@ -26,8 +26,8 @@
namespace telemetry {
namespace {
std::string GetMachineId() {
#ifdef DOCKER_BUILD
return "DOCKER";
#ifdef MG_TELEMETRY_ID_OVERRIDE
return MG_TELEMETRY_ID_OVERRIDE;
#else
// We assume we're on linux and we need to read the machine id from /etc/machine-id
const auto machine_id_lines = utils::ReadLines("/etc/machine-id");