From a8abfae0f5c4166c5c2f0fd6951273f96da69c03 Mon Sep 17 00:00:00 2001 From: Bob Haddleton Date: Tue, 5 Jun 2018 22:07:47 -0500 Subject: [PATCH] Update default Docker configuration and documentation Updated the default Docker configuration so it works with the default sqlite condfiguration. Also updated the README file. Updated .gitignore and .dockerignore to ignore .coverage.* files Change-Id: I698f8d0c97e2c5dc202af714470b6e055c74eea2 --- .dockerignore | 2 ++ .gitignore | 1 + tools/docker/DOCKER_README.rst | 44 +++++++++++++++++----------------- tools/docker/Dockerfile | 4 ++-- tools/docker/start.sh | 11 ++++++--- 5 files changed, 35 insertions(+), 27 deletions(-) diff --git a/.dockerignore b/.dockerignore index 0d2ccf742..51ead7c27 100644 --- a/.dockerignore +++ b/.dockerignore @@ -35,6 +35,8 @@ pip-log.txt # Unit test / coverage reports .coverage +.coverage.* +.stestr .tox nosetests.xml cover/* diff --git a/.gitignore b/.gitignore index 115157ee4..9a133ff9b 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,7 @@ pip-log.txt .tox nosetests.xml cover/* +.coverage.* .testrepository/ .stestr/ subunit.log diff --git a/tools/docker/DOCKER_README.rst b/tools/docker/DOCKER_README.rst index ec5effc80..878217aba 100644 --- a/tools/docker/DOCKER_README.rst +++ b/tools/docker/DOCKER_README.rst @@ -1,30 +1,28 @@ Using Mistral with Docker ========================= -In order to minimize the work needed to run the current Mistral code, or -be able to spin up independent or networked Mistral instances in seconds, -Docker containers are a very good option. This guide describes the process +Docker containers provide an easy way to quickly deploy independent or +networked Mistral instances in seconds. This guide describes the process to launch an all-in-one Mistral container. -Docker installation +Docker Installation ------------------- -The links help you to install latest Docker software: +The following links contain instructions to install latest Docker software: * `Docker Engine `_ * `Docker Compose `_ -Build the Mistral image manually +Build the Mistral Image Manually -------------------------------- -The `build.sh` script takes care of creating the `mistral-all` image locally. -On the other hand you could execute the following command:: +Execute the following command from the repository top-level directory:: docker build -t mistral -f tools/docker/Dockerfile . -The Mistral Docker image has a build parameter. +The Mistral Docker image has one build parameter: +-------------------------+-------------+--------------------------------------+ |Name |Default value| Description | @@ -51,13 +49,15 @@ To launch Mistral in the multi node configuration:: -f tools/docker/docker-compose/mistral-multi-node.yaml \ -p mistral up -d -The infrastructure docker-compose file contains a example of RabbitMQ, -PostgreSQL and MySQL. Fill free to modify docker-compose files. +The infrastructure docker-compose file contains examples of RabbitMQ, +PostgreSQL and MySQL configurations. Feel free to modify the docker-compose +files as needed. -Also the docker-compose contains the Clould-flow container. -It is available by `link `_ +The docker-compose Mistral configurations also include the CloudFlow container. +It is available at `link `_ -If you want to rebuild image you should add `--build` option, for example:: +The `--build` option can be used when it is necessary to rebuild the image, +for example:: docker-compose -f tools/docker/docker-compose/infrastructure.yaml \ -f tools/docker/docker-compose/mistral-single-node.yaml \ @@ -75,8 +75,8 @@ by default: |`MESSAGE_BROKER_URL`|rabbit://guest:gu\|The message broker URL | | |est@rabbitmq:5672 | | +--------------------+------------------+----------------------+---------------+ -|`DATABASE_URL` |sqlite://mistral.\|The database URL | -| |db | | +|`DATABASE_URL` |sqlite:///mistral\|The database URL | +| |.db | | +--------------------+------------------+----------------------+---------------+ |`UPGRADE_DB` |false |If the `UPGRADE_DB` equals `true`, | | | |a database upgrade will be launched | @@ -94,8 +94,9 @@ by default: | | |launched inside container | +--------------------+------------------+----------------------+---------------+ -Other way you can mount the your config file to a Mistral Docker container. -You should uncomment the volume sections in the docker-compose files. +The `/etc/mistral/mistral.conf` configuration file can be mounted to the Mistral +Docker container by uncommenting and editing the `volumes` sections in the Mistral +docker-compose files. Launch tests inside Container @@ -120,8 +121,7 @@ or PostgreSQL:: Using Mistral Client -------------------- -The script also configures the containers so that the Mistral API will be -accessible from the host machine on the default port 8989. So it is also -possible to install the `mistral-pythonclient` to the host machine and -execute commands there. +The Mistral API will be accessible from the host machine on the default +port 8989. Install `python-mistralclient` on the host machine to +execute mistral commands. diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile index 8b5944303..f3e4370c2 100644 --- a/tools/docker/Dockerfile +++ b/tools/docker/Dockerfile @@ -31,7 +31,7 @@ ENV MISTRAL_DIR="/opt/stack/mistral" \ CONFIG_FILE="/etc/mistral/mistral.conf" \ INI_SET="crudini --set /etc/mistral/mistral.conf" \ MESSAGE_BROKER_URL="rabbit://guest:guest@rabbitmq:5672/" \ - DATABASE_URL="sqlite://mistral.db" \ + DATABASE_URL="sqlite:///mistral.db" \ UPGRADE_DB="false" \ RUN_TESTS="false" \ DEBIAN_FRONTEND="noninteractive" \ @@ -60,4 +60,4 @@ RUN pip install -e "${MISTRAL_DIR}" && \ WORKDIR "${MISTRAL_DIR}" EXPOSE 8989 -CMD "${MISTRAL_DIR}/tools/docker/start.sh" \ No newline at end of file +CMD "${MISTRAL_DIR}/tools/docker/start.sh" diff --git a/tools/docker/start.sh b/tools/docker/start.sh index f2980a2b2..d0b7652af 100755 --- a/tools/docker/start.sh +++ b/tools/docker/start.sh @@ -16,16 +16,21 @@ if [ ! -f ${CONFIG_FILE} ]; then ${INI_SET} DEFAULT debug "${LOG_DEBUG}" fi -if "${UPGRADE_DB}"; +if [ ${DATABASE_URL} == "sqlite:///mistral.db" -a ! -f ./mistral.db ] then - mistral-db-manage --config-file "${CONFIG_FILE}" upgrade head + python ./tools/sync_db.py --config-file "${CONFIG_FILE}" mistral-db-manage --config-file "${CONFIG_FILE}" populate fi +if "${UPGRADE_DB}"; +then + /usr/local/bin/mistral-db-manage --config-file "${CONFIG_FILE}" upgrade head + mistral-db-manage --config-file "${CONFIG_FILE}" populate +fi if "${RUN_TESTS}"; then cp "${CONFIG_FILE}" .mistral.conf "${MISTRAL_DIR}/run_tests.sh" -N else mistral-server --config-file "${CONFIG_FILE}" --server ${MISTRAL_SERVER} -fi \ No newline at end of file +fi