Go - Echoip

Go - Echoip

EchoIP is a simple service for looking up your IP address.

This doc explains how to install and configure EchoIP from source, and how to deploy it as a Go application on Clever Cloud.

How to Configure and Deploy EchoIP on Clever Cloud

Download EchoIP

You can download EchoIP from https://github.com/mpolden/echoip and create a new origin.

First clone EchoIP’s repository:

~ $ git clone https://github.com/mpolden/echoip.git
~ $ cd echoip

Configure clevercloud/go.json

Create the necessary files to build and run the application:

echoip/ ~ $ mkdir clevercloud
echoip/ ~ $ cat << EOF > clevercloud/go.json
  "deploy": {
    "makefile": "Makefile",
    "main": "../go_home/bin/echoip"
echoip/ ~ $ git add clevercloud/
echoip/ ~ $ git commit -m "add clevercloud files" clevercloud/

Setting up environment variables on Clever Cloud

With the Clever Cloud console

  1. Go to the Clever Cloud console, and find the app you want to fine tune under it’s organization.
  2. Find the Environment variables menu and select it.
  3. In this menu, you will see a form with VARIABLE_NAME and variable value fields.
  4. Fill them with the desired values then select Add.
  5. Don’t forget to “Update Changes” at the end of the menu.

With the Clever Tools CLI

  1. Make sure you have clever-tools installed locally. Refer to our CLI getting started.
  2. In your code folder, do clever env set <variable-name> <variable-value>

Refer to environment variables reference for more details on available environment variables on Clever Cloud.

You can of course create custom ones with the interface we just demonstrated, they will be available for your application.

Define necessary environment variables (this is specific to EchoIP):

echoip/ ~ $ clever env set CC_RUN_COMMAND "~/go_home/bin/echoip -H X-Forwarded-For"
Your environment variable has been successfully saved

Git Deployment on Clever Cloud

You need Git on your computer to deploy via this tool. Here is the official website of Git to get more information: git-scm.com

Setting up your remotes

  1. The “Information” page of your app gives you your Git deployment URL, it looks like this:

    1. git+ssh://git@push.clever-cloud.com/<your_app_id>.git
    2. Copy it in your clipboard
  2. Locally, under your code folder, type in git init to set up a new git repository or skip this step if you already have one

  3. Add the deploy URL with git remote add <name> <your-git-deployment-url>

  4. Add your files via git add <files path> and commit them via git commit -m <your commit message>

  5. Now push your application on Clever Cloud with git push <name> master

Refer to git deployments for more details.

Add the clevercloud git remote:

echoip/ ~ $ git remote add clevercloud $(jq -r '.apps[0].git_ssh_url' < .clever.json)

Push the app for deployment:

echoip/ ~ $ git push clevercloud master

Check the deployment logs:

echoip/ ~ $ clever logs
Last updated on

Did this documentation help you ?