Package Memgraph
This guide will show you how to package Memgraph as a .deb or .rpm package.
There are three main ways to package Memgraph:
- Using the
mgbuild.shscript, which builds Memgraph in a Docker container. (Recommended) - Using the
package.shscript, which packages a local build directory. - Using CPack, which invokes CPack manually.
As of version 3.13 the produced packages are distro-agnostic: one .deb
(all Debian-family distributions) and one .rpm (all RHEL-family
distributions) per architecture, running on any Linux with glibc 2.31 or
newer. The OS value below only selects the Docker build environment,
not the target distribution. Available build environments: centos-9,
centos-10, debian-12, debian-13, fedora-42, fedora-43,
rocky-10, ubuntu-22.04, ubuntu-24.04, ubuntu-26.04.
Using the mgbuild.sh script
The mgbuild.sh script is a convenience script that builds Memgraph in a Docker container. Prior to
packaging Memgraph, you need to build it first.
Using the same export environment variables as in the
build-memgraph-from-source guide, run the
mgbuild.sh script by running the following command to build the package:
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
--build-type $BUILD_TYPE \
package-memgraphThen it can be copied out of the container:
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
copy \
--package \
--dest-dir outputStop the container:
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
stop --removeNow, the package can be found in the output directory and it can be installed using apt or
dnf, depending on the distribution. For example, for Ubuntu 24.04:
sudo apt install ./output/memgraph_<version>_<arch>.debFor Ubuntu 24.04, the package can also be used to create a Docker image. To do this, we must first build a custom OpenSSL package:
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
build-ssl \
--version "3.5.4"The following command will then create an Ubuntu-based Docker image:
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
--build-type $BUILD_TYPE \
package-docker \
--src-dir output \
--dest-dir docker-outputresulting in a Docker image tarball in the docker-output directory. This can then be loaded
into Docker using the docker load command.
docker load -i docker-output/memgraph-<version>-docker.tar.gzThe image can then be run using the docker run command.
docker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph:<version>Using the package.sh script
After following the build instructions using
build.sh, or
conan and cmake, the
package.sh script in the repository root packages the build directory directly on the host.
It takes a target and a package format:
source /opt/toolchain-v8/activate
./package.sh memgraph debTARGETis one ofmemgraph(thememgraph+memgraph-debuginfopackages),mage(thememgraph-magepackage, plusmemgraph-mage-debuginfowhen the build used--split-debug), orall(everything the build was configured for).FORMATisdeborrpm.
For example, to package the MAGE query modules as an RPM from a
./build.sh --mage only build:
./package.sh mage rpmThe script checks that the build directory is actually configured for the requested target
(e.g. packaging mage requires a build with --mage on or --mage only), selects the right
CPack components, and verifies the expected number of packages was produced. The packages are
written to build/output/. Use --build-dir DIR to package from a non-default build
directory.
Using CPack
package.sh is a thin wrapper around CPack — if you need full control, you can also invoke
CPack manually.
Prior to packaging, create the output directory:
mkdir -p build/output && cd build/outputActivate the toolchain:
source /opt/toolchain-v8/activateThen run the following commands to build the package, depending upon the distibution:
- For RPM-based distributions:
cpack -G RPM --config ../CPackConfig.cmake- For DEB-based distributions:
cpack -G DEB --config ../CPackConfig.cmakeOnce built, the packages can be installed using apt or dnf.