Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions pages/getting-started/build-memgraph-from-source.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ first.

</Callout>

Please see the [Packaging Memgraph](/getting-started/packaging-memgraph) guide for
information on how to build a Memgraph package for a Linux distribution.

## Obtain the Source Code

After installing `git`, you are now ready to fetch your own copy of the Memgraph
Expand Down Expand Up @@ -205,12 +208,24 @@ conan profile detect
conan config install conan_config
```

<Callout>
- `conan` is a Python-based package manager for C/C++ projects. It is used to manage dependencies
and build Memgraph.
- `conan_config` is a subdirectory of the Memgraph repository which contains specific configuration
files that tell `conan` how to build Memgraph and the libraries that link to it.
</Callout>

<h3 className="custom-header">Run the init script to fetch other libs required for the build</h3>

```bash
./init
```

<Callout>
The `init` script fetches other libraries required for the build which are not yet provided
by `conan`.
</Callout>

<h3 className="custom-header">Install conan dependencies</h3>

```bash
Expand All @@ -223,6 +238,12 @@ conan install . \
source build/generators/conanbuild.sh
```

<Callout>
- `conan install` builds the libraries and build tools required for building Memgraph, creates
generators for CMake and Ninja and generates the CMake preset.
- The `source build/generators/conanbuild.sh` command sets up the environment for the build.
</Callout>

<h3 className="custom-header">Configure the project with cmake</h3>

Note that the name of the preset depends on the build type set in the previous
Expand Down Expand Up @@ -259,6 +280,18 @@ export BUILD_TYPE="Release"
export TOOLCHAIN="v7"
```

<Callout>
The distributions of Linux currently supported by Memgraph are and their associated `OS` environment variable:
- CentOS 9: `centos-9`
- CentOS 10: `centos-10`
- Debian 12: `debian-12`
- Debian 13: `debian-13`
- Fedora 42: `fedora-42`
- Rocky 10: `rocky-10`
- Ubuntu 22.04: `ubuntu-22.04`
- Ubuntu 24.04: `ubuntu-24.04`
</Callout>

Next, pull the appropriate Docker image for the build, e.g.:

```bash
Expand Down Expand Up @@ -331,3 +364,26 @@ Or in Docker:
--organization-name $MEMGRAPH_ORGANIZATION_NAME \
test-memgraph unit
```

## Troubleshoot

When build errors occur, there are some common issues that can be resolved by the following steps:

1. Remove the `build` directory and run the build again.

2. Re-run `./init`: Sometimes libraries that are configures by this script will be
upgraded/added/removed in the `master` branch, potentially causing future build errors.

3. Re-run `conan install`: for simlar reasons as the previous step - libraries used in the build may
have been changed in `conanfile.py`. Unexpected linking errors can be caused by this.

4. Reinstall `conan_config`. As list of supported Linux distributions and architectures evolves,
and the libraries used in the build may change, the configuration may need to be updated to account
for specific build issues on some platforms.

5. Reinstall host dependencies, as these may sometimes change.

6. Renaming or removing the conan cache directory (usually `~/.conan2`) in order to rebuild the
libraries and build tools from scratch can help to resolve build issues.

7. Open an issue on our [GitHub repository](https://github.com/memgraph/memgraph/issues) with the error message.
150 changes: 150 additions & 0 deletions pages/getting-started/packaging-memgraph.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
---
title: Packaging Memgraph
description: This guide will show you how to package Memgraph for a Linux distribution.
---

import { Callout } from 'nextra/components'
import { Steps } from 'nextra/components'

# Package Memgraph

This guide will show you how to package Memgraph for one of out supportedLinux distributions.
There are two main ways to package Memgraph:

- [Using the `mgbuild.sh` script](#using-the-mgbuildsh-script), which builds Memgraph in a Docker container. (Recommended)
- [Using CPack](#using-cpack), which builds Memgraph using CMake.

<Callout>
The distributions of Linux currently supported by Memgraph are and their associated `OS` environment variable:
- CentOS 9: `centos-9`
- CentOS 10: `centos-10`
- Debian 12: `debian-12`
- Debian 13: `debian-13`
- Fedora 42: `fedora-42`
- Rocky 10: `rocky-10`
- Ubuntu 22.04: `ubuntu-22.04`
- Ubuntu 24.04: `ubuntu-24.04`
</Callout>

## 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](/getting-started/build-memgraph-from-source#use-docker).

Using the same export environment variables as in the
[build-memgraph-from-source](/getting-started/build-memgraph-from-source#use-docker) guide, run the
`mgbuild.sh` script by running the following command to build a distro-specific package:

```bash
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
--build-type $BUILD_TYPE \
package-memgraph
```

Then it can be copied out of the container:

```bash
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
copy \
--package \
--dest-dir output
```

Stop the container:

```bash
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
stop --remove
```

Now, 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:

```bash
sudo apt install ./output/memgraph_<version>_<arch>.deb
```

<Callout>
For 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:

```bash
./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:

```bash
./release/package/mgbuild.sh \
--toolchain $TOOLCHAIN \
--os "$OS" \
--arch $ARCH \
--build-type $BUILD_TYPE \
package-docker \
--src-dir output \
--dest-dir docker-output
```

resulting in a Docker image tarball in the `docker-output` directory. This can then be loaded
into Docker using the `docker load` command.

```bash
docker load -i docker-output/memgraph-<version>-docker.tar.gz
```

The image can then be run using the `docker run` command.

```bash
docker run -p 7687:7687 -p 7444:7444 --name memgraph memgraph/memgraph:<version>
```
</Callout>


## Using CPack

After following the build instructions using
[`build.sh`](/getting-started/build-memgraph-from-source#use-buildsh-script), or
[`conan` and `cmake`](/getting-started/build-memgraph-from-source#use-conan-and-cmake), one can use
CPackto build a Memgraph package for a Linux distribution.

Prior to packaging, create the output directory:

```bash
mkdir -p build/output && cd build/output
```

Activate the toolchain:

```bash
source /opt/toolchain-v7/activate
```

Then run the following commands to build the package, depending upon the distibution:

- For RPM-based distributions:

```bash
cpack -G RPM --config ../CPackConfig.cmake
```

- For DEB-based distributions:

```bash
cpack -G DEB --config ../CPackConfig.cmake
```

Once built, the packages can be installed using `apt` or `dnf`.