Deploy Umami analytics with Launcher

I have recently moved my deployment solution to Launcher and I wanted to use it to deploy Umami in my server too. It involves a few steps.

Create a new site and set the Git repository to git@github.com:mikecao/umami.git, and branch master, and copy the new database credentials.

Edit the App .env file.

1DATABASE_URL=mysql://USERNAME:PASSWORD@mysql-8:3306/statsyourdomaincom
2HASH_SALT=WzkHGhOkPkV5dQHwVmOXeJK7ro4uWL5Z

Replacing USERNAME and PASSWORD with your generated database credentials, and RANDOMSTRING with a random string.

On macOS, you can use the following code to generate a random string of 32 characters.

1cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 32

Edit the Deploy script (entrypoint).

1#!/bin/bash
2 
3set -eux -o pipefail
4export NODE_OPTIONS=--max-old-space-size=8192
5 
6echo "Git pull"
7git remote set-url origin $LAUNCHER_SITE_GIT_REPOSITORY
8git pull origin $LAUNCHER_SITE_GIT_BRANCH
9 
10if [ -f yarn.lock ]; then
11 echo "Install yarn dependencies and build production assets"
12 yarn install
13 yarn run build
14fi
15 
16exec "$@"

Edit the Dockerfile PHP-FPM to expose the port 3000 used for Umami.

1# https://hub.docker.com/u/uselauncher/php-fpm-80
2# https://github.com/uselauncher/php-fpm-80
3 
4FROM uselauncher/php-fpm-80
5 
6# Uncomment the two lines below to install additional PHP extensions
7# See: https://github.com/mlocati/docker-php-extension-installer
8 
9# USER root
10# RUN install-php-extensions ldap
11 
12USER launcher
13 
14EXPOSE 3000

Deploy your stats.yourdomain.com site.

Create a daemon with the following command.

1yarn --cwd /app start

SSH into container to get the daemon container name.

1ssh launcher@YOURSERVERIP -t 'sudo docker ps'

SSH into container to get the daemon container IP address.

1ssh launcher@YOURSERVERIP -t 'sudo docker inspect stats.yourdomain.com-daemon-1ee049e0-9ec6-40ba-ac0a-c81da43098e1'

Edit your Nginx site config to proxy the traffic and add this location block as shown below, and redeploy the site.

1location / {
2 proxy_pass http://172.18.0.23:3000;
3 proxy_set_header Host $host;
4 proxy_set_header X-Real-IP $remote_addr;
5 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
6}

Now Umami is accesible at https://stats.yourdomain.com, and you can log in using admin/umami and change your password.