DEV Community

JakovGlavac
JakovGlavac

Posted on

Deploy Meilisearch on Fly.io

Introduction

This guide explains how to deploy a ready-to-use Meilisearch instance on Fly.io.
First time I tried this I've had some problems that wasted me a lot of time, so to save you the time I'll create step-by-step instructions.

Just do it

So if you want to deploy it to fly io as fast as possible, this is the way.

In any folder create fly.toml, and copy the content

app = "my-meilisearch"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  image = "getmeili/meilisearch"

[env]

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[mounts]]
  source = "disc1"
  destination = "/meili_data"

[[services]]
  http_checks = []
  internal_port = 7700
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"
Enter fullscreen mode Exit fullscreen mode

then login in fly io!

flyctl login

and then deploy it!

flyctl deploy

Theory

persistent storage

So, the "hard" part of deploying is to create persistent storage.
Fly.io has a guide on that here, but in short you need to add this part to your toml.

[[mounts]]
  source = "disc1"
  destination = "/meili_data"
Enter fullscreen mode Exit fullscreen mode

This creates disc, that is mapped to this folder meili_data.

Why use /meili_data, because there is where melisearch stores your data.

docker image

If you want fly io to use docker image from docker hub you need to specify image in build step like this:

[build]
  image = "getmeili/meilisearch"
Enter fullscreen mode Exit fullscreen mode

port

Meilisearch is by default on port 7700, so you need to tell fly io to listen to internal 7700 port.

[[services]]
  internal_port = 7700
Enter fullscreen mode Exit fullscreen mode

Everything else is pretty much default.

And that's it 🎉!

Top comments (3)

Collapse
 
hiccupq profile image
hiccupq

Saved my ass thanks a lot!

Collapse
 
pierratono profile image
Pierratono Costa MAHORO

How to set master key?

Collapse
 
jakovglavac profile image
JakovGlavac

set it as an environment variable, use the following syntax: MEILI_MASTER_KEY="MASTER_KEY". For more information, refer to the documentation meilisearch.com/docs/learn/securit...