Skip to main content
Version: Next

Docker Installation

note

Before installing Lunar.dev API Consumption Gateway, make sure thatĀ DockerĀ is installed on your environment. If you haven't installed Docker yet, you can learn more about it and download it fromĀ the Docker website

Installation through the Lunar.dev Control Planeā€‹

The easiest installation process is through theĀ Lunar.dev Control Plane. After launching the control plane, simply follow the step-by-step instructions that appear after clicking the "Continue" button. As long as you have a Docker instance up and running, the Lunar.dev Control Plane will be automatically synced to your API Consumption Gateway via the API key that appears in the command for you to copy.

Manual Installationā€‹

Alternatively, if you do not want to leverage the Lunar.dev Control Plane, you can install the Lunar.dev API Consumption Gateway without the UI by following the steps below.

Step 1: Run Lunar's Gateway Containerā€‹

Once the image download is complete, you can run the API Consumption Gateway container using the following command:

docker run -d --rm -p 8000:8000 -p 8081:8081 -p 8040:8040 -e TENANT_NAME="ORGANIZATION" -v $(pwd):/etc/lunar-proxy --name lunar-proxy lunarapi/lunar-proxy:latest
caution

Note that theĀ TENANT_NAMEĀ environment variable is required. This variable should be set to the name of your organization.

  • d: Start a container in detached mode.
  • -rm: Automatically remove the container when it exits.
  • p: Publish all exposed ports to the host interfaces.
  • e: Set environment variables. In this case, we set theĀ TENANT_NAMEĀ environment variable toĀ ORGANIZATION.
  • -v: Mount your configuration files to the /etc/lunar-proxy directory inside the Lunar.dev Gateway container.
  • -name: The UUID identifiers come from the Docker daemon.

For more details on how to structure your configuration files, refer to the ā€œFlows Configurationsā€ page.

Step 2: Verify Installationā€‹

To ensure the successful installation of Lunar.dev API Consumption Gateway there are two options:

Option 1:Ā Run the following command to make a request to the healthcheck endpoint which validates that Lunar.dev API Consumption Gateway is up.

curl http://localhost:8040/healthcheck

Or, if you prefer usingĀ wget:

wget -qO - http://localhost:8040/healthcheck

Please note that these commands are interchangeable based on your preference and the availability ofĀ curlĀ orĀ wgetĀ on your system.

Option 2:Ā Try to pass a request through the API Consumption Gateway by running the following command:

curl http://localhost:8000/fact -H "x-lunar-host: catfact.ninja" -H "x-lunar-scheme: https"

Or, withĀ wget:

wget -qO - --header="x-lunar-host: catfact.ninja" --header="x-lunar-scheme: https" http://localhost:8000/fact

This will make a request to Lunar.dev API Consumption Gateway on port 8000, which will forward the request to the upstream serverĀ catfact.ninjaĀ on port 443, at the pathĀ /factĀ (this is an API that returns the latest exchange rates).

The result should look something like this:

{"fact":"Among many other diseases, cats can suffer from anorexia, senility, feline AIDS and acne.","length":89}

Then, use theĀ DiscoverĀ command to validate that the requests were passed through Lunar.dev API Consumption Gateway.

docker exec lunar-proxy discover

The result should look something like this:

{
"interceptors": [
{
"type": "unknown",
"version": "unknown",
"last_transaction_date": "2023-07-10T08:56:12Z"
}
],
"endpoints": {
"GET:::catfact.ninja/fact": {
"min_time": "2023-02-05T17:07:42",
"max_time": "2023-02-05T17:09:14",
"count": 1,
"status_codes": {
"200": 1
},
"average_duration": 555
}
}
}

note

The interceptor type and version are unknown because we are using curl to make the request. Once anĀ interceptorĀ is used, its type and version will appear in the discover command output.