You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by rg...@apache.org on 2015/07/26 06:44:34 UTC

svn commit: r1692686 - in /comdev/tools: readme.md scripts/dev.sh

Author: rgardler
Date: Sun Jul 26 04:44:34 2015
New Revision: 1692686

URL: http://svn.apache.org/r1692686
Log:
add a dev.sh script for easy configuration of a development environment

Added:
    comdev/tools/scripts/dev.sh
Modified:
    comdev/tools/readme.md

Modified: comdev/tools/readme.md
URL: http://svn.apache.org/viewvc/comdev/tools/readme.md?rev=1692686&r1=1692685&r2=1692686&view=diff
==============================================================================
--- comdev/tools/readme.md (original)
+++ comdev/tools/readme.md Sun Jul 26 04:44:34 2015
@@ -118,37 +118,20 @@ containers during development. Your loca
 will be mapped into /project on the container, thus local edits will
 be available in your development container immediately.
 
-The first time you run the container you will need to configure the
-database. Subsequent runs will just require standard Django commands
-to be run.
+We have provided a script that will setup a development environment
+for you. First ensure the Docker CLI is setup to work with the right
+Docker host using the following command:
 
-### First Run ###
+        $ eval "$(docker-machine env MACHINE_NAME)"
 
-As with all Docker containers the first time you build and run them
-the images and corresponding layers need to be downloaded. This can
-take a few minutes. After the first run everything is very quick.
+Then you can setup a clean dev environment with the command:
 
-Ensure you are in the project root and then start the postgres
-database container:
+        $ scripts/dev.sh
 
-	$ docker run -d -v //home/docker/project:/project -p 5432:5432 --name comdev_db postgres
-
-Build the application container:
-
-	$ docker build -t meetups .
-
-Configure the application and the database:
-
-	$ docker run --rm -v //home/docker/comdev/meetups:/project --link comdev_db:db meetups python manage.py makemigrations events_list
-	$ docker run --rm -v //home/docker/comdev/meetups:/project --link comdev_db:db meetups python manage.py migrate
-
-Now, run the application:
-
-	$ docker run --rm -v //home/docker/comdev/meetups:/project --link comdev_db:db -p 80:8000 --name meetup_app meetups python manage.py runserver 0.0.0.0:8000
-
-Now you can visit the app at http://docker.host/events
-
-Access the admin pages at http://docker.host/admin
+NOTE: this command kills any running dev containers and restarts
+them. This will remove any data that has been changed during the most
+recent development activity. Only run this command if you are prepared
+to go back to a clean dev state.
 
 ### Running Django Commands ###
 
@@ -156,7 +139,11 @@ From this point development is just like
 but to run Django commands in the app container you will need to open
 a terminal on that machine. To do this run:
 
-	$ docker exec -it comdev_app bash
+	$ docker exec -it meetups_app bash
+
+To run individual commands rather than entering an interactive shell:
+
+        $ docker exec meetups_app python manage.py COMMAND
 
 ### Using the Admin Interface ###
 
@@ -166,6 +153,6 @@ container (i.e. with no data in the data
 an admin user. To do this run the following command in your Django
 terminal.
 
-	$ python manage.py createsuperuser
+	$ docker exec -it meetups_app python manage.py createsuperuser
 
 Now you can log into the admin app at http://docker.host/admin

Added: comdev/tools/scripts/dev.sh
URL: http://svn.apache.org/viewvc/comdev/tools/scripts/dev.sh?rev=1692686&view=auto
==============================================================================
--- comdev/tools/scripts/dev.sh (added)
+++ comdev/tools/scripts/dev.sh Sun Jul 26 04:44:34 2015
@@ -0,0 +1,50 @@
+echo "##################################################################################################"
+echo "# Check we really want to restart dev containers"
+echo "##################################################################################################"
+
+echo "DOCKER_HOST is set to $DOCKER_HOST"
+echo "DOCKER_MACHINE_NAME is set to $DOCKER_MACHINE_NAME"
+echo "Do you really want to restart containers on this machine?"
+read -p "Remember, it will destroy all data.\nEnter 'Yes' to confirm: " CONFIRM
+
+if [ $CONFIRM != "Yes" ]; then
+  echo "Phew!!! That was close, aborting"
+  exit 1
+fi
+
+echo "##################################################################################################"
+echo "# Remove old dev containers that may still be running"
+echo "##################################################################################################"
+docker rm -f meetups_db
+docker rm -f meetups_app
+
+echo "##################################################################################################"
+echo "# Start the database container"
+echo "##################################################################################################"
+docker run -d -v //home/docker/project:/project -p 5432:5432 --name meetups_db postgres
+sleep 3 # a small delay to ensure the DB hads time to start before we try to conenct to it
+
+echo "##################################################################################################"
+echo "# Build the application container"
+echo "##################################################################################################"
+docker build -t meetups .
+
+echo "##################################################################################################"
+echo "# Configure the database"
+echo "##################################################################################################"
+docker run --rm -v //home/docker/comdev/meetups:/project --link meetups_db:db meetups python manage.py makemigrations events_list
+docker run --rm -v //home/docker/comdev/meetups:/project --link meetups_db:db meetups python manage.py migrate
+
+echo "##################################################################################################"
+echo "# Setup a superuser (hit return to continue once created)"
+echo "##################################################################################################"
+docker run --rm -it --link meetups_db:db meetups python manage.py createsuperuser
+
+echo "##################################################################################################"
+echo "# Run the application"
+echo "##################################################################################################"
+docker run --rm -v //home/docker/comdev/meetups:/project --link meetups_db:db -p 80:8000 --name meetups_app meetups python manage.py runserver 0.0.0.0:8000
+
+echo "##################################################################################################"
+echo "# Done"
+echo "##################################################################################################"