From 4bd764c96f528ff11db8388ffcb8703a23ba3136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Mohier?= Date: Thu, 6 Jun 2019 16:20:22 +0200 Subject: [PATCH] Images for testing - still some improvements --- docker/README | 9 +++-- .../alignak/etc/alignak.d/extra-alignak.ini | 14 ++++++++ .../etc/base/objects/contacts/admin.cfg | 2 +- .../etc/base/objects/contacts/guest.cfg | 2 +- .../etc/base/objects/contacts/notified.cfg | 4 +-- .../etc/base/templates/generic-contact.cfg | 34 ++++++++++--------- docker/image-alignak-ui/Dockerfile | 10 ++++++ docker/image-alignak/Dockerfile | 15 ++++---- 8 files changed, 62 insertions(+), 28 deletions(-) diff --git a/docker/README b/docker/README index 1f04a6e84..5b4c99420 100644 --- a/docker/README +++ b/docker/README @@ -1,13 +1,18 @@ # Docker Alignak -To be completed... +## Host / containers shared volume + +The *data/alignak* directory is shared between the host system and the running containers. + + +## Using the makefile + 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 diff --git a/docker/data/alignak/etc/alignak.d/extra-alignak.ini b/docker/data/alignak/etc/alignak.d/extra-alignak.ini index 655272ed0..fb2cdb306 100755 --- a/docker/data/alignak/etc/alignak.d/extra-alignak.ini +++ b/docker/data/alignak/etc/alignak.d/extra-alignak.ini @@ -6,6 +6,20 @@ _dist_VAR=%(_dist)s/plugins _dist_RUN=%(_dist)s/run _dist_LOG=%(_dist)s/log +; Daemons path configuration +; ---------- +workdir=%(_dist_RUN)s +logdir=%(_dist_LOG)s +etcdir=%(_dist_ETC)s +bindir=%(_dist_BIN)s +vardir=%(_dist_VAR)s + +; Set to try creating the directory if it does not exist +; It will also try to set ownership and permissions for the user account the daemon runs with +; Default is unset +;create_directories=0 +create_directories=1 + # Allow hosts and hostgroups not in the same realm forced_realms_hostgroups=False diff --git a/docker/data/alignak/etc/base/objects/contacts/admin.cfg b/docker/data/alignak/etc/base/objects/contacts/admin.cfg index 4b1e94e5b..5f3e90357 100755 --- a/docker/data/alignak/etc/base/objects/contacts/admin.cfg +++ b/docker/data/alignak/etc/base/objects/contacts/admin.cfg @@ -9,7 +9,7 @@ define contact{ # email alignak@localhost # pager 0600000000 - # Minium business impact - All elements + # Minimum business impact - All elements min_business_impact 0 # Only useful for the UI... diff --git a/docker/data/alignak/etc/base/objects/contacts/guest.cfg b/docker/data/alignak/etc/base/objects/contacts/guest.cfg index 9d9cc87df..a285ffdeb 100755 --- a/docker/data/alignak/etc/base/objects/contacts/guest.cfg +++ b/docker/data/alignak/etc/base/objects/contacts/guest.cfg @@ -8,7 +8,7 @@ define contact{ email guest@localhost - # Minium business impact - Only important elements + # Minimum business impact - Only important elements min_business_impact 3 # Only useful for the UI... diff --git a/docker/data/alignak/etc/base/objects/contacts/notified.cfg b/docker/data/alignak/etc/base/objects/contacts/notified.cfg index 67678b594..93ef54a9b 100755 --- a/docker/data/alignak/etc/base/objects/contacts/notified.cfg +++ b/docker/data/alignak/etc/base/objects/contacts/notified.cfg @@ -5,10 +5,10 @@ define contact{ contact_name notified alias Notified contact - # No notifications for hosts/services + # No notifications for hosts/services host_notifications_enabled 1 service_notifications_enabled 1 - notificationways email + notificationways email email alignak@localhost # Minium business impact - All elements diff --git a/docker/data/alignak/etc/base/templates/generic-contact.cfg b/docker/data/alignak/etc/base/templates/generic-contact.cfg index ed2bb25cc..a4f56d263 100755 --- a/docker/data/alignak/etc/base/templates/generic-contact.cfg +++ b/docker/data/alignak/etc/base/templates/generic-contact.cfg @@ -1,24 +1,26 @@ # Default contact definition define contact{ - name generic-contact + name generic-contact - # No notifications for hosts/services - host_notifications_enabled 0 - service_notifications_enabled 0 - notificationways log + # No notifications for hosts/services + host_notifications_enabled 0 + service_notifications_enabled 0 - # Because min_business_impact is set, we must define service_notification_period,... - # else the default created notification ways raise a configuration error! - service_notification_period 24x7 - host_notification_period 24x7 - host_notification_commands notify-host-by-log - service_notification_commands notify-service-by-log + notificationways log - # Only useful for the UI... - password NOTSET - is_admin 0 - can_submit_commands 0 + # Because min_business_impact is set, we must define service_notification_period,... + # else the default created notification ways raise a configuration error! + service_notification_period 24x7 + host_notification_period 24x7 + host_notification_commands notify-host-by-log + service_notification_commands notify-service-by-log + + # Only useful for the UI... + # Change this default password!!! + password NOTSET + is_admin 0 + can_submit_commands 0 # This to say that it's a template - register 0 + register 0 } diff --git a/docker/image-alignak-ui/Dockerfile b/docker/image-alignak-ui/Dockerfile index 48bd8ec72..a706b6abc 100644 --- a/docker/image-alignak-ui/Dockerfile +++ b/docker/image-alignak-ui/Dockerfile @@ -13,6 +13,9 @@ LABEL maintainer="Frédéric Mohier (frederic.mohier@alignak.net)" \ ENV DEBIAN_FRONTEND noninteractive +# Run as the root user +USER root + RUN apt-get install -y --no-install-recommends \ nginx \ python3-pip \ @@ -43,6 +46,13 @@ RUN cd /repos && \ pip3 install -r requirements.txt && \ pip3 install . +# Define some environment variables +ENV ALIGNAK_GROUP "alignak" +ENV ALIGNAK_USER "alignak" + +# Run as the newly created user +USER $ALIGNAK_USER + # Copy the Nginx global conf COPY nginx.conf /etc/nginx/ # Copy the Flask Nginx site conf diff --git a/docker/image-alignak/Dockerfile b/docker/image-alignak/Dockerfile index 906966f72..cbffd6c59 100644 --- a/docker/image-alignak/Dockerfile +++ b/docker/image-alignak/Dockerfile @@ -50,16 +50,19 @@ ENV ALIGNAK_GROUP "alignak" ENV ALIGNAK_USER "alignak" # Create alignak system user/group for Alignak application -# Note that the group is set a gid (1024), this to allow easy sharing with the doker host +# Note that the group is set a gid (1024), this to allow easy sharing with the Docker host ARG ALIGNAK_SHARE_ID=1024 RUN groupadd --system --gid $ALIGNAK_SHARE_ID $ALIGNAK_GROUP RUN useradd --system $ALIGNAK_USER --uid $ALIGNAK_SHARE_ID --gid $ALIGNAK_SHARE_ID -ENV ALIGNAK_SHARE_DIR=$ALIGNAK_SHARE_DIR -COPY ./entrypoint.sh /entrypoint.sh -RUN chown $ALIGNAK_USER:$ALIGNAK_GROUP /entrypoint.sh -RUN chmod 500 /entrypoint.sh +# Create the shared directory if it does not exist and set proper credentials +ARG ALIGNAK_SHARE_DIR=/alignak +RUN mkdir -p $ALIGNAK_SHARE_DIR +RUN chown $ALIGNAK_USER:$ALIGNAK_GROUP $ALIGNAK_SHARE_DIR +RUN chmod -R 775 $ALIGNAK_SHARE_DIR + +# Run as the newly created user +USER $ALIGNAK_USER -ENTRYPOINT ["/entrypoint.sh"] # Run the arbiter in check mode for the configuration in the Alignak directory CMD ["alignak-arbiter", "-V", "-e", "/alignak/etc/alignak.ini" ]