Skip to main content
Version: Next

Docker Installation

note

Before installing Lunar 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 Control Plane​

The easiest installation process is through the Lunar 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 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 Control Plane, you can install the Lunar 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 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 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 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 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 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.

CTRL + M