initial commit

This commit is contained in:
Peter Leurs 2025-08-15 23:23:00 +02:00
commit 50dcfec65a
5 changed files with 127 additions and 0 deletions

30
appinfo.yml Normal file
View file

@ -0,0 +1,30 @@
mainunit: zabbix-server.service
mainunitfile: zabbix-server.service.j2
ports:
- web
templatefiles:
- src: compose.yml.j2
dest: ~/compose.yml
exports:
web:
sites:
- proxyaddress: "http://127.0.0.1:{{ ports.web }}"
publicname: "{{ config.domainname }}"
configdefinition:
description: Zabbix config
type: object
additionalProperties: false
properties:
domainname:
type: string
description: The url that is used for the site
required:
- domainname
const:
image:
# Zabbix 7 (LTS) can't yet handle postgres 17
postgres: docker.io/library/postgres:16.6
# version 7.0.7 has a bug: https://support.zabbix.com/browse/ZBX-25765
zabbix: docker.io/zabbix/zabbix-server-pgsql:7.0.6-ubuntu
web: docker.io/zabbix/zabbix-web-nginx-pgsql:7.0.6-ubuntu

61
compose.yml.j2 Normal file
View file

@ -0,0 +1,61 @@
version: '3'
# We put everything in a seperate network so it doesn't matter
# that the passwords in this file are simple and known - you can't access it.
networks:
zabbix: {}
services:
postgres-server:
image: {{ const.image.postgres }}
container_name: postgres-server
environment:
- POSTGRES_PASSWORD=postgres
- PGDATA=/data/pgdata
restart: always
volumes:
- {{ homedir }}/data:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
- {{ homedir }}/appdefinition/dbsetup.sh:/docker-entrypoint-initdb.d/dbsetup.sh
healthcheck:
test: psql -U postgres -c "select version();" || exit 1
interval: 5s
timeout: 2s
retries: 3
zabbix:
image: {{ const.image.zabbix }}
container_name: zabbix
restart: always
volumes:
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
environment:
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix
- POSTGRES_DB=zabbix
- DB_SERVER_HOST=postgres-server
- TZ=Europe/Brussels
depends_on:
postgres-server:
condition: service_healthy
restart: true
init: true
web:
image: {{ const.image.web }}
container_name: web
environment:
- POSTGRES_USER=zabbix
- POSTGRES_PASSWORD=zabbix
- POSTGRES_DB=zabbix
- DB_SERVER_HOST=postgres-server
- ZBX_SERVER_HOST=zabbix
- PHP_TZ=Europe/Brussels
- TZ=Europe/Brussels
restart: always
depends_on:
postgres-server:
condition: service_healthy
restart: true
ports:
- '127.0.0.1:{{ ports.web }}:8080'

16
dbsetup.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/bash
set -e
# This file is executed INSIDE the postgres container, but only the very first time
# the database is created. If any side-effects of this script need to be performed
# again, execute into the container and try again. There is no need for authentication
# inside the container, the connection is trusted
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL
CREATE USER zabbix WITH PASSWORD 'zabbix';
CREATE DATABASE zabbix;
GRANT ALL PRIVILEGES ON DATABASE zabbix TO zabbix;
EOSQL
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname zabbix <<-EOSQL
GRANT ALL PRIVILEGES ON SCHEMA public TO zabbix;
EOSQL

3
readme Normal file
View file

@ -0,0 +1,3 @@
Work in progress.
Still needs a ppm template to be added.
Contact me if you're using the project!

17
zabbix-server.service.j2 Normal file
View file

@ -0,0 +1,17 @@
[Unit]
Description=Podman Compose based service
After=network.target
[Service]
Type=exec
# If started incorrectly: stop it first (ie when started without systemd, systemd will know something is started
# and will not do anything when start is called on a unit that already is running)
ExecStartPre=-/usr/bin/podman-compose -f {{ homedir }}/compose.yml down
ExecStartPre={{ ppmbinary }} setup --do-not-enable-units
ExecStart=/usr/bin/podman-compose -f {{ homedir }}/compose.yml up
ExecStop=/usr/bin/podman-compose -f {{ homedir }}/compose.yml down
Restart=always
WorkingDirectory={{ homedir }}
[Install]
WantedBy=default.target