Skip to content

Commit

Permalink
Very first images for testing - looks like a problem exist with the B…
Browse files Browse the repository at this point in the history
…roker!
  • Loading branch information
mohierf committed Dec 24, 2019
1 parent d281361 commit 8675cf6
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 39 deletions.
1 change: 1 addition & 0 deletions docker/.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SHINKEN_UI_GRAPHITE_GIT_REPO=mohierf/mod-ui-graphite
ALIGNAK_DATADIR=./data/alignak

# In the container
ALIGNAK_SHARE_DIR=/alignak
ALIGNAK_LOG_DIR=/alignak/log
ALIGNAK_RUN_DIR=/alignak/run
ALIGNAK_ETC_DIR=/alignak/etc
Expand Down
83 changes: 83 additions & 0 deletions docker/.env.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
PYTHON_BASE_VERSION=3.6
ALIGNAK_IMAGE_TAG=0.0.1

DOCKER_REPOSITORY=alignak
DOCKER_SERVICE=alignak
DOCKER_SERVICE_UI=alignak-ui

ALIGNAK_GIT_REPO=Alignak-monitoring/alignak
SHINKEN_WEBUI_GIT_REPO=mohierf/mod-webui
SHINKEN_UI_GRAPHITE_GIT_REPO=mohierf/mod-ui-graphite

# Shared with the host
ALIGNAK_DATADIR=./data/alignak

# In the container
ALIGNAK_SHARE_DIR=/alignak
ALIGNAK_LOG_DIR=/alignak/log
ALIGNAK_RUN_DIR=/alignak/run
ALIGNAK_ETC_DIR=/alignak/etc
ALIGNAK_CONFIGURATION_FILE=/alignak/etc/alignak.ini

####################
# Alignak configuration
####################
# Use Shinken Web UI as the Alignak UI
ALIGNAK_SHINKEN_UI=yes
SHINKEN_UI_DEBUG=yes

# Alignak retention module configuration
# Override module configuration file!
ALIGNAK_RETENTION_DIR=/alignak/retention

# Alignak logging more information
#ALIGNAK_LOG_ACTIONS=WARNING
#ALIGNAK_LOG_ALERTS=WARNING
#ALIGNAK_LOG_CHECKS=1
#ALIGNAK_LOG_ACTIVITY=3600

####################
# Graphite configuration
####################
GRAPHITE_DATADIR=./data/graphite

# Tuning - much more is available, see: https://github.com/graphite-project/docker-graphite-statsd
GRAPHITE_WSGI_PROCESSES=4
GRAPHITE_WSGI_THREADS=2
GRAPHITE_WSGI_REQUEST_TIMEOUT=65
GRAPHITE_WSGI_MAX_REQUESTS=1000
GRAPHITE_WSGI_REQUEST_LINE=0

# Log
GRAPHITE_LOG_ROTATION=true
GRAPHITE_LOG_ROTATION_COUNT=1
GRAPHITE_LOG_RENDERING_PERFORMANCE=true
GRAPHITE_LOG_CACHE_PERFORMANCE=true

GRAPHITE_DEBUG=false

COLLECTD=1

####################
# MongoDB variables
####################
MONGO_DATADIR=./data/mongodb

# Create a super-user on first database launch
# Disabled!
MONGO_INITDB_ROOT_USERNAME=
MONGO_INITDB_ROOT_PASSWORD=
# Database selected for startup scripts
MONGO_INITDB_DATABASE=alignak

####################
# Mongo express configuration
####################
ME_CONFIG_MONGODB_SERVER=mongodb
ME_CONFIG_MONGODB_ENABLE_ADMIN=true
# Disabled!
ME_CONFIG_MONGODB_ADMINUSERNAME=
ME_CONFIG_MONGODB_ADMINPASSWORD=
ME_CONFIG_OPTIONS_EDITORTHEME=ambiance
ME_CONFIG_BASICAUTH_USERNAME=admin
ME_CONFIG_BASICAUTH_PASSWORD=admin
15 changes: 8 additions & 7 deletions docker/Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!make
# Specify a shell
SHELL := /bin/bash

.PHONY: help

# Get the environment variables
$(shell cp .env.dist .env)
include .env

ifndef DOCKER_TAG
$(info The image TAG variable (DOCKER_TAG) is missing. Setting a default value!)
ifndef ALIGNAK_IMAGE_TAG
$(error The image TAG variable (ALIGNAK_IMAGE_TAG) is missing.)
endif

# Default values for the image
PYTHON_VERSION ?= 3.6
DOCKER_TAG ?= 0.0.0
PYTHON_BASE_VERSION ?= 3.6
DOCKER_REPOSITORY ?= alignak
DOCKER_ALIGNAK_DAEMON ?= alignak
DOCKER_ALIGNAK_WEBUI ?= alignak-ui
Expand All @@ -34,7 +35,7 @@ help: banner
# --------------------
banner: ## This help message
@echo -e "--------------------"
@echo -e "\x1b[36mImage\x1b[m:$(DOCKER_IMAGE):$(DOCKER_TAG)" | column -c2 -t -s :
@echo -e "\x1b[36mImage\x1b[m:$(DOCKER_IMAGE):$(ALIGNAK_IMAGE_TAG)" | column -c2 -t -s :
@echo -e "--------------------"

build: banner ## Build the image
Expand Down Expand Up @@ -68,8 +69,8 @@ check: banner ## Check the Alignak configuration
docker-compose run arbiter-master alignak-arbiter -V -e $(ALIGNAK_CONFIGURATION_FILE)

push: banner login ## Push the image to the repository
$(info Pushing "$(DOCKER_IMAGE)":"$(DOCKER_TAG)" tagged image.)
@docker push $(DOCKER_IMAGE):$(DOCKER_TAG)
$(info Pushing "$(DOCKER_IMAGE)":"$(ALIGNAK_IMAGE_TAG)" tagged image.)
@docker push $(DOCKER_IMAGE):$(ALIGNAK_IMAGE_TAG)

pull: banner ## Pull the image
$(info Pulling "$(DOCKER_TAG)" tagged image.)
Expand Down
44 changes: 30 additions & 14 deletions docker/README
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
# Docker Alignak

To be completed...
A GNU makefile exists to help for the most common operations with Alignak Docker images.

The Makefile includes the *.env* file existing in the current directory.

Note: If the *.env* file does not exist, running make will copy the default *.env.dist* file to a new *.env* file.

## Using the makefile

```bash

# View all the available targets + doc
make

# Build the images
make build
# This will build the images according to the values defined in the .env file

# Clean extra unused images
make clean

# Push an image to your repository
# Direct
TAG=0.0.1 DOCKER_USER=username DOCKER_PASS=password make push

export TAG=0.0.1
export DOCKER_USER=username
export DOCKER_PASS=password
make push
```

## Build and run
You can also use usual docker-compose to build the Alignak images:

```bash
docker-compose build
Expand All @@ -21,20 +51,6 @@ Check the Alignak configuration:
make check
```

## Using the makefile

```bash

# Push an image to your repository
# Direct
TAG=0.0.1 DOCKER_USER=username DOCKER_PASS=password make push

export TAG=0.0.1
export DOCKER_USER=username
export DOCKER_PASS=password
make push
```

## Metrics and Graphite

View https://github.com/graphite-project/docker-graphite-statsd
Expand Down
2 changes: 1 addition & 1 deletion docker/data/alignak/etc/alignak.d/extra-alignak.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[DEFAULT]
_dist=/tmp/alignak
_dist=/alignak
_dist_BIN=/usr/local/bin
_dist_ETC=%(_dist)s/etc
_dist_VAR=%(_dist)s/plugins
Expand Down
46 changes: 42 additions & 4 deletions docker/data/alignak/etc/alignak.ini
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bindir=%(_dist_BIN)s
; ----------
; This is the name used for this configuration
; The only purpose of this variable is to make it easier to search in the system log
config_name=Alignak global configuration
config_name=Alignak configuration

; Alignak instance name
; ----------
Expand Down Expand Up @@ -109,8 +109,10 @@ alignak_name=My Alignak
; ----------
; Python logger configuration file
; Default is to get this file in the same directory as the alignak.ini
;logger_configuration=DEFAULT
; is the same as
;logger_configuration=./alignak-logger.json
; This will set the daemon log file
; This file will configure the daemon log and monitoring events loggers
; --------------------------------------------------------------------

; --------------------------------------------------------------------
Expand Down Expand Up @@ -152,11 +154,20 @@ alignak_name=My Alignak
;idontcareaboutsecurity=0

; Log file
; The daemon log file is configured according to the Python logger but it is
; The daemon log file is configured according to the Alignak Python logger but it is
; still possible to override this...
;log_filename=%(workdir)s/daemon.log
; Same for the log_level
; Same for the log_level. Default is to use the global log level
;log_level=
; and some other self-explanatory parameters.
; Those parameters and the log_level are not used except if the former log_filename is set.
; log_filename and log_level may be overriden on the daemon command line
;log_rotation_when=midnight
;log_rotation_interval=1
;log_rotation_count=7
;log_format[%%(asctime)s] %%(levelname)s: [%%(name)s] %%(message)s
;log_date=%%Y-%%m-%%d %%H:%%M:%%S
# !!! Note that the % sign must be written as %%

; Include the CherryPy daemon HTTP server log in the daemon log file
; This is interesting if you want many many details about the daemons inter-communication
Expand Down Expand Up @@ -543,6 +554,22 @@ $NRPE_PLUGINS_DIR$=$NAGIOSPLUGINSDIR$
; ---
; Monitoring events log default configuration
; --------------------------------------------------------------------
; Log file
; The daemon log file is configured according to the Alignak Python logger but it is
; still possible to override this...
;log_filename=%(workdir)s/daemon.log
; Same for the log_level. Default is to use the global log level
;log_level=
; and some other self-explanatory parameters.
; Those parameters and the log_level are not used except if the former log_filename is set.
; log_filename and log_level may be overriden on the daemon command line
;log_rotation_when=midnight
;log_rotation_interval=1
;log_rotation_count=365
;log_format[%%(my_date)s] %%(levelname)s: %%(message)s
;log_date=%%Y-%%m-%%d %%H:%%M:%%S
# !!! Note that the % sign must be written as %%

; Notifications
;log_notifications=1

Expand Down Expand Up @@ -701,3 +728,14 @@ retention_update_interval=60
;tick_send_broks_to_modules=1
;tick_get_objects_from_from_queues=1
;tick_get_latency_average_percentile=10


; --------------------------------------------------------------------
; Some tuning parameters
; --------------------------------------------------------------------
; When set, this parameter makes run the configuration clean once the data are
; ready to be prepared for dispatching to the daemons.
; This may be useful to make the running configuration a bit smaller
; Note that some configuration check information will get lost
; (imported from, configuration warnings, ...)
;clean_objects=0
4 changes: 2 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ services:
# Alignak daemons
# - arbiter
arbiter-master:
image: ${DOCKER_REPOSITORY}/${DOCKER_ALIGNAK_DAEMON}:${DOCKER_TAG}
image: ${DOCKER_REPOSITORY}/${DOCKER_SERVICE}:${ALIGNAK_IMAGE_TAG}
build:
context: ./image-alignak
args:
Expand Down Expand Up @@ -86,7 +86,7 @@ services:

# - broker
broker-master:
image: ${DOCKER_REPOSITORY}/${DOCKER_ALIGNAK_WEBUI}:${DOCKER_TAG}
image: ${DOCKER_REPOSITORY}/${DOCKER_SERVICE_UI}:${ALIGNAK_IMAGE_TAG}
build:
context: image-alignak-ui
args:
Expand Down
13 changes: 11 additions & 2 deletions docker/image-alignak-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
FROM alignak/alignak:0.0.1
ARG ALIGNAK_IMAGE_TAG

LABEL maintainer="Frédéric Mohier ([email protected])"
FROM alignak/alignak:${ALIGNAK_IMAGE_TAG}

ARG ALIGNAK_IMAGE_TAG

ENV ALIGNAK_IMAGE_TAG $ALIGNAK_IMAGE_TAG

LABEL maintainer="Frédéric Mohier ([email protected])" \
alignak.image_type="UI" \
alignak.image.version=$ALIGNAK_IMAGE_TAG \
alignak.python.version=$PYTHON_BASE_VERSION

ENV DEBIAN_FRONTEND noninteractive

Expand Down
14 changes: 13 additions & 1 deletion docker/image-alignak-ui/supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
[supervisord]
nodaemon=true
logfile=/alignak/log/supervisord.log ; supervisord log file
logfile_maxbytes=50MB ; maximum size of logfile before rotation
logfile_backups=10 ; number of backed up logfiles
loglevel=info ; info, debug, warn, trace
pidfile=/alignak/run/supervisord.pid ; pidfile location
nodaemon=true ; do not run supervisord as a daemon
minfds=1024 ; number of startup file descriptors
minprocs=200 ; number of process descriptors
###user=root ; default user
user=alignak


[program:alignak-broker]
user=alignak
command=/usr/local/bin/alignak-broker -n broker-master -e %(ENV_ALIGNAK_CONFIGURATION_FILE)s
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0

[program:nginx]
user=alignak
command=/usr/sbin/nginx
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
Expand Down
10 changes: 4 additions & 6 deletions docker/image-alignak/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ ARG ALIGNAK_IMAGE_TAG
ENV ALIGNAK_IMAGE_TAG $ALIGNAK_IMAGE_TAG
ENV PYTHON_BASE_VERSION $PYTHON_BASE_VERSION

LABEL alignak.image.version=$ALIGNAK_IMAGE_TAG \
LABEL maintainer="Frédéric Mohier ([email protected])" \
alignak.image_type="Generic" \
alignak.image.version=$ALIGNAK_IMAGE_TAG \
alignak.python.version=$PYTHON_BASE_VERSION

LABEL maintainer="Frédéric Mohier ([email protected])"

LABEL alignak.image_type="Generic"

ENV DEBIAN_FRONTEND noninteractive

# Force container timezone
Expand Down Expand Up @@ -64,4 +62,4 @@ RUN chmod 500 /entrypoint.sh

ENTRYPOINT ["/entrypoint.sh"]
# Run the arbiter in check mode for the configuration in the Alignak directory
CMD ["alignak-arbiter", "-V", "-e", "/repos/alignak/etc/alignak.ini" ]
CMD ["alignak-arbiter", "-V", "-e", "/alignak/etc/alignak.ini" ]
8 changes: 6 additions & 2 deletions docker/image-alignak/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash
#!/bin/bash

chown $ALIGNAK_USER:$ALIGNAK_GROUP $ALIGNAK_SHARE_DIR
ALIGNAK_SHARE_DIR=${ALIGNAK_SHARE_DIR:-/alignak}
ALIGNAK_USER=${ALIGNAK_USER:-alignak}
ALIGNAK_GROUP=${ALIGNAK_GROUP:-alignak}

chown -R $ALIGNAK_USER:$ALIGNAK_GROUP $ALIGNAK_SHARE_DIR
chmod -R 775 $ALIGNAK_SHARE_DIR

echo $@ > /cmd
Expand Down

0 comments on commit 8675cf6

Please sign in to comment.