From fb68ee8741d24db7dcc9f34d01e5635bd10d3048 Mon Sep 17 00:00:00 2001 From: Michele Bologna Date: Fri, 6 Apr 2018 18:40:58 +0200 Subject: [PATCH] Feat: remove Supervisor dependency Removed Supervisor dependency that was dragging Python 2 into the installed packages. Everything is running with Python 3 now: USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 15 0.6 0.2 285336 38156 ? S 16:38 0:00 /usr/bin/python3 /usr/bin/salt-master -d -l debug root 44 1.5 0.2 210236 39772 ? S 16:38 0:00 /usr/bin/python3 usr/bin/salt-api -d -l debug Fix #1 --- Dockerfile-master | 12 +++--------- Dockerfile-minion | 4 +--- entrypoint-master.sh | 36 ++++++++++++++++++++++++++++++++++++ etc_master/supervisord.conf | 8 -------- 4 files changed, 40 insertions(+), 20 deletions(-) create mode 100755 entrypoint-master.sh delete mode 100644 etc_master/supervisord.conf diff --git a/Dockerfile-master b/Dockerfile-master index 04959c5..16e6494 100644 --- a/Dockerfile-master +++ b/Dockerfile-master @@ -1,22 +1,16 @@ FROM opensuse:tumbleweed MAINTAINER Michele Bologna -RUN zypper --non-interactive --no-gpg-checks refresh && \ - zypper --non-interactive up --no-recommends -y && \ - zypper --non-interactive in -y salt-master salt-api && \ - zypper --non-interactive addrepo https://download.opensuse.org/repositories/devel:/languages:/python/openSUSE_Tumbleweed/devel:languages:python.repo && \ - zypper --non-interactive --no-gpg-checks refresh && \ - zypper --non-interactive in --no-recommends -y supervisor && \ +RUN zypper --non-interactive in --no-recommends -y salt-master salt-api && \ zypper clean && \ useradd saltdev -p '$6$0BIlOqYqg5Rcuu5A$ojdWZ.aZztdSqPCnqsEE3ViRDcFAZ0MSp0UUvT23GG5mnbUOcalZPh8basKox2wcn4F1if2kfChOO/J1K2boe.' && \ - mkdir /var/run/supervisord/ && \ sed -i -e 's/^user: salt$/user: root/g' /etc/salt/master -COPY etc_master/supervisord.conf /etc/supervisor.d/supervisord.conf COPY etc_master/salt/master.d/autoaccept.conf /etc/salt/master.d/ COPY etc_master/salt/master.d/netapi.conf /etc/salt/master.d/ +COPY entrypoint-master.sh /entrypoint-master.sh VOLUME ["/srv/salt"] EXPOSE 8000 -CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor.d/supervisord.conf"] +CMD /entrypoint-master.sh diff --git a/Dockerfile-minion b/Dockerfile-minion index e3c2303..a7a99dd 100644 --- a/Dockerfile-minion +++ b/Dockerfile-minion @@ -1,9 +1,7 @@ FROM opensuse:tumbleweed MAINTAINER Michele Bologna -RUN zypper --non-interactive --no-gpg-checks refresh && \ - zypper --non-interactive up --no-recommends -y && \ - zypper --non-interactive in -y salt-minion && \ +RUN zypper --non-interactive in --no-recommends -y salt-minion && \ zypper clean CMD ["/usr/bin/salt-minion", "-l", "debug"] diff --git a/entrypoint-master.sh b/entrypoint-master.sh new file mode 100755 index 0000000..108e671 --- /dev/null +++ b/entrypoint-master.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Start the first process +/usr/bin/salt-master -d -l debug +status=$? +if [ $status -ne 0 ]; then + echo "Failed to start salt-master: $status" + exit $status +fi + +# Start the second process +usr/bin/salt-api -d -l debug +status=$? +if [ $status -ne 0 ]; then + echo "Failed to start salt-api: $status" + exit $status +fi + +# Naive check runs checks once a minute to see if either of the processes exited. +# This illustrates part of the heavy lifting you need to do if you want to run +# more than one service in a container. The container exits with an error +# if it detects that either of the processes has exited. +# Otherwise it loops forever, waking up every 60 seconds + +while sleep 60; do + ps aux |grep salt-master |grep -q -v grep + PROCESS_1_STATUS=$? + ps aux |grep salt-api |grep -q -v grep + PROCESS_2_STATUS=$? + # If the greps above find anything, they exit with 0 status + # If they are not both 0, then something is wrong + if [ $PROCESS_1_STATUS -ne 0 -o $PROCESS_2_STATUS -ne 0 ]; then + echo "One of the processes has already exited." + exit 1 + fi +done diff --git a/etc_master/supervisord.conf b/etc_master/supervisord.conf deleted file mode 100644 index 588c0b2..0000000 --- a/etc_master/supervisord.conf +++ /dev/null @@ -1,8 +0,0 @@ -[supervisord] -nodaemon=true - -[program:salt-master] -command=/usr/bin/salt-master -l debug - -[program:salt-api] -command=/usr/bin/salt-api -l debug