How to Install Cachet on Docker with Vultr's Marketplace App

Updated on November 21, 2023
How to Install Cachet on Docker with Vultr's Marketplace App header image

Introduction

Cachet is the free and open source status page for your API, service or company. Built with all of the features that you'd expect from a status page, Cachet comes with a powerful API, a metric system, multiple user support, two factor authentication for added security and is easy to get setup. A powerful, self-hosted alternative to StatusPage.io and Status.io. This article explains how to set up Cachet on a Ubuntu 20.04 x64 server using Vultr's one-click Docker Application and setting up your status page as a subdomain with CaddyServer so that you instantly have SSL enabled.

Install & Configure Prerequisites

  1. Deploy the Docker Application from Vultr Marketplace.

  2. Once your Cloud Server is installed, create an A record at your host that points status.example.com to your Vultr IP address where status.example.com is the domain you want to use for your CachetHQ installation URL.

  3. Login as root and run the following commands.

     $ apt-get update -y
     $ apt-get install git
     $ docker network create caddy

Install CachetHQ

  1. Change into the /home directory.

     $ cd /home
  2. Clone the the CachetHQ repository.

     $ git clone https://github.com/cachethq/Docker.git cachet-docker
  3. Change into the /home/cachet-docker directory

     $ cd cachet-docker
  4. Open the docker-compose.yml file.

     $ nano docker-compose.yml
  5. Look for the following line:

     cachet:
  6. Add container_name: cachet below that line, so it looks like this:

     cachet:
       container_name: cachet
  7. In the environment: section, add - APP_URL=<https://subdomain.example.com> to the end, after - DEBUG=false. When finished, it will look like this:

     environment:
       - DB_DRIVER=pgsql
       - DB_HOST=postgres
       - DB_PORT=5432
       - DB_DATABASE=postgres
       - DB_USERNAME=postgres
       - DB_PASSWORD=postgres
       - DB_PREFIX=chq_
       - APP_KEY=${APP_KEY:-null}
       - APP_LOG=errorlog
       - APP_ENV=${APP_ENV:-production}
       - APP_DEBUG=false
       - DEBUG=false
       - APP_URL=<https://subdomain.example.com>
  8. Add the following section to the end of the file.

     networks:
       default:
         external:
           name: caddy
  9. Save and exit the file. The completed file should look like this:

     version: "3"
    
     services:
       postgres:
         image: postgres:12-alpine
         volumes:
           - /var/lib/postgresql/data
         environment:
           - POSTGRES_USER=postgres
           - POSTGRES_PASSWORD=postgres
         restart: always
       cachet:
         container_name: cachet
         build:
           context: .
         args:
           - cachet_ver=2.4
         ports:
           - 80:8000
         links:
           - postgres:postgres
         environment:
           - DB_DRIVER=pgsql
           - DB_HOST=postgres
           - DB_PORT=5432
           - DB_DATABASE=postgres
           - DB_USERNAME=postgres
           - DB_PASSWORD=postgres
           - DB_PREFIX=chq_
           - APP_KEY=${APP_KEY:-null}
           - APP_LOG=errorlog
           - APP_ENV=${APP_ENV:-production}
           - APP_DEBUG=false
           - DEBUG=false
           - APP_URL=<https://subdomain.example.com>
         depends_on:
           - postgres
         restart: on-failure
         networks:
           default:
             external:
               name: caddy
  10. Open the conf/nginx-site.conf file:

     $ nano conf/nginx-site.conf
  11. Add fastcgi_param HTTPS on; after the fastcgi_keep_conn on; line, so it looks like this:

     fastcgi_keep_conn on;
     fastcgi_param HTTPS on;
  12. Save the file.

  13. Run docker-compose build to build the images.

     $ docker-compose build
  14. Run docker-compose up to start the containers.

     $ docker-compose up
  15. Locate the ERROR line that displays the following error and take note of the APP_KEY given to you.

     cachet_1    | ERROR: Please set the 'APP_KEY=base64:1b3Ni9TaOHdbliYWKPM+bqv7kSJ/BZx7PzAde1yPm+k=' environment variable at runtime or in docker-compose.yml and re-launch
  16. Open the docker-compose.yml file.

     $ nano docker-compose.yml
  17. Locate the APP_KEY variable, which should look like this:

     - APP_KEY=${APP_KEY:-null}
  18. Replace the APP_KEY variable with what was given to you in the ERROR: line after running docker-compose up so it looks like below and save the file:

     - APP_KEY=base64:1b3Ni9TaOHdbliYWKPM+bqv7kSJ/BZx7PzAde1yPm+k=
  19. Run docker-compose build and docker-compose up -d again.

Configure CaddyServer for Auto SSL

  1. Change into the /home directory.

     $ cd /home
  2. Create a new directory called caddy.

     $ mkdir caddy
  3. Change into the /home/caddy directory.

     $ cd caddy
  4. Create a new Caddyfile.

     $ nano Caddyfile
  5. Paste the following contents, replacing the domain with your domain you configured with DNS and save that file:

     status.example.com {
             reverse_proxy cachet:8000
     }
  6. Create a docker-compose.yml file.

     $ nano docker-compose.yml
  7. Paste the following content:

     version: '3.1'
    
     services:
       caddy:
         ports:
           - 443:443
         image: caddy/caddy
         volumes:
           - ./caddy/data:/data
           - ./Caddyfile:/etc/caddy/Caddyfile
     networks:
       default:
         external:
           name: caddy
  8. Run the following command to initalize Caddy to get the certificates:

     $ docker-compose up -d

Configure CachetHQ

In your web browser, navigate to https://status.example.com to start configuring your new Cachet status page.

Lock Down Your Server

  1. Run the following command to open the ssh configuration and change your SSH port to a non-standard port number:

     $ nano /etc/ssh/sshd_config
  2. Locate the following line that reads:

     #Port 22
  3. Uncomment out the line by removing the # symbol and change the port so it looks like this:

     Port 2222
  4. Save the file, update your firewall to accept the new port, and restart the firewall:

     $ ufw allow 2222/tcp
     $ service ssh restart

More Information