Hometutorials
deploy umami on serverless containers

Jump toUpdate content

How to deploy umami web analytics on Serverless Containers

Reviewed on 21 April 2022Published on 21 April 2021
  • umami
  • serverless
  • containers

Umami is a simple, easy to use, self-hosted web analytics solution. It provides an easy-to-use, open-source, and privacy-focused alternative to paid solutions such as Google Analytics. The tool collects only the metrics relevant to you and displays everything on a single page.

Requirements:

Preparating the Database

  1. Create a database user and grant permissions to the PostgreSQL database you want to use for umami.

  2. Clone the umami project locally and enter the project’s directory:

    git clone https://github.com/mikecao/umami.git
    cd umami
  3. Install the required tables from the script shipped with umami:

    psql -h <postgresql-ip>:<port> -U username -d databasename -f sql/schema.postgresql.sql

Preparing the Container Registry

  1. Sign in to your namespace in your terminal:

    docker login rg.fr-par.scw.cloud/<umami-namespace> -u nologin -p $SCW_SECRET_TOKEN
    Important:

    In order to run this example, you must first create a secret token from the credentials page, and replace the expression $SCW_SECRET_TOKEN with the created token.

  2. Download the umami Docker container on your local machine:

    docker pull ghcr.io/mikecao/umami:postgresql-latest
  3. Tag the local container

    docker tag ghcr.io/mikecao/umami:postgresql-latest rg.fr-par.scw.cloud/<umami-namespace>/umami:postgresql-latest
  4. Push the local container to your Container Registry namespace:

    docker push rg.fr-par.scw.cloud/<umami-namespace>/umami:postgresql-latest
  5. Click the Namespace Settings tab in the Container Registry section of the Scaleway console and make sure your namespace privacy policy is set to Public.

Deploying the Serverless Container

  1. Select the namespace you want to use to deploy the application in the Serverless Containers section of the Scaleway console. If you do not have a Serverless Containers namespace yet, click + Create a namespace to create a new one.

  2. Click + Deploy a Container. The container deployment wizard displays.

  3. Choose the namespace you pushed the image to and select the umami:postgresql-latest image. Set the value for the port to 3000.

  4. Enter a name for your container. Optionally, you can enter a container description.

  5. Select the resources you want to allocate to the container. The resources to allocate depend on the intended load of your application. In this tutorial we use 128 MB - 70 mCPU.

  6. Configure the minimum and maximum values to autoscale the number of available instances for your container.

  7. Set the Secrets. Secrets are an extra-secure type of environment variables which are injected into your container and stored securely:

Click **+ Add a new secret** to add a secret. Configure the following two secrets:
* `DATABASE_URL`: The URL of your PostgreSQL database in the format:

```md
postgres://<db-user>:<db-password>@<postgresql-ip>:<port>/<db-name>?sslmode=require
```
* `HASH_SALT`: A random hash. To generate it, run `openssl rand -hex 32` in your terminal and post the output in the form.
  1. Verify that the container privacy policy is set to Public.

  2. Click Deploy a Container.

Accessing the umami dashboard

  1. Click the Container Settings tab, to display container information.

  2. Copy the URL displayed for Container Endpoint and paste it into a web browser. The umami login screen displays.

  3. Log in to the umami interface using the following credentials:

    • User: admin
    • Password: umami

    The umami dashboard displays and you can add websites to monitor. For more information about umami refer to the official documentation.

Customizing the endpoint name (otionally)

Your Serverless Functions come with a default endpoint name. You can customize this to a name of your choice using the Endpoints feature.

  1. Click the Endpoints tab. The endpoint information displays.

  2. Click + Add new Endpoints. A pop up displays.

  3. Enter the name of your endpoint. You can use any domain or subdomain that you own. Click Add Endpoint to validate.

    Note:

    Make sure you have configured a valid CNAME record for your domain and activated TLS before adding the endpoint.

The new endpoint displays in the list of endpoints. You can now access your application using your custom endpoint name.