Application Support and ITIL with Hesk and Docker

Application Support and ITIL with Hesk and Docker

scotty profile picture

Scotty Parlor

Aug. 15, 2022

Read Time 22 min

 

Often times, the things I am relaying on this blog are directly tied to things I am studying for my real job. When I came across this job listing, it was directly in line with the current certification I am pursuing: Axelos ITIL Foundation v4. The hints in this job description are almost too obvious! Let’s take a look (check out the corresponding video for this to see me analyze this in detail).

 

As you can see, almost every single item in the responsibilities section is directly referencing ITIL practices.

 

The obvious line is at the very bottom where it gives it all away!

 

Tutorial Requirements

  1. Docker and Docker-compose
  2. Basic understanding of the linux command line

 

It is not a requirement, but I highly recommend picking up a copy of the Axelo’s ITIL Foundation v4 book if you are wanting to make that certification a part of your career portfolio.

 

1.) Downloading Hesk Files

Since this is an ITIL service management focused tutorial, and we want to be able to store this as a project in GitHub, I wanted to use a free, downloadable service desk to build on the fly with Docker. Head over to https://www.hesk.com/download.php and download the zip. Then, extract them into the root of your project directory.

 

2.) Creating the Dockerfile and docker-compose.yml

    In the root directory with the hesk files, let’s create our base dockerfile and docker-compose.yml so anyone can build this.

code dockerfile docker-compose.yml

 

Now inside the dockerfile, add the following:

FROM ubuntu:xenial
ENV DEBIAN_FRONTEND=noninteractive
WORKDIR /public_html

COPY . .
EXPOSE 8000

 

And add the following for the docker-compose.yml:

version: '3'
services:
  db:
    build: .
    tty: true
    ports:
      - "8000:8000"
    volumes:
      - type: bind
        source: ./data
        target: /public_html/data
    entrypoint: "./scripts/entrypoint.sh"

 

The key things to note here are:

  1. Port binding to 8000
  2. Binding a volume on the data directory so that we can base data from the container back to our local (you will see why I need this)
  3. And finally, and entrypoint script that we will write next. Let’s save those and move on.

 

Before moving on, create the data directory in the root of the project

mkdir data

3.) Entrypoint.sh

For organizational purposes, let’s create a new directory in the root called “scripts” and place our entrypoint there.

mkdir scripts
code scripts/entrypoint.sh

 

Inside this entrypoint, we want to install our dependencies with apt, start mysql service, and start the very simple php server. Note: With this install, I am NOT giving the root user to the database a password. Obviously this is terrible in real life, but for the sake of this tutorial lets leave it as is. Just keep that in mind…

 

Add the contents to the entrypoint.sh

#!/bin/bash
apt update && apt install php php-mysql mysql-server -y
service mysql start
mysql --user=root --execute="CREATE DATABASE hesk;"
php -S 0.0.0.0:8000

 

Save that and then chmod it

chmod +x scripts/entrypoint.sh

 

4.) Recruiter Dashboard creation

    Hesk was ultimately pretty easy to set up based on their documentation. For our purposes of showcasing this to an audience (i.e. recruiter or manager), we will want to get creative regarding project setup and ease of use for our end user.

 

Before we dive into Hesk, let me quickly explain the thought behind what we are about to do.

 

  1. We need to setup Hesk and make sure the the product is ready to be used by an end user, in our case a potential employer.
     
  2. Since everything is in docker and not in the cloud, we are going to need to setup the database now, dump it, and then make it ridiculously easy for a potentially non-technical person to use.
     
  3. To accomplish this, we are going to want to make a custom dashboard to add to Hesk to do the dump, restore, and some other minor functions specific to Hesk.
     

So let’s start by quickly creating the custom dashboard and then setting up Hesk for the first time.

 

In the root project directory, create a new file called dash.php. Please read the comments to help you understand what’s going on!

<?php

// This function is an easy way for the end user to delete the install directory (a requirement of Hesk after setup)
    function remove_install() {
        shell_exec("rm -r install");
    }

// The dump function will be used to dump our database and place it into the bound data volume (specified in docker-compose.yml)
    function dump() {
        shell_exec("mysqldump -u root hesk > /public_html/data/dump.sql && cp /public_html/hesk_settings.inc.php /public_html/data");
    }
// The restore function will restore the dump.sql file found in the data volume.
    function restore() {
        shell_exec("mysql -u root hesk < /public_html/data/dump.sql && rm -r /public_html/install && cp /public_html/data/hesk_settings.inc.php /public_html");
    }

//The following if statements will execute the functions as supplied by the links at the bottom of this document.
    if (isset($_GET['rminstall'])) {
        remove_install();
    } elseif (isset($_GET['dump'])) {
        dump();
    } elseif (isset($_GET['restore'])) {
        restore();
    }
?>

<style>
    body {
        display:flex;
        align-items:center;
        flex-direction:column;
    }
    a {
        padding:2rem;
        width:10rem;
        text-align:center;
        margin:1rem;
        border:1px solid gray;
        color:black;
        text-decoration: none;
    }
</style>

<!-- The following anchors will provide a streamlined way for the end user to execute the required commands without needing technical knowledge -->

<a href="?dump=true">Dump Database</a>
<a href="dash.php?rminstall=true">Remove Install Dir</a>
<a href="?restore=true">Restore Database</a>
<a href="/admin/admin_main.php" target="_blank">Admin</a>

 

Now save that file and let’s quickly create the header before moving on to Hesk specific setup.

 

Hesk is using the header.txt file in the root dir to allow us to add our own code to the project before the body tag. Open that file and place the following there.

<!-- Custom code to be included after <body> tag -->
<a href="/install/install.php">Install</a>
<a href="/dash.php">Demo Dashboard</a>

 

Now save that and let’s build Hesk.

5.) Building and running with docker-compose

    Now that we have everything our docker-compose file requires, we can build Hesk. Run the following in your project root directory:

docker-compose build && docker-compose up &

 

This might take a few minutes so be patient! Once the container is up, move on to the next step.

 

6.) Setting up Hesk

    Once the container is up and healthy, navigate to http://localhost:8000 and you will see the following:

 

 

In the top left of the screen, you should see our custom header. Click Install and perform the following:

 

  1. Read the License agreement and click I ACCEPT
  2. On the next screen, update the database user, password, hesk username and password to:
    1. root
    2. Empty password (since we set it up that way)
    3. admin
    4. welcome

 

 

Then click Continue

 

On the following page you will see more instructions. If you click Skip Directly to Settings you will be prompted to delete the Install directory. That’s where our dashboard comes into play! Sure, you could exec into the pod and rm it…but you are technical! We  have to assume the user reviewing our end product is able to accomplish this setup with ease.

 

Navigate to http://localhost:8000/dash.php 

 

Click Remove Install Dir and then Admin

 

You should’ve opened a new tab and now have access to the Hesk admin panel.

 

7.) Adding KB’s with Examples from the Job Requirements.

In the left panel, select knowledgebase -> Manage and then in the middle box, select New Article

 

 

I am only going to do two of these for you and then I encourage you to spend some time researching and filling out a few more on your own.

 

For the first KB, we are going to call the subject Escalations. In this specific case, the Escalations module in Hesk is only available in the cloud version. So, we cannot really showcase that well here. But still, lets define it and direct the user to the escalations page anyway so they can be aware of the process!


 

 



 

Subject: Escalations

 

Body

 

Axelos ITIL Foundation V4 defines Escalation as:

 

“The act of sharing awareness or transferring ownership of an issue or work item.”

 

Hesk has a dedicated module for escalations in their cloud and paid versions. You can find more information at http://localhost:8000/admin/module_escalate.php

 

This module will help you escalate tickets that are not attended to on time.

  • Tickets not assigned, replied to, or resolved within a timeframe,
  • tickets approaching due date and overdue tickets,
  • automatically change ticket priority, re-assign a ticket, send an email notification,
  • apply rules based on ticket category, owner, status,
  • and much more…

The escalation process here completely revolves around customer service and ticket hygiene.

 

 


Save that entry and lets start another one!

 

 


Subject: Incident Management

Body: The following is from Axelos ITIL Foundation V4 and not my own words.

Incident = an unplanned interruption to a service or reduction in the quality of a service.

The purpose of the incident management practice is to minimize the negative impact of incidents by restoring normal service operation as quickly as possible.

By gathering specific information about incidents organizations can set priorities and improve the service value chain.

 

 


Those are the only two I will add for now. But go back and read over the requirements and add to what I wrote and add more KB articles!

8.) Dumping our Database

This is one of the final steps to this project. In order for our end user to see all of this informative content we just shared, they will need to restore our database to their newly created one on their own machine.

 

We can do that by heading back over to the tab that contains our dashboard. If you closed the tab, you can find it at http://localhost:8000/dash.php

 

Now click Dump Database

 

On your local, navigate over to the data directory and you should now see two files.
 

  1. dump.sql
  2. hesk_settings.inc.php

 

The dump file contains all of the data and setup you just did, and the php file contains the setup configurations you did in step 6.

 

With those files checked into source control, any user will be able to click Restore Database on your dashboard and have the Hesk Help desk ready to consume.

9.) Final Steps

The project is done at this point. However, you will need to write up Detailed instructions in a Readme file so that users can build your project. I will let you handle that and push this up to your repo, but it should really follow this direction:

 

  1.  Git clone
  2. docker-compose build && docker-compose up &
  3. Navigate to http://localhost:8000/dash.php
  4. Click Restore Database
  5. Click Admin
  6. Navigate to Knowledgebase
  7. Review content

 

Now if you wanted to, you can wipe out your docker container and image and rebuild fresh running through the users workflow to try it all out!

 

I hope you enjoyed this tutorial!