NavigationContentFooter
Jump toSuggest an edit

Deploying Umami web analytics on Serverless Containers

Reviewed on 26 February 2024Published on 21 April 2021
  • Umami
  • serverless
  • containers
  • endpoint

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.

Before you start

To complete the actions presented below, you must have:

  • A Scaleway account logged into the console
  • Owner status or IAM permissions allowing you to perform actions in the intended Organization
  • An SSH key
  • A valid API key
  • A Container Registry
  • A Database for PostgreSQL
  • Installed Docker on your local computer

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 $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 mVCPU.

  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:

      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.

  8. Verify that the container privacy policy is set to Public.

  9. 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 (optionally)

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.

Docs APIScaleway consoleDedibox consoleScaleway LearningScaleway.comPricingBlogCarreer
© 2023-2024 – Scaleway