added build docker-compose.yml and instructions

This commit is contained in:
Shihaam Abdul Rahman 2022-09-30 20:19:09 +05:00
parent 01e02541e1
commit d17a3ae40b
Signed by: shihaam
GPG Key ID: 3B007D22E5584980
3 changed files with 49 additions and 46 deletions

View File

@ -7,59 +7,25 @@ Mysql files are mounted at datadir. \
`startservices.sh` contain script to start `zabbix_server`, `nginx` and `php-fpm` `startservices.sh` contain script to start `zabbix_server`, `nginx` and `php-fpm`
## Getting started ## Getting started
### Building
- git clone and cd into git dir - git clone and cd into git dir
- Build zabbix image - Build zabbix image
- cd into configdir and configure according to your set up. - cd into configdir and configure according to your set up.
```bash ```bash
git clone https://gitlab.com/alliedmaldives/ops/zabbix-dockerfile zabbix-docker git clone https://git.shihaam.dev/dockerfiles/zabbix-server.git
cd zabbix-docker cd zabbix-server
docker-compose up -d docker-compose -f docker-compose-build.yml up -d
xdg-open http://localhost:8000 xdg-open http://localhost:8000
``` ```
### Running production
## Running production - Git clone this repo and run `docker compose up -d`
This includes database config \ ```bash
copy paste this in docker-compose.yml \ git clone https://git.shihaam.dev/dockerfiles/zabbix-server.git
run `docker compose up -d` cd zabbix-server
``` docker-compose up -d
version: '3.5'
services:
#########################
zabbix:
image: git.shihaam.dev/dockerfiles/zabbix-server
volumes:
- $PWD/configdir/etc/zabbix/zabbix_server.conf:/etc/zabbix/zabbix_server.conf
- $PWD/configdir/etc/zabbix/nginx.conf:/etc/zabbix/nginx.conf
- $PWD/configdir/etc/zabbix/web/zabbix.conf.php:/etc/zabbix/web/zabbix.conf.php
- $PWD/configdir/etc/php/7.4/fpm/php-fpm.conf:/etc/php/7.4/fpm/php-fpm.conf
- $PWD/datadir/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts
- $PWD/datadir/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts
ports:
- 8000:80
- 10051:10051
restart: always
#########################
db:
image: mysql:8
environment:
MYSQL_DATABASE: zabbix
MYSQL_USER: zabbix
MYSQL_PASSWORD: zabbix
MYSQL_ALLOW_EMPTY_PASSWORD: true
command:
- mysqld
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_bin
- --skip-character-set-client-handshake
- --default-authentication-plugin=mysql_native_password
volumes:
- $PWD/configdir/init/init.db:/docker-entrypoint-initdb.d
- $PWD/datadir/mysql:/var/lib/mysql
restart: always
depends_on:
- zabbix
``` ```
- You will have Zabbix frontent avaible on port 8009
## To-do ## To-do
- mount all needed config dirs outside container. (currently only basic configs are there) - mount all needed config dirs outside container. (currently only basic configs are there)

17
docker-compose-build.yml Normal file
View File

@ -0,0 +1,17 @@
version: '3.5'
services:
#########################
zabbix:
build: .
image: git.shihaam.dev/dockerfiles/zabbix-server
volumes:
- $PWD/configdir/etc/zabbix/zabbix_server.conf:/etc/zabbix/zabbix_server.conf
- $PWD/configdir/etc/zabbix/nginx.conf:/etc/zabbix/nginx.conf
- $PWD/configdir/etc/zabbix/web/zabbix.conf.php:/etc/zabbix/web/zabbix.conf.php
- $PWD/configdir/etc/php/7.4/fpm/php-fpm.conf:/etc/php/7.4/fpm/php-fpm.conf
- $PWD/datadir/usr/lib/zabbix/externalscripts:/usr/lib/zabbix/externalscripts
- $PWD/datadir/usr/lib/zabbix/alertscripts:/usr/lib/zabbix/alertscripts
ports:
- 8000:80
- 10051:10051
restart: always

View File

@ -2,7 +2,6 @@ version: '3.5'
services: services:
######################### #########################
zabbix: zabbix:
build: .
image: git.shihaam.dev/dockerfiles/zabbix-server image: git.shihaam.dev/dockerfiles/zabbix-server
volumes: volumes:
- $PWD/configdir/etc/zabbix/zabbix_server.conf:/etc/zabbix/zabbix_server.conf - $PWD/configdir/etc/zabbix/zabbix_server.conf:/etc/zabbix/zabbix_server.conf
@ -15,3 +14,24 @@ services:
- 8000:80 - 8000:80
- 10051:10051 - 10051:10051
restart: always restart: always
#########################
db:
image: mysql:8
environment:
MYSQL_DATABASE: zabbix
MYSQL_USER: zabbix
MYSQL_PASSWORD: zabbix
MYSQL_ALLOW_EMPTY_PASSWORD: true
command:
- mysqld
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_bin
- --skip-character-set-client-handshake
- --default-authentication-plugin=mysql_native_password
volumes:
- $PWD/configdir/init/init.db:/docker-entrypoint-initdb.d
- $PWD/datadir/mysql:/var/lib/mysql
restart: always
depends_on:
- zabbix