From 501bbab97b24fed21a5b5631d9b1b02e94a991af Mon Sep 17 00:00:00 2001 From: Tai Lee Date: Tue, 20 Sep 2016 01:45:15 +1000 Subject: [PATCH] Run `setup-django.sh bash.sh` as the default command for `django` service. This should give people a look at the list of commands they can run in the shell, and make it easier to switch between the Django dev server, nginx/gunicorn, running tests, etc., without having to interact with Docker for every command and wait for the entrypoint/setup every time. --- README.md | 17 ++++++++++++---- docker-compose.yml | 2 +- docs/contributing/contributing.md | 30 ++++++++++++++++++++--------- docs/intro/install.md | 17 ++++++++++++---- icekit/bin/startproject.sh | 17 ++++++++++++---- project_template/docker-compose.yml | 2 +- 6 files changed, 62 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index ba967dda..4a63d8ff 100644 --- a/README.md +++ b/README.md @@ -43,20 +43,29 @@ Build a Docker image: $ cd $ docker-compose build --pull +Run a `django` container and all of its dependancies: + + $ docker-compose run --rm --service-ports django + Create a superuser account: - $ docker-compose run --rm django manage.py createsuperuser + # manage.py createsuperuser -Run the project: +Run the Django dev server: - $ docker-compose run --rm --service-ports django + # runserver.sh ## 3. That's it! -Open your new site in a browser: +Open the site in a browser: http://localhost:8000 +When you're done, exit the container and stop all of its dependencies: + + # exit + $ docker-compose stop + # Next steps * [Start building your site](docs/howto/start.md) diff --git a/docker-compose.yml b/docker-compose.yml index d3e3dded..4e1e4d94 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: command: setup-django.sh celeryflower.sh extends: django django: - command: setup-django.sh runserver.sh + command: setup-django.sh bash.sh environment: BASE_SETTINGS_MODULE: develop MASTER_PASSWORD: # Get from environment diff --git a/docs/contributing/contributing.md b/docs/contributing/contributing.md index 93620cf3..60ca7007 100644 --- a/docs/contributing/contributing.md +++ b/docs/contributing/contributing.md @@ -12,29 +12,41 @@ Get the code: $ git clone https://github.com/ic-labs/django-icekit.git $ cd django-icekit -Build a Docker image: +Run a `django` container and all of its dependancies: - $ docker-compose build --pull + $ docker-compose run --rm --service-ports django + +Run the tests: + + # runtests.sh Create a superuser account: - $ docker-compose run --rm django manage.py createsuperuser + # manage.py createsuperuser -Run the project: +Run the Django dev server: - $ docker-compose run --rm --service-ports django + # runserver.sh -Now you can open the site in a browser: +Open the site in a browser: http://localhost:8000 -Stop all services: +When you're done, exit the container and stop all of its dependencies: + # exit $ docker-compose stop -Run the tests: +## Running multiple containers + +Only one container can bind a fixed service port on the host at a time. + +If you want to run a second container, for example to run tests in while +running the Django dev server, you will need to run it with a different fixed +port or a dynamic port: - $ docker-compose run --rm django runtests.sh + $ docker-compose run --rm -p 8001:8000 django # fixed: 8001->8000 + $ docker-compose run --rm -p 8000 django # dynamic, check with docker-compose ps # Run without Docker diff --git a/docs/intro/install.md b/docs/intro/install.md index 145db23c..62475847 100644 --- a/docs/intro/install.md +++ b/docs/intro/install.md @@ -30,20 +30,29 @@ Build a Docker image: $ cd $ docker-compose build --pull +Run a `django` container and all of its dependancies: + + $ docker-compose run --rm --service-ports django + Create a superuser account: - $ docker-compose run --rm django manage.py createsuperuser + # manage.py createsuperuser -Run the project: +Run the Django dev server: - $ docker-compose run --rm --service-ports django + # runserver.sh ## 3. That's it! -Open your new site in a browser: +Open the site in a browser: http://localhost:8000 +When you're done, exit the container and stop all of its dependencies: + + # exit + $ docker-compose stop + # Next steps * [Start building your site](../howto/start.md) diff --git a/icekit/bin/startproject.sh b/icekit/bin/startproject.sh index 1f22f249..dc3aeaaa 100755 --- a/icekit/bin/startproject.sh +++ b/icekit/bin/startproject.sh @@ -90,18 +90,27 @@ Build a Docker image: $ docker-compose build --pull +Run a 'django' container and all of its dependancies: + + $ docker-compose run --rm --service-ports django + Create a superuser account: - $ docker-compose run --rm django manage.py createsuperuser + # manage.py createsuperuser -Run the project: +Run the Django dev server: - $ docker-compose run --rm --service-ports django + # runserver.sh -Now you can open the site in a browser: +Open the site in a browser: http://localhost:8000 +When you're done, exit the container and stop all of its dependencies: + + # exit + $ docker-compose stop + Read our [Docker Quick Start](https://github.com/ic-labs/django-icekit/blob/${BRANCH}/docs/docker-quick-start.md) guide for more info on running an ICEkit project with Docker. diff --git a/project_template/docker-compose.yml b/project_template/docker-compose.yml index c4112bf1..453e07a0 100644 --- a/project_template/docker-compose.yml +++ b/project_template/docker-compose.yml @@ -10,7 +10,7 @@ services: command: setup-django.sh celeryflower.sh extends: django django: - command: setup-django.sh runserver.sh + command: setup-django.sh bash.sh environment: BASE_SETTINGS_MODULE: develop MASTER_PASSWORD: # Get from environment