Package Memgraph
Build a .deb or .rpm package of Memgraph from source. There are three ways
to do it:
- With
mgbuild.sh, which builds and packages Memgraph in a Docker container (recommended). - With
package.sh, which packages a local build directory. - With CPack, which you run by hand.
Since Memgraph 3.13, the 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.
Package with mgbuild.sh
The mgbuild.sh script builds Memgraph in a Docker container. Before you
package Memgraph, build it with
Docker.
The OS variable only selects the Docker build environment, not the target
distribution. The build environments are centos-9, centos-10, debian-12,
debian-13, fedora-42, fedora-43, rocky-10, ubuntu-22.04,
ubuntu-24.04 and ubuntu-26.04.
With the same environment variables you exported for the build, build the package:
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
--build-type $BUILD_TYPE \
package-memgraphCopy the package 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 --removeThe package is in the output directory. Install it with apt or dnf,
depending on the distribution. For example, on Ubuntu 24.04:
sudo apt install ./output/PACKAGE_FILE.debPACKAGE_FILE is the name of the .deb file in the output directory,
named memgraph_VERSION_ARCH.deb.
Build a Docker image from the package
On Ubuntu 24.04, you can also turn the package into a Docker image. First, build a custom OpenSSL package:
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
build-ssl \
--version "3.5.4"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-outputThe command writes a Docker image archive to the docker-output directory.
Load it into Docker:
docker load -i docker-output/IMAGE_ARCHIVE.tar.gzIMAGE_ARCHIVE is the name of the archive in docker-output. docker load
prints the name and tag of the loaded image. Run it:
docker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph:IMAGE_TAGIMAGE_TAG is the tag that docker load printed.
Package with package.sh
After you build Memgraph with
build.sh
or with conan and
cmake,
the package.sh script in the repository root packages the build directory on
the host. It takes a target and a package format:
source /opt/toolchain-v8/activate
./package.sh memgraph deb- The target is
memgraph(thememgraphandmemgraph-debuginfopackages),mage(thememgraph-magepackage, plusmemgraph-mage-debuginfowhen the build used--split-debug) orall(everything the build was configured for). - The format is
deborrpm.
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 configured for the requested
target (packaging mage requires a build with --mage on or --mage only),
selects the right CPack components and checks that it produced the expected
number of packages. It writes the packages to build/output/. To package from
another build directory, pass --build-dir DIR, where DIR is the path to
that directory.
Package with CPack
package.sh is a wrapper around CPack. For full control, run CPack yourself.
Create the output directory:
mkdir -p build/output && cd build/outputActivate the toolchain:
source /opt/toolchain-v8/activateBuild the package for your distribution family:
-
RPM-based distributions:
cpack -G RPM --config ../CPackConfig.cmake -
DEB-based distributions:
cpack -G DEB --config ../CPackConfig.cmake
Install the package with apt or dnf.