Completely redo support for Docker; everything should work now

This commit is contained in:
April King 2015-09-10 12:19:46 -05:00
Родитель 41411bc12b
Коммит 245ecfc0d5
5 изменённых файлов: 67 добавлений и 47 удалений

Просмотреть файл

@ -5,10 +5,11 @@ ENV MINION_BACKEND /opt/minion/minion-backend
ENV MINION_DOCKERIZED true
EXPOSE 8383
# Install minion-backend
RUN git clone https://github.com/mozilla/minion-backend.git ${MINION_BACKEND}
# Run everything with bash
# RUN rm /bin/sh && ln -s /bin/bash /bin/sh
# Move files into place
COPY backend.json /tmp/backend.json
COPY scan.json /tmp/scan.json
COPY backend.sh /tmp/backend.sh
@ -16,5 +17,14 @@ COPY common.sh /tmp/common.sh
RUN chmod 755 /tmp/backend.sh /tmp/common.sh
# Install common software, setup virtualenv
RUN /bin/bash -c /tmp/common.sh
# Install minion-backend
RUN git clone https://github.com/mozilla/minion-backend.git ${MINION_BACKEND}
# Setup the backend environment
CMD /tmp/common.sh && /tmp/backend.sh
RUN /bin/bash -c /tmp/backend.sh
# Start up Minion backend
CMD service mongodb start && service rabbitmq-server start && service minion start && tail -F /var/log/minion/*

Просмотреть файл

@ -5,9 +5,6 @@ ENV MINION_DOCKERIZED true
ENV MINION_FRONTEND /opt/minion/minion-frontend
EXPOSE 8080
# Install minion-frontend
RUN git clone https://github.com/mozilla/minion-frontend.git ${MINION_FRONTEND}
# Move files into place
COPY frontend.json /tmp/frontend.json
@ -16,5 +13,14 @@ COPY common.sh /tmp/common.sh
RUN chmod 755 /tmp/frontend.sh /tmp/common.sh
# Install common software, setup virtualenv
RUN /bin/bash -c /tmp/common.sh
# Install minion-frontend
RUN git clone https://github.com/mozilla/minion-frontend.git ${MINION_FRONTEND}
# Setup the frontend environment
CMD /tmp/common.sh && /tmp/frontend.sh
RUN /bin/bash -c /tmp/frontend.sh
# Start up the Minion frontend
CMD service minion start && tail -F /var/log/minion/*

Просмотреть файл

@ -6,20 +6,18 @@ MINION_ADMINISTRATOR_NAME="April King"
# The base directory for large pieces of the install
MINION_BASE_DIRECTORY=/opt/minion
# Install backend only packages on Vagrant systems
if [[ `id -un vagrant` == 'vagrant' ]]; then
apt-get -y install curl \
libcurl4-openssl-dev \
libffi-dev \
mongodb-server \
nmap \
postfix \
rabbitmq-server \
stunnel
# Install backend only packages
apt-get -y install curl \
libcurl4-openssl-dev \
libffi-dev \
mongodb-server \
nmap \
postfix \
rabbitmq-server \
stunnel
# For some reason, it has trouble adding the rabbitmq groups
apt-get -y install rabbitmq-server
fi
# For some reason, it has trouble adding the rabbitmq groups
apt-get -y install rabbitmq-server
# First, source the virtualenv
cd ${MINION_BASE_DIRECTORY}
@ -34,6 +32,7 @@ python setup.py develop
# Configure minion-backend (listening on 0.0.0.0:8383, and with no blacklist)
mkdir -p /etc/minion
mv /tmp/backend.json /etc/minion
mv /tmp/scan.json /etc/minion
# Install minion-nmap-plugin; comment out `git clone` if working on minion-nmap-plugin locally
@ -42,14 +41,6 @@ git clone https://github.com/mozilla/minion-nmap-plugin ${MINION_BASE_DIRECTORY}
cd ${MINION_BASE_DIRECTORY}/minion-nmap-plugin
python setup.py install
# Start MongoDB
service mongodb start
sleep 5
# Start RabbitMQ
service rabbitmq-server start
sleep 5
# Add the minion init scripts to the system startup scripts
cp ${MINION_BASE_DIRECTORY}/minion-backend/scripts/minion-init /etc/init.d/minion
chown root:root /etc/init.d/minion
@ -61,6 +52,14 @@ echo -e "\n# Minion convenience commands" >> ~minion/.bashrc
echo -e "alias miniond=\"supervisord -c ${MINION_BASE_DIRECTORY}/minion-backend/etc/supervisord.conf\"" >> ~minion/.bashrc
echo -e "alias minionctl=\"supervisorctl -c ${MINION_BASE_DIRECTORY}/minion-backend/etc/supervisord.conf\"" >> ~minion/.bashrc
# Start MongoDB
service mongodb start
sleep 5
# Start RabbitMQ
service rabbitmq-server start
sleep 5
# Start Minion
service minion start
sleep 30
@ -68,10 +67,14 @@ sleep 30
# Create the initial administrator and database
minion-db-init "$MINION_ADMINISTRATOR_EMAIL" "$MINION_ADMINISTRATOR_NAME" y
# Give instructions to add debugging and automatic reloading
echo "Add '--debug --reload' to minion-backend.supervisor.conf for automatic loading of changes to Minion"
# Eternal process for Docker
# If we're running in Docker, we start these with CMD
if [[ $MINION_DOCKERIZED == "true" ]]; then
tail -f /var/log/minion/*.log
fi
service minion stop
sleep 30
service rabbitmq-server stop
sleep 5
# This seems to be broken on Ubuntu 14.04, since it doesn't create the /var/run/mongodb directory
# service mongodb stop
kill `ps aux | grep mongod | grep -v grep | tr -s ' ' | cut -d ' ' -f 2`
fi

Просмотреть файл

@ -3,20 +3,23 @@
# The base directory for large pieces of the install
MINION_BASE_DIRECTORY=/opt/minion
# Install common packages on Vagrant systems
if [[ `id -un vagrant` == 'vagrant' ]]; then
apt-get update && apt-get -y install build-essential \
# Install common packages
apt-get update && apt-get -y install build-essential \
git \
libssl-dev \
python \
python-dev \
python-virtualenv \
supervisor
fi
# We install supervisor, but we don't actually need it to startup: /etc/init.d/minion already does that
update-rc.d -f supervisor remove
# Create the Minion directory if it doesn't exist, like in Docker
if [[ ! -d "${MINION_BASE_DIRECTORY}" ]]; then
mkdir -p "${MINION_BASE_DIRECTORY}"
fi
cd ${MINION_BASE_DIRECTORY}
# First, create and activate the virtualenv; we do this outside of the shared directory
@ -33,4 +36,4 @@ useradd -m minion
install -m 700 -o minion -g minion -d /run/minion -d /var/lib/minion -d /var/log/minion -d ~minion/.python-eggs
# Setup the minion environment for the minion user
echo -e "\n# Automatically source minion-backend virtualenv\nsource ${MINION_BASE_DIRECTORY}/minion-env/bin/activate" >> ~minion/.profile
echo -e "\n# Source minion-backend virtualenv\nsource ${MINION_BASE_DIRECTORY}/minion-env/bin/activate" >> ~minion/.profile

Просмотреть файл

@ -2,11 +2,9 @@
MINION_BASE_DIRECTORY=/opt/minion
# Install frontend only packages on Vagrant systems
if [[ `id -un vagrant` == 'vagrant' ]]; then
apt-get install -y libldap2-dev \
libsasl2-dev
fi
# Install frontend packages on Vagrant systems
apt-get install -y libldap2-dev \
libsasl2-dev
# First, source the virtualenv
cd ${MINION_BASE_DIRECTORY}
@ -36,7 +34,7 @@ echo -e "alias minionctl=\"supervisorctl -c ${MINION_BASE_DIRECTORY}/minion-fron
service minion start
sleep 5
# Start up minion-frontend; in Docker, this is the CMD
# If we're running in Docker, we start these with CMD
if [[ $MINION_DOCKERIZED == 'true' ]]; then
tail -f /var/log/minion/*.log
fi
service minion stop
fi