2023-06-24 23:37:35 +02:00
# FIXME
2023-06-24 23:27:59 +02:00
2023-06-24 23:37:35 +02:00
Search and replace all mentions of FIXME with sensible content in this file and in [docker-compose.yml ](docker-compose.yml ).
2023-06-24 23:27:59 +02:00
2023-06-12 01:29:22 +02:00
# Grafana Docker Compose files
2023-06-24 23:37:35 +02:00
Docker Compose files to spin up an instance of Grafana FIXME capitalization FIXME.
2023-06-12 01:29:22 +02:00
# How to run
Add a `COMPOSE_ENV` file and save its location as a shell variable along with the location where this repo lives, here for example `/opt/containers/grafana` plus all other variables. At [env/fqdn_context.env.example ](env/fqdn_context.env.example ) you'll find an example environment file.
When everything's ready start Grafana with Docker Compose, otherwise head down to [Initial setup ](#initial-setup ) first.
## Environment
```
export COMPOSE_DIR='/opt/containers/grafana'
2023-06-14 22:11:04 +02:00
export COMPOSE_CTX='ux_vilnius'
2023-06-12 01:29:22 +02:00
export COMPOSE_PROJECT='grafana-'"${COMPOSE_CTX}"
export COMPOSE_FILE="${COMPOSE_DIR}"'/docker-compose.yml'
export COMPOSE_ENV=< add accordingly >
```
2023-06-21 00:27:23 +02:00
## Context
On your deployment machine create the necessary Docker context to connect to and control the Docker daemon on whatever target host you'll be using, for example:
```
docker context create fully.qualified.domain.name --docker 'host=ssh://root@fully .qualified.domain.name'
```
2023-06-24 23:36:59 +02:00
## Pull
Pull images from Docker Hub verbatim.
```
docker compose --project-name "${COMPOSE_PROJECT}" --file "${COMPOSE_FILE}" --env-file "${COMPOSE_ENV}" --profile 'full' pull
```
2023-06-12 01:29:22 +02:00
## Start
```
2023-06-21 00:27:23 +02:00
docker --context 'fully.qualified.domain.name' compose --project-name "${COMPOSE_PROJECT}" --file "${COMPOSE_FILE}" --env-file "${COMPOSE_ENV}" --profile 'full' up --detach
2023-06-12 01:29:22 +02:00
```
# Initial setup
We're assuming you run Docker Compose workloads with ZFS-based bind mounts. ZFS management, creating a zpool and setting adequate properties for its datasets is out of scope of this document.
## Datasets
Create ZFS datasets and set permissions as needed.
* Parent dateset
```
zfs create -o mountpoint=/opt/docker-data 'zpool/docker-data'
```
* Container-specific datasets
```
2023-06-14 22:11:04 +02:00
zfs create -p 'zpool/docker-data/grafana-'"${COMPOSE_CTX}"'/grafana/data/db'
zfs create -p 'zpool/docker-data/grafana-'"${COMPOSE_CTX}"'/grafana/data/logs'
zfs create -p 'zpool/docker-data/grafana-'"${COMPOSE_CTX}"'/grafana/config'
zfs create -p 'zpool/docker-data/grafana-'"${COMPOSE_CTX}"'/nginx/data/db'
zfs create -p 'zpool/docker-data/grafana-'"${COMPOSE_CTX}"'/nginx/data/logs'
zfs create -p 'zpool/docker-data/grafana-'"${COMPOSE_CTX}"'/nginx/config'
2023-06-12 01:29:22 +02:00
```
2023-06-24 23:37:35 +02:00
FIXME delete when all is done FIXME When changing bind mount locations to real ones remember to also update `volumes:` in [docker-compose.yml ](docker-compose.yml ).
2023-06-12 01:29:22 +02:00
2023-06-14 22:11:04 +02:00
* Create subdirs
```
mkdir -p '/opt/docker-data/grafana-'"${COMPOSE_CTX}"'/grafana/'{'.ssh','config','data','projects'}
```
2023-06-12 01:29:22 +02:00
* Change ownership
```
2023-06-24 23:01:00 +02:00
chown -R 1000:1000 '/opt/docker-data/grafana-${COMPOSE_CTX}/grafana/data/'{*,.*}
2023-06-12 01:29:22 +02:00
```
2023-06-14 22:11:04 +02:00
## Additional files
Place the following files on target server. Use the directory structure at [build-context ](build-context ) as a guide, specifically at `docker-data` .
2023-06-24 23:37:35 +02:00
FIXME Add details about files that aren't self-explanatory FIXME
2023-06-24 23:27:59 +02:00
2023-06-14 22:11:04 +02:00
```
build-context/
├── grafana
│ ├── docker-data
│ | └── config
│ │ └── grafana.cfg
│ ├── Dockerfile
│ └── extras
└── nginx
├── docker-data
| └── config
│ └── nginx.cfg
├── Dockerfile
└── extras
```
2023-06-12 01:29:22 +02:00
When done head back up to [How to run ](#how-to-run ).