# Neo4j

import { Tabs, TabsContent, TabsList, TabsTrigger } from "zudoku/ui/Tabs"

{/* vale off */}
{/* THIS FILE WAS AUTOGENERATED FROM THE PUBLIC EXAMPLE REPOSITORY. DO NOT EDIT THIS FILE DIRECTLY. */}


This guide shows you how to use [Neo4j](https://neo4j.com), one of the most popular open source graph databases.
To run this example, follow these steps:

1. Install the CLI.
   Use the [unikraft CLI](/cli/unikraft).
   You need a [BuildKit](https://github.com/moby/buildkit) builder. The easiest way to get one is via [Docker](https://docs.docker.com/engine/install/).
   Alternatively, you can also directly set up and use BuildKit, see the [quick start](https://github.com/moby/buildkit#quick-start).

2. Clone the [`examples` repository](https://github.com/unikraft-cloud/examples) and `cd` into the `examples/neo4j/` directory:

   ```bash
   git clone https://github.com/unikraft-cloud/examples
   cd examples/neo4j/
   ```

Make sure to log into Unikraft Cloud and pick a [metro](/platform/metros) close to you.
This guide uses `fra` (Frankfurt, 🇩🇪):

```bash title="unikraft"
unikraft login
```

When done, invoke the following command to deploy this app on Unikraft Cloud:

```bash title="unikraft"
unikraft build . --output <my-org>/neo4j:latest
unikraft run --metro fra --scale-to-zero policy=idle,cooldown-time=4000,stateful=true -m 2G -p 443:7474/tls+http -p 7687:7687/tls --image <my-org>/neo4j:latest
```

:::note
You can also set a custom password for the default neo4j user by adding the
following env var to the run command
`-e "NEO4J_AUTH_PASSWORD=..."`
:::

The output shows the instance address and other details:

```ansi title="unikraft"
[1mmetro[22m:           fra
[1mname[22m:            neo4j-t117i
[1muuid[22m:            c59f865e-e954-4bf8-8da8-7ee6f1c1aab2
[1mstate[22m:           [38;2;144;161;185mstarting[0m
[1mimage[22m:           <my-org>/neo4j
[1mresources[22m:
[3m  memory[23m:        2GiB
[3m  vcpus[23m:         1
[1mservice[22m:
[3m  name[23m:          fragrant-fog-pj1gi4jl
[3m  uuid[23m:          a3d29dfa-650b-4e8c-a8e6-055f59dd4c92
[3m  domains[23m:
[3m  - fqdn[23m:        fragrant-fog-pj1gi4jl.fra.unikraft.app
[1mnetworks[22m:
[3m- uuid[23m:          1a65f2c3-cbfd-48bf-b8db-5cb90ed62a7c
[3m  private-ip[23m:    10.0.1.73
[3m  mac[23m:           12:b0:0a:00:01:49
[1mtimestamps[22m:
[3m  created[23m:       just now
[1mscale-to-zero[22m:
[3m  enabled[23m:       true
[3m  policy[23m:        idle
[3m  stateful[23m:      true
[3m  cooldown-time[23m: 4s
```

In this case, the instance name is `neo4j-t117i` and the address is `https://fragrant-fog-pj1gi4jl.fra.unikraft.app`
They're different for each run.

Use `curl` to query the Unikraft Cloud Neo4j instance:

```bash
curl https://fragrant-fog-pj1gi4jl.fra.unikraft.app
```

```text
{"bolt_routing":"neo4j://fragrant-fog-pj1gi4jl.fra.unikraft.app:7687","query":"https://fragrant-fog-pj1gi4jl.fra.unikraft.app:7687/db/{databaseName}/query/v2","transaction":"https://fragrant-fog-pj1gi4jl.fra.unikraft.app/db/{databaseName}/tx","bolt_direct":"bolt://fragrant-fog-pj1gi4jl.fra.unikraft.app:7687","neo4j_version":"2026.04.0","neo4j_edition":"community"}
```

Or even better, point a browser at it 😀. Make sure you have the protocol set
to `neo4j+s` when logging in.

You can also try connecting to the instance using the `cypher-shell` CLI
```bash
cypher-shell -a neo4j+s://fragrant-fog-pj1gi4jl.fra.unikraft.app:7687 -u neo4j
```

You can list information about the instance by running:

<CodeTabs syncKey="cli">

```bash title="unikraft"
unikraft instances list
```

```ansi title="unikraft"
[1mMETRO[22m         [1mNAME[22m         [1mSTATE[22m    [1mIMAGE[22m           [1mARGS[22m  [1mMEMORY[22m  [1mVCPUS[22m  [1mFQDN[22m                                              [1mCREATED[22m
fra           neo4j-t117i  [38;2;43;127;255mstandby[0m  <my-org>/neo4j        2GiB    1      fragrant-fog-pj1gi4jl.fra.unikraft.app   just now
```

</CodeTabs>

When done, you can remove the instance:

```bash title="unikraft"
unikraft instances delete neo4j-t117i
```

## Using volumes

You can use [volumes](/platform/volumes) for data persistence for your neo4j instance.
For that you would first create a volume:

```bash title="unikraft"
unikraft volume create --set metro=fra --set name=neo4j-store --set size=512M
```

Then start the neo4j instance and mount that volume:

```bash title="unikraft"
unikraft build . --output <my-org>/neo4j:latest
unikraft run --metro fra --scale-to-zero policy=idle,cooldown-time=4000,stateful=true -m 2G -p 443:7474/tls+http -p 7687:7687/tls --volume neo4j-store:/data --image <my-org>/neo4j:latest
```

## Customize your app

To customize the app, update the files in the repository, listed below:

* `Kraftfile`: the Unikraft Cloud specification, including command-line arguments
* `Dockerfile`: In case you need to add files to your instance's rootfs

## Learn more

Use the `--help` option for detailed information on using Unikraft Cloud:

```bash title="unikraft"
unikraft --help
```
Or visit the [CLI Reference](/cli/unikraft)
{/* vale on */}
