From 940910b9a3b6876ac23d79e71ab8951248e8fe31 Mon Sep 17 00:00:00 2001 From: Matthew Jones Date: Wed, 9 Sep 2015 17:16:35 -0400 Subject: Adding docker-compose development workflow --- .gitignore | 1 + Makefile | 7 ++++--- tools/docker-compose.yml | 23 ++++++++++++++++++++ tools/docker-compose/Dockerfile | 24 +++++++++++++++++++++ tools/docker-compose/README | 2 ++ tools/docker-compose/start_development.sh | 35 +++++++++++++++++++++++++++++++ 6 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 tools/docker-compose.yml create mode 100644 tools/docker-compose/Dockerfile create mode 100644 tools/docker-compose/README create mode 100755 tools/docker-compose/start_development.sh diff --git a/.gitignore b/.gitignore index f86a281884..74a3bd3bda 100644 --- a/.gitignore +++ b/.gitignore @@ -83,5 +83,6 @@ nohup.out reports # AWX python libs populated by requirements.txt +awx/lib/.deps_built awx/lib/site-packages diff --git a/Makefile b/Makefile index f0dc8786c8..1b173c1be7 100644 --- a/Makefile +++ b/Makefile @@ -567,9 +567,6 @@ packaging/packer/output-virtualbox-iso/centos-7.ovf: virtualbox-centos-7: packaging/packer/output-virtualbox-iso/centos-7.ovf -docker-dev: - docker build --no-cache=true --rm=true -t ansible/tower_devel:latest tools/docker - # TODO - figure out how to build the front-end and python requirements with # 'build' build: @@ -577,3 +574,7 @@ build: install: $(PYTHON) setup.py install $(SETUP_INSTALL_ARGS) + +# Docker Compose Development environment +docker-compose: + docker-compose -f tools/docker-compose.yml up --no-recreate diff --git a/tools/docker-compose.yml b/tools/docker-compose.yml new file mode 100644 index 0000000000..e882ecd4d2 --- /dev/null +++ b/tools/docker-compose.yml @@ -0,0 +1,23 @@ +tower: + build: ./docker-compose + ports: + - "8080:8080" + - "8013:8013" + links: + - postgres + - redis + - mongo + volumes: + - ../:/tower_devel +postgres: + image: postgres:9.4.1 + # ports: + # - 5432:5432 +redis: + image: redis:3.0.1 + # ports: + # - 6379:6379 +mongo: + image: mongo:3.0 + # ports: + # - 27017:27017 \ No newline at end of file diff --git a/tools/docker-compose/Dockerfile b/tools/docker-compose/Dockerfile new file mode 100644 index 0000000000..d794df1b30 --- /dev/null +++ b/tools/docker-compose/Dockerfile @@ -0,0 +1,24 @@ +FROM ubuntu:14.04 + +RUN locale-gen en_US.UTF-8 +ENV LANG en_US.UTF-8 +ENV LANGUAGE en_US:en +ENV LC_ALL en_US.UTF-8 +RUN apt-get update +RUN apt-get install -y software-properties-common python-software-properties curl +RUN add-apt-repository -y ppa:chris-lea/zeromq; add-apt-repository -y ppa:chris-lea/node.js; add-apt-repository ppa:ansible/ansible +RUN curl -sL https://deb.nodesource.com/setup_0.12 | bash - +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && apt-key adv --fetch-keys http://www.postgresql.org/media/keys/ACCC4CF8.asc +RUN echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-3.0.list && echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" | tee /etc/apt/sources.list.d/postgres-9.4.list +RUN apt-get update +RUN apt-get install -y openssh-server ansible mg vim tmux git mercurial subversion python-dev python-psycopg2 make postgresql-client libpq-dev nodejs python-psutil libxml2-dev libxslt-dev lib32z1-dev libsasl2-dev libldap2-dev libffi-dev libzmq-dev proot python-pip && rm -rf /var/lib/apt/lists/* +RUN /usr/bin/ssh-keygen -q -t rsa -N "" -f /root/.ssh/id_rsa +RUN mkdir -p /etc/tower +RUN mkdir -p /data/db +ADD license /etc/awx/license +ADD license /etc/tower/license +RUN pip2 install honcho +ADD start_development.sh /start_development.sh + +EXPOSE 8013 8080 22 +CMD /start_development.sh diff --git a/tools/docker-compose/README b/tools/docker-compose/README new file mode 100644 index 0000000000..1d1829ec11 --- /dev/null +++ b/tools/docker-compose/README @@ -0,0 +1,2 @@ +docker build --no-cache=true --rm=true -t ansible/tower_devel:latest . +docker run --name tower_test -it --memory="4g" --cpuset="0,1" -v /Users/meyers/ansible/:/tower_devel -p 8013:8013 -p 8080:8080 -p 27017:27017 -p 2222:22 ansible/tower_devel diff --git a/tools/docker-compose/start_development.sh b/tools/docker-compose/start_development.sh new file mode 100755 index 0000000000..f2267a85ce --- /dev/null +++ b/tools/docker-compose/start_development.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +# We need to give the databases enough time to start up (switch to using ansible's wait_for here) +sleep 20 + +# In case Tower in the container wants to connect to itself, use "docker exec" to attach to the container otherwise +/etc/init.d/ssh start +ansible -i "127.0.0.1," -c local -v -m postgresql_user -U postgres -a "name=awx-dev password=AWXsome1 login_user=postgres login_host=postgres" all +ansible -i "127.0.0.1," -c local -v -m postgresql_db -U postgres -a "name=awx-dev owner=awx-dev login_user=postgres login_host=postgres" all + +# Move to the source directory so we can bootstrap +if [ -f "/tower_devel/manage.py" ]; then + cd /tower_devel +elif [ -f "/tower_devel/ansible-tower/manage.py" ]; then + cd /tower_devel/ansible-tower +else + echo "Failed to find tower source tree, map your development tree volume" +fi +make develop + +# Check if we need to build dependencies +if [ -f "awx/lib/.deps_built" ]; then + echo "Skipping dependency build - remove awx/lib/.deps_built to force a rebuild" +else + make requirements_dev + touch awx/lib/.deps_built +fi + +# Tower bootstrapping +make version_file +make migrate +make init + +# Start the service +make honcho -- cgit v1.2.3