# Installtion

# Installation via Docker

### Beschreibung

Kimai via Docker mit https via Letsencrypt.

### Installation

#### Vorbereitung

Sollte Apparmor enabled sein, wie das bei hetzner der Fall ist dann noch eben die Apparmor Pakete installieren

```
apt-get install apparmor apparmor-utils curl docker.io docker-compose
```

Als erstes erstellen wir unsere Verzeichnisse

```
mkdir -p /root/kimai/mariadb
mkdir -p /root/kimai/data
mkdir -p /root/kimai/plugins
```

Nun erstellen wir im Verzeichnis /root/kimai eine neue Datei namens .env

```
nano /root/kimai/.env
```

Inhalt:

```
# MySQL Credentials
MYSQL_ROOT_PASSWORD=12345678
MYSQL_USER=kimai
MYSQL_PASSWORD=1234567890
MYSQL_DATABASE=kimai

# Volume directories
MARIADB_VOLUME_DIR=/root/kimai/mariadb
DATA_VOLUME_DIR=/root/kimai/data

```

#### Docker-compose Datei erstellen

```
nano /root/kimai/docker-compose.yml
```

Inhalt

```
ersion: '3.3'

services:
  mariadb:
    image: mariadb:latest
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_USER: ${MYSQL_USER}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE}
    volumes:
      - ${MARIADB_VOLUME_DIR}:/var/lib/mysql

  kimai:
    image: kimai/kimai2:apache
    restart: unless-stopped
    environment:
      - DATABASE_URL=mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@mariadb/${MYSQL_DATABASE}
    volumes:
      - ${DATA_VOLUME_DIR}:/opt/kimai/var
      - ./plugins:/opt/kimai/var/plugins

  caddy:
    image: caddy:latest
    container_name: caddy-reverse-proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./caddy_data:/data
      - ./caddy_config:/config
    restart: unless-stopped

```

Nun Caddyfile erstellen

```
nano /root/kimai/Caddyfile
```

Inhalt

```
zeit.example.tld {
    reverse_proxy http://kimai:8001
    tls info@example.tld {
        #ca https://acme-staging-v02.api.letsencrypt.org/directory
    }
}

```

Nun sicher stellen das die ports 80 und 443 auch über die Domain auf den Server erreichbar sind.

hier ein kleines Script das auf den port 80 lauscht um dies zu testen

```
nano /root/kimai/testeweb.sh
```

Inhalt

```
#!/bin/bash

# Funktion, die aufgerufen wird, wenn das Skript ein SIGINT-Signal (Ctrl+C) empfängt
cleanup() {
    echo "Server wird beendet..."
    exit 0
}

# Trap für das SIGINT-Signal einrichten
trap cleanup SIGINT

# Endlosschleife für den Server
while true; do
    # Listen on port 80
    { echo -ne "HTTP/1.1 200 OK\r\nContent-Length: $(echo -n "Hello, World!" | wc -c)\r\n\r\nHello, World!"; } | nc -l -p 80 -q 1
done

```

Danach ausführbar machen

```
chmod +x /root/kimai/testeweb.sh
```

nun das Script starten, kann mit strg+c wieder abgebrochen werden.   
Nun kann getestet werden ob Firewall/Portforwarding richtig funktioniert, idem in einem Webbrowser die public ip aufegrufen wird.  
Es muss eine hello World Seite zurück gegben werden.

Container Starten

Ins kimai Verzeichnis gehen

```
cd /root/kimai
```

Nun den Conatiner starten

```
 docker-compose up -d 
```

#### Benutzer anlegen

##### Die Rollen

<table class="table" id="bkmrk-role-name-descriptio"><thead><tr><th>Role name</th><th>Description</th></tr></thead><tbody><tr><td>User</td><td>Normal user can track their working times, see basic reports and change their own preferences. Technical name: `ROLE_USER`</td></tr><tr><td>Teamlead</td><td>Manages [teams](https://www.kimai.org/documentation/teams.html) with permissions for invoices and access to all **team** timesheets. Technical name: `ROLE_TEAMLEAD`</td></tr><tr><td>Administrator</td><td>Can manage all content and timesheet related data, but lack user administration and system privileges. Technical name: `ROLE_ADMIN`</td></tr><tr><td>System-Admin</td><td>Has permissions to manage everything in Kimai, from content to timesheets to users, plugins and system configurations. Technical name: `ROLE_SUPER_ADMIN`</td></tr></tbody></table>

```
die container id mit docker ps herausfinden

docker exec -ti <containerid> \
         /opt/kimai/bin/console kimai:user:create <username> <emailadresse> ROLE_SUPER_ADMIN

Beispiel:

docker exec -ti 32da986c57c2 \
         /opt/kimai/bin/console kimai:user:create admin admin@example.com ROLE_SUPER_ADMIN
         
Dann kann ein Kennwort vergeben werden. Muss mindestens 8 Zeichen haben

```

#### Benutzer Passwort ändern  


```
die container id mit docker ps herausfinden

docker exec -ti <containerid> \
         /opt/kimai/bin/console kimai:user:password <username> 

Beispiel:

docker exec -ti 32da986c57c2 \
         /opt/kimai/bin/console kimai:user:password admin 
         
Dann kann ein neues Kennwort vergeben werden. Muss mindestens 8 Zeichen haben

```

####   

# Mobile App

### Beschreibung:

Für Kimai gibt es auch eine Mobile App.

Aus dem AppStore die Mobile App installieren:

iOS [link zum Store](https://apps.apple.com/us/app/kimai-mobile/id1563933145)

Android [Link zum Store](https://play.google.com/store/apps/details?id=de.cloudrizon.kimaimobile)

### Benutzer freischalten im Kimai Backend.

Damit sich der Benutzer anmelden kann, muss in den Benutzereinstellungen ein APi Passwort (Nicht Token) hinterlegt werden.  
Beim Passwort kommt der Hinweis das diese methode veraltet ist, aber die Mobil App nutzt zur zeit nur Passwort.

Dazu gehen wir Auf System -&gt; Benutzer

[![Auswahl_1229.png](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/scaled-1680-/9DMDBsOX8zgtBR7U-auswahl-1229.png)](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/9DMDBsOX8zgtBR7U-auswahl-1229.png)

Dann den benutzer anklicken, für den wir das API Passwort erstellen wollen

[![Auswahl_1230.png](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/scaled-1680-/XkKf3o45FG0Nsv93-auswahl-1230.png)](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/XkKf3o45FG0Nsv93-auswahl-1230.png)Dort dann oben auf bearbeiten klicken und API Zugang auswählen

[![Menü_014.png](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/scaled-1680-/rjglURguvaYMWc7E-menu-014.png)](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/rjglURguvaYMWc7E-menu-014.png)

Nun das neue Kennwort setzten und speichern.

### [![Auswahl_1231.png](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/scaled-1680-/Ya89fDaHkEKh1KMA-auswahl-1231.png)](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/Ya89fDaHkEKh1KMA-auswahl-1231.png)  
Einloggen auf der Mobile App

Create Workspace anklicken.

Daten ausfüllen.

Workspace Name, zum Beispiel Firmenname.  
Server URL : die Kimai Seite [https://vorweg](https://vorweg) schreiben  
Die APP Funktioniert nur über https

Email / Username : den Benutzernamen eintragen  
Password: Das API Kennwort

Nun auf Create a new Workspace klicken.

[![Screenshot_2024-07-08-13-00-22-26_f1c6ba619212653817d1dec5c2916048.jpg](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/scaled-1680-/fDxitAYithsyhVCp-screenshot-2024-07-08-13-00-22-26-f1c6ba619212653817d1dec5c2916048.jpg)](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/fDxitAYithsyhVCp-screenshot-2024-07-08-13-00-22-26-f1c6ba619212653817d1dec5c2916048.jpg)

Und eingeloggt:

[![Screenshot_2024-07-08-13-02-40-71_f1c6ba619212653817d1dec5c2916048.jpg](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/scaled-1680-/rToTgEBm7cpWdzVp-screenshot-2024-07-08-13-02-40-71-f1c6ba619212653817d1dec5c2916048.jpg)](https://wiki.hacker-net.de/uploads/images/gallery/2024-07/rToTgEBm7cpWdzVp-screenshot-2024-07-08-13-02-40-71-f1c6ba619212653817d1dec5c2916048.jpg)