Update docker Makefile commands and docs

This commit is contained in:
Mark Striemer 2015-10-21 16:48:12 -05:00
Родитель d076c64582
Коммит 013d999a83
4 изменённых файлов: 57 добавлений и 48 удалений

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

@ -1,15 +1,14 @@
.PHONY: help docs test test_es test_no_es test_force_db tdd test_failed initialize_db populate_data update_code update_deps update_db update_assets full_init full_update reindex flake8 update_docker initialize_docker
.PHONY: help docs test test_es test_no_es test_force_db tdd test_failed initialize_db populate_data update_code update_deps update_db update_assets full_init full_update reindex flake8 update_docker initialize_docker shell debug
NUM_ADDONS=10
NUM_THEMES=$(NUM_ADDONS)
UNAME_S := $(shell uname -s)
# If you use docker you can get a shell by executing
# `docker exec -t -i [container-id] /bin/bash`
# If you use docker-utils you can execute `docker-utils bash web` instead
help:
@echo "Please use 'make <target>' where <target> is one of"
@echo " shell to connect to a running olympia docker shell"
@echo " debug to connect to a running olympia docker for debugging"
@echo " make to connect to a running olympia docker and run make ARGS"
@echo " docs to builds the docs for Zamboni"
@echo " test to run all the test suite"
@echo " test_force_db to run all the test suite with a new database"
@ -81,10 +80,10 @@ update_assets:
python manage.py compress_assets
python manage.py collectstatic --noinput
initialize_docker: initialize_db update_assets
$(MAKE) populate_data
update_docker:
docker exec -t -i olympia_web_1 make update_docker_inner
update_docker: update_db update_assets
update_docker_inner: update_db update_assets
full_init: update_deps initialize_db populate_data update_assets
@ -95,3 +94,19 @@ reindex:
flake8:
flake8 --ignore=E265,E266 --exclude=services,wsgi,docs,node_modules,.npm,build*.py .
initialize_docker:
docker exec -t -i olympia_web_1 make initialize_docker_inner
initialize_docker_inner: initialize_db update_assets
$(MAKE) populate_data
debug:
docker exec -t -i olympia_web_1 supervisorctl fg olympia
shell:
docker exec -t -i olympia_web_1 bash
# Run a make command in docker.
make:
docker exec -t -i olympia_web_1 make $(ARGS)

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

@ -51,20 +51,11 @@ on your host machine::
git clone git://github.com/mozilla/olympia.git
cd olympia
pip install docker-compose docker-utils
pip install docker-compose
docker-compose pull # Can take a while depending on your internet bandwidth.
docker-compose up -d
docker-utils bash web # Opens a shell on the running web container.
# On the shell opened by docker-utils:
make initialize_docker # Answer yes, and create your superuser when asked.
.. note::
docker-utils_ is a wrapper library written in Python that wraps the
docker-compose command. It adds sugar for things like getting a bash shell
on a running container. As it wraps ``docker-compose`` once installed you can
alias ``docker-utils`` and use that in place of ``docker-compose``.
The last step is to grab the ip of the vm. If you're using docker-machine,
you can get the ip like so::
@ -89,7 +80,7 @@ Now you can connect to port 80 of that ip address. Here's an example
Any other commands can now be run in a shell on the running container::
docker-utils bash web
make shell
Then, to run the tests for example, just run this command in the shell::
@ -101,9 +92,6 @@ update your Docker image and database with any new requirements or migrations::
docker-compose stop
docker-compose pull
docker-compose up -d
Then from a shell on the running container run::
make update_docker # Runs database migrations and rebuilds assets.
Please note that any command that would result in files added or modified
@ -246,5 +234,4 @@ Indices and tables
.. _docker: https://docs.docker.com/installation/#installation
.. _docker-utils: https://pypi.python.org/pypi/docker-utils
.. _docker-toolbox: https://www.docker.com/toolbox

Двоичные данные
docs/screenshots/docker-ipdb.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 199 KiB

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

@ -15,42 +15,49 @@ As with ipdb normally just add a line in your code at the relevant point:
import ipdb; ipdb.set_trace()
Next open a shell on the running web container::
Next connect to the running web container::
docker exec -t -i olympia_web_1 supervisorctl fg olympia
make debug
This will bring the Django management server to the foreground and you
can interact with ipdb as you would normally. To quit you can just type
``Ctrl+c``.
All being well it should look like this:
All being well it should look like this::
.. image:: /screenshots/docker-ipdb.png
$ make debug
docker exec -t -i olympia_web_1 supervisorctl fg olympia
:/opt/rh/python27/root/usr/lib/python2.7/site-packages/celery/utils/__init__.py:93
11:02:08 py.warnings:WARNING /opt/rh/python27/root/usr/lib/python2.7/site-packages/jwt/api_jws.py:118: DeprecationWarning: The verify parameter is deprecated. Please use options instead.
'Please use options instead.', DeprecationWarning)
:/opt/rh/python27/root/usr/lib/python2.7/site-packages/jwt/api_jws.py:118
[21/Oct/2015 11:02:08] "PUT /en-US/firefox/api/v3/addons/%40unlisted/versions/0.0.5/ HTTP/1.1" 400 36
Validating models...
If you would rather use docker-utils_ you can do the following::
0 errors found
October 21, 2015 - 13:52:07
Django version 1.6.11, using settings 'settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CONTROL-C.
[21/Oct/2015 13:57:56] "GET /static/img/app-icons/16/sprite.png HTTP/1.1" 200 3810
13:58:01 py.warnings:WARNING /opt/rh/python27/root/usr/lib/python2.7/site-packages/celery/task/sets.py:23: CDeprecationWarning:
celery.task.sets and TaskSet is deprecated and scheduled for removal in
version 4.0. Please use "group" instead (see the Canvas section in the userguide)
docker-utils bash web
""")
:/opt/rh/python27/root/usr/lib/python2.7/site-packages/celery/utils/__init__.py:93
> /code/apps/browse/views.py(148)themes()
147 import ipdb;ipdb.set_trace()
--> 148 TYPE = amo.ADDON_THEME
149 if category is not None:
From here you can run supervisorctl::
supervisorctl
This will show you something like the following::
bash-4.1# supervisorctl
olympia RUNNING pid 21, uptime 0:18:38
supervisor>
To bring the runserver to the foreground type ``fg olympia`` at the
prompt::
supervisor> fg olympia
To quit you can just type ``Ctrl+c`` (this will bring you back to the
supervisorctl prompt). There you can type ``exit`` to quit (sometimes exiting
the supervisorctl prompt doesn't respond so closing that shell is another
option).
ipdb> n
> /code/apps/browse/views.py(149)themes()
148 TYPE = amo.ADDON_THEME
--> 149 if category is not None:
150 q = Category.objects.filter(application=request.APP.id, type=TYPE)
ipdb>
Using the Django Debug Toolbar