Skip to content

johnfmorton/plausible-with-traefik-update-for-laravel-forge

 
 

Repository files navigation

Plausible Analytics hosting for Laravel Forge using Traefik

Laravel Forge Site Deployment Status

This repo is a fork of Plausible's hosting repo,https://github.com/plausible/hosting.

It contains modifications to the original repo to make it work with Laravel Forge and Traefik. Modifications are primarily in the /reverse-proxy/traefik/docker-compose.traefik.yml file. There are a few changes in the main docker-compose.yml file to use .env for environmental variables. Using the .env file allows you to use Laravel Forge's built-in environmental variables editor. I've also removed exposing ports that were not needed when using Traefik.

The clickhouse/clickhouse-config.xml file has been modified from the original to allow the included backup scripts to work.

Here is a link to the Traefik repo used in conjunction with this repo:

https://github.com/johnfmorton/traefik-for-laravel-forge

The accompanying blog post

For a complete write-up on using this repo, read Analytics a different way. Plausible Analytics on Laravel Forge with Traefik and Docker.

Laravel Forge preparation

The repo assumes you have Docker installed already. See the johnfmorton/traefik-for-laravel-forge repo for more information.

DNS setup

You will need to set up DNS to point your domain name with an A record to your server you've created with Laravel Forge. For example, analytics.yourdomain.com should point to your server's IP address.

Setting up the .env file

In the .env file, set BASE_URL to this domain name. For example, https://analytics.yourdomain.com. You must include the protocol, either https:// or http:// is required by Plausible for this setting.

Use the example.env for reference in setting up the additional environmental variables.

Laravel Forge Deployment script

Here is a basic version of the deployment script.

cd /home/forge/analytics

git pull origin $FORGE_SITE_BRANCH

docker-compose -f docker-compose.yml -f reverse-proxy/traefik/docker-compose.traefik.yml up -d -remove-orphans

For a more complete version of the deployment script, see the forge-deployment-script.sh file in this repo.

Reference links

I referenced and borrowed from all of the following links. I'm grateful the authors have all shared their knowledge.

Troubleshooting

During my tests of this repo, I ran into a few issues. I would test building and deploying contains from the command line and also from with the Forge control panel. This caused my server to have a lot of containers and images. I had to remove them a few times.

I'm documenting them here in case they are helpful to others.

I pruned the networks, images and containers on my server like this.

docker network prune
docker image prune
docker container prune

At one point, I needed to stop all the containers so I could start everything again from scratch. Here's how to do that.

docker stop $(docker ps -aq)

License

The source code for the site is licensed under the MIT license, which you can find in the MIT-LICENSE.txt file.

About

A docker-compose setup for hosting Plausible Analytics with Traefik update.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%