From a57af695ccd0e2dd83db3c36de056f5b2fb93d00 Mon Sep 17 00:00:00 2001 From: Krzysztof Szumny Date: Thu, 20 Aug 2015 01:28:41 +0200 Subject: [PATCH] smarter post_gen_project.py + Docker Remote Debugging instructions placeholder --- README.rst | 11 +++- hooks/post_gen_project.py | 57 +++++++++++-------- {{cookiecutter.repo_name}}/README.rst | 2 + .../docs/docker_remote_debugging.rst | 11 ++++ 4 files changed, 57 insertions(+), 24 deletions(-) create mode 100644 {{cookiecutter.repo_name}}/docs/docker_remote_debugging.rst diff --git a/README.rst b/README.rst index 5f118dd78..e86a8dc79 100644 --- a/README.rst +++ b/README.rst @@ -37,7 +37,8 @@ Features * Pre configured Celery_ (optional) * Integration with Maildump_ for local email testing (optional) * Integration with Sentry_ for error logging (optional) -* Docker support using docker-compose_ for dev (with debug) and prod +* Docker support using docker-compose_ for dev (with debug) and prod (optional) +* PyCharm "Run/Debug Configurations" for django, grunt and docker (optional) .. _Hitch: https://github.com/hitchtest/hitchtest .. _Bootstrap: https://github.com/twbs/bootstrap @@ -189,6 +190,14 @@ And then run:: $ docker-compose up +If you want to connect to python interpreter inside docker container with remote debbuger, you have to run different +container with debug.yml (dev.yml has to be build first):: + + $ docker-compose -f dev.yml build; docker-compose -f debug.yml up + + +See `docker remote debugging instructions <{{cookiecutter.repo_name}}/docs/docker_remote_debugging.rst>`_ for particular IDE (PyCharm, etc). + To migrate your app and to create a superuser, run:: $ docker-compose run django python manage.py migrate diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index f19f2d1d3..e019f5a9e 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -4,43 +4,54 @@ import shutil project_directory = os.path.realpath(os.path.curdir) -# ------------------------------------------------------------------------------ +def clean(items): + for item in items: + path = os.path.join(project_directory, item) + if os.path.isdir(path): + shutil.rmtree(path) + else: + os.remove(path) + +pycharm = '{{cookiecutter.use_pycharm}}' == 'y' docker = '{{cookiecutter.use_docker}}' == 'y' +# ------------------------------------------------------------------------------ docker_files = [ 'debug.yml', 'dev.yml', 'docker-compose.yml', - 'Dockerfile' -] - -docker_dirs = [ + 'Dockerfile', 'compose/', ] if not docker: - for path in docker_files: - os.remove(os.path.join(project_directory, path)) - - for path in docker_dirs: - shutil.rmtree(os.path.join(project_directory, path)) - + clean(docker_files) # ------------------------------------------------------------------------------ -pycharm = '{{cookiecutter.use_pycharm}}' == 'y' - pycharm_files = [ - -] - -pycharm_dirs = [ '.idea/', ] +pycharm_docker_files = [ + '.idea/Docker__createsuperuser.xml', + '.idea/Docker__grunt_build.xml', + '.idea/Docker__grunt_compass.xml', + '.idea/Docker__grunt_serve.xml', + '.idea/Docker__grunt_start_email_server.xml', + '.idea/Docker__grunt_stop_email_server.xml', + '.idea/Docker__grunt_watch.xml', + '.idea/Docker__migrate.xml', + '.idea/Docker__runserver_plus.xml', + '.idea/Docker__runserver.xml', + '.idea/Docker__tests___all.xml', + '.idea/Docker__tests___class__TestUser.xml', + '.idea/Docker__tests___file__test_models.xml', + '.idea/Docker__tests___module__users.xml', + '.idea/Docker__tests___specific__test_get_absolute_url.xml', + '.idea/Docker__tests___users.xml', +] + if not pycharm: - for path in pycharm_files: - os.remove(os.path.join(project_directory, path)) - - for path in pycharm_dirs: - shutil.rmtree(os.path.join(project_directory, path)) - + clean(pycharm_files) +elif pycharm and not docker: + clean(pycharm_docker_files) # ------------------------------------------------------------------------------ diff --git a/{{cookiecutter.repo_name}}/README.rst b/{{cookiecutter.repo_name}}/README.rst index 79dfb430a..4a65b5f48 100644 --- a/{{cookiecutter.repo_name}}/README.rst +++ b/{{cookiecutter.repo_name}}/README.rst @@ -279,6 +279,7 @@ You can then deploy by running the following commands. ssh -t dokku@yourservername.com dokku run {{cookiecutter.repo_name}} python manage.py createsuperuser When deploying via Dokku make sure you backup your database in some fashion as it is NOT done automatically. +{% if cookiecutter.use_docker == 'y' %} Docker ^^^^^^ @@ -394,3 +395,4 @@ If you want to scale your application, run:: **Don't run the scale command on postgres or celerybeat** +{% endif %} diff --git a/{{cookiecutter.repo_name}}/docs/docker_remote_debugging.rst b/{{cookiecutter.repo_name}}/docs/docker_remote_debugging.rst new file mode 100644 index 000000000..9e4c4ed6c --- /dev/null +++ b/{{cookiecutter.repo_name}}/docs/docker_remote_debugging.rst @@ -0,0 +1,11 @@ +Docker Remote Debugging +======================= + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque lobortis pharetra rutrum. Nulla finibus metus eget egestas facilisis. Sed non turpis at neque rhoncus vestibulum. Duis tristique augue nibh, at rhoncus orci vulputate ut. Aenean auctor vel magna nec pellentesque. Cras porta vestibulum tortor in sodales. Phasellus tempor arcu et mi faucibus, vel finibus massa tristique. + +Proin vestibulum placerat orci ac ultricies. Pellentesque consectetur enim eget ex convallis, ut volutpat felis tincidunt. Sed magna purus, fringilla vitae lectus mattis, finibus hendrerit sapien. Mauris aliquam arcu maximus quam eleifend, sit amet aliquet orci porta. Nulla facilisi. Nulla pharetra augue pellentesque mauris consequat, sed porta magna accumsan. Etiam eget neque eget dolor feugiat rhoncus. + +PyCharm +^^^^^^^ + +Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nulla vitae tellus eros. Etiam faucibus consectetur sem, in pharetra mi semper sed. Proin dignissim orci eget ante pulvinar semper. Mauris scelerisque gravida elit vitae dapibus. Morbi tincidunt leo vulputate, ornare ipsum vel, gravida purus. Mauris sed commodo ex. Fusce id enim arcu. Phasellus ultricies lorem nulla, vitae luctus mauris lobortis a. Aenean ac mauris ut neque semper egestas. Nullam ac elementum nunc. \ No newline at end of file