meili-gcp-min (1).png

Self-Hosting Meilisearch - Own Your Tools

Goal

At the end of this tutorial, you'll have a production-ready search Meilisearch Instance ready to serve content running on Google Cloud Platform in your own infrastructure. This article is part of the "Own Your Tools" series, which explores the key advantages of embracing self-hosted open-source solutions like Appsmith and Meilisearch for building business-oriented dashboards and apps. 

Prerequisites

  • A Google Cloud Platform Account (you can use the Free Tier

Overview

Meilisearch is an open-source, lightning-fast search engine that can be easily integrated into internal dashboards and enterprise apps. It's designed to provide an excellent search experience with its key features:

  1. Blazing Fast Search
  2. Full-Text Search
  3. Typo Tolerance
  4. Filtering and Faceting
  5. Ranking and Relevance
  6. Easy Integration
  7. Scalability
  8. RESTful API

Meilisearch is an excellent choice for enhancing the search experience in various enterprise cases.

  1. Import Meilisearch custom image on your GCP account

    Navigate to "Compute Engine" -> "Images" and then Click on "[+] CREATE IMAGE"

    meilisearch gcp
    • Give it a name (I called mine meilisearch)
    • For the "Source" field, select "Virtual disk (VMDK, VHD)"
    • If you are prompted to enable Cloud Build tools and grant permissions, do it
    • Copy the following URI in the "Cloud Storage file" field
    meilisearch-image/meilisearch-v1-4-0-debian-11.vmdk

    If you click on the Browse button, you can see other version of Meilisearch and you can select the one you need, or see new versions. 

    meilisearch gcp
    • The other fields are not required; unselect the "Install guest packages"
    • Click on "Create". You may have to wait up to 20 minutes while the Meilisearch custom image imports to your account
    meilisearch gcp
  2. Create a new GCP Compute Engine instance from the imported image

    Open the tab "Images" and click on the name of the image that you just imported, in my case is called meilisearch, and click on the "[+] Create instance" button. 

    meilisearch gcp
    • Give your instance a name
    • In the "Machine configuration" section, make sure to pick a "Machine type" with enough memory to run Meilisearch according to your needs. More memory means faster searching, for the sake of this demo we'll use the e20-micro (vCPU 0.25-2 vCPU (1 shared core) Memory 1 GB) and it works really well, for production scenarios you might want to consider a e2-highmem-2 configuration at least. 
    • In the "Firewall" section, make sure to check the "Allow HTTP traffic" and "Allow HTTPS traffic" boxes so that your Meilisearch instance can communicate with the internet
    • Finally, click on the "Create" button. After a minute or two, your Meilisearch instance should be up and running

    gcp meilisearch

    You can check that your instance is running correctly by copying and pasting the "External IP" address provided by GCP into your browser, or by typing the following command on your terminal:

    curl http://<your-external-ip>/health

    The server should answer with a 200 OK status code as shown in the example below:

    {"status": "available"}
    meilisearch gcp

    Now, this is great! our instance is ready to start indexing content, but before doing that, we need to secure our instance by defining a master API key. 

  3. Set your instance to a production environment


    Configuring your Meilisearch instance in a production environment is not just straightforward—it's completely automated. Let's connect to our instance using SSH and a script will guide us through the process.

    meilisearch gcp

    This will open a new tab and provide a SSH client to our VM. 

    You should see something like this:

    ________________________________________________
    ________________________________________________
                 _ _ _ __                     _
      /\/\   ___(_) (_) _\ ___  __ _ _ __ ___| |__
     /    \ / _ \ | | \ \ / _ \/ _` | '__/ __| '_ \
    / /\/\ \  __/ | | |\ \  __/ (_| | | | (__| | | |
    \/    \/\___|_|_|_\__/\___|\__,_|_|  \___|_| |_|
    
    ________________________________________________
    ________________________________________________

    If it’s your first time accessing the instance via SSH, a script automatically asks for your settings and desired configuration. If you want to run this script again at any time, you can do so by using the following command:

    meilisearch-setup

    The setup guide will ask you some questions for example the master KEY setup, domain setup and other configurations

    Once you are done with it, your instance is ready for production use with the MASTER key, make sure to securely store this key as we will need to use it to index data and also search data. 
     

Conclusion

This article showcased how easy is to self-host Meilsearch on GCP. By taking ownership of your tools, you can unlock a world of possibilities, including Enhanced Security and Privacy, Seamless Compliance, Customization and Extensibility, Freedom from Vendor Lock-in and Cost-Effective Scalability. 

In the next chapter, you will discover how easy it is to integrate Appsmith with Meilisearch and have internal dashboards with powerful search capabilities. 

Additional Resources