Deploy a Meilisearch instance on Google Cloud Platform (GCP) Compute Engine

    Using our GCP custom image, Meilisearch can be deployed on GCP in just a few minutes.

    The following guide will walk you through every step to deploy Meilisearch in a GCP Compute Engine instance. If you have any problems with our GCP image, please create an issue in this repository.

    Part 1: Deploy a Meilisearch instance

    1. Import Meilisearch custom image on your GCP account

    Page titled 'Images'

    Adding image name(permanent), source, and cloud storage file

    meilisearch-image/meilisearch-v1.0.2-debian-10.vmdk
    

    meilisearch-example successfully imported

    2. Create a new GCP Compute Engine instance from the imported image

    The meilisearch-v-X-X-X instance

    Selecting the 'E2' series and 'e2-medium (2 vCPU, 4 GB memory)' machine type

    Selecting the 'Balanced persistent disk' Boot disk type and 10GB Size

    The meilisearch-gcp-test instance running successfully

    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"}
    

    Part 2: Set your instance to a production environment

    Configuring your Meilisearch instance in a production environment is not just straightforward—it's completely automated. Establish an SSH connection with your instance, and a script will guide you through the process.

    1. Make your domain name point to your instance IP

    If you want to use a custom domain name (or sub-domain), add an A record in your domain name provider account. Otherwise, you can skip this step.

    The my-gcp-instance domain

    Your domain name should now be linked to your Meilisearch instance. Run a health check to verify that your instance is running and your DNS is well configured:

    curl -v http://<your-domain-name>/health
    

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

    ...
    < HTTP/1.1 200 OK
    ...
    

    2. Set API key and SSL (HTTPS)

    Meilisearch is currently running in a development environment. You haven't set up an API key, meaning that anyone can read/write from your Meilisearch, and you aren't using HTTPS yet, which makes this configuration unsafe for production.

    To start the configuration process, connect via SSH to your new Meilisearch instance and follow the instructions that appear.

    2.2. Run the configuration script

    2.2.1 Option 1: Using the Google Cloud Console

    Navigate to "Compute Engine" -> "VM instances". Click on the name of your instance, and then click on the "SSH" button (make sure to have pop-ups enabled or the window may be blocked). The connection will be established and the script will automatically run.

    2.2.2 Option 2: Add your SSH key to the Compute Engine metadata

    cat ~/.ssh/id_rsa.pub
    

    Now establish an SSH connection using the same username that is present on your SSH key. If you are adding your local system key, it will probably be your username on your local system. To know what this username is in UNIX-like systems, run the command:

    whoami
    

    Then establish a connection using the following command:

    ssh <your-username>@<your-external-ip-or-domain-name>
    

    You should see something like this:

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

    If it’s your first time accessing the instance via SSH, a script will run automatically asking 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
    

    3. Enjoy your ready-to-use Meilisearch instance

    Your Meilisearch instance is up and running on GCP and ready to be used in production.

    To make sure that everything is running smoothly, do a final HTTP call to the /health route:

    curl -v https://<your-domain-name>/health
    

    Note that this time, we're using HTTPS.

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

    ...
    < HTTP/1.1 200 OK
    ...
    

    You're all set to use Meilisearch in production with GCP! If you have any problems with our GCP image, please create an issue in this repository.