Update docker_remote_debugging.rst, screenshots + description
|
@ -1,42 +0,0 @@
|
|||
# Run/Debug Configuration (for PyCharm)
|
||||
|
||||
## Run debug docker container
|
||||
|
||||
To debug python code inside a docker container, you have to first run:
|
||||
|
||||
$ docker-compose -f debug.yml up
|
||||
|
||||
Container should be ready, when
|
||||
|
||||
...
|
||||
debug_1 | Starting OpenBSD Secure Shell server: sshd
|
||||
...
|
||||
|
||||
will be displayed in docker-compose logs.
|
||||
|
||||
## First time configuration
|
||||
|
||||
If you haven't configure it yet, enable django support for your project:
|
||||
|
||||
<img src="pycharm_configuration/1.png"/>
|
||||
|
||||
Next, you have to add python intepreter which is inside docker as remote interpreter:
|
||||
|
||||
<img src="pycharm_configuration/2.png"/>
|
||||
|
||||
|
||||
<img src="pycharm_configuration/3.png"/>
|
||||
|
||||
The last thing, you have to properly setup you Run/Debug Configuration. Make sure, that you use host 0.0.0.0.
|
||||
|
||||
<img src="pycharm_configuration/4.png"/>
|
||||
|
||||
|
||||
## How to debug?
|
||||
|
||||
Having configuration prepared, simply run your "run" debug configuration:
|
||||
|
||||
<img src="pycharm_configuration/5.png"/>
|
||||
|
||||
|
||||
|
|
@ -41,15 +41,80 @@ or you can also use ssh-key::
|
|||
PyCharm
|
||||
^^^^^^^
|
||||
|
||||
This repository comes with already prepared "Run/Debug Configurations" for docker.
|
||||
This repository comes with already prepared "Run/Debug Configurations" for docker.
|
||||
|
||||
.. image:: pycharm_configuration/1.png
|
||||
|
||||
But as you can see, at the beggining there is something wrong with them. They have red X on django icon, and they cannot be used, withot configuring remote python interpteter. To do that, you have to go to *Settings > Build, Execution, Deployment* first.
|
||||
|
||||
Even if you tested ssh connection manually, you **have to** do that one more time, through PyCharm, to active "Run/Debug Configurations" for Docker. To do that, please go to *Settings > Build, Execution, Deployment > Deployment > docker_{{ cookiecutter.repo_name }}* and click *Test SFTP connection*:
|
||||
|
||||
.. image:: pycharm_configuration/2.png
|
||||
|
||||
You should see:
|
||||
|
||||
.. image:: pycharm_configuration/3.png
|
||||
|
||||
**Important note:** if in the future you will somehow lose ability to login to docker container through PyCharm, always start with *Test SFTP Connection*. Very often this solves all issues.
|
||||
|
||||
Configure Remote Python Interpreter based on deployment settings
|
||||
----------------------------------------------------------------
|
||||
Configure Remote Python Interpreter
|
||||
-----------------------------------
|
||||
|
||||
...
|
||||
Next, you have to add new remote python interpreter, based on already tested deployment settings. Go to *Settings > Project > Project Interpreter*. Click on the cog icon, and click *Add Remote*.
|
||||
|
||||
.. image:: pycharm_configuration/4.png
|
||||
|
||||
Switch to *Deployment configuration*, and click on *Move this server to application level*. Last, and **very important** thing, change **Python interpreter path**, from `/usr/bin/python` to `/usr/local/bin/python`
|
||||
|
||||
.. image:: pycharm_configuration/5.png
|
||||
|
||||
The final result should be:
|
||||
|
||||
.. image:: pycharm_configuration/6.png
|
||||
|
||||
Having that, click *OK*. Close *Settings* panel, and wait few seconds...
|
||||
|
||||
.. image:: pycharm_configuration/7.png
|
||||
|
||||
After few seconds, all *Run/Debug Configurations* should be ready to use.
|
||||
|
||||
.. image:: pycharm_configuration/8.png
|
||||
|
||||
**Things you can do with provided configuration**:
|
||||
|
||||
* run and debug python code
|
||||
.. image:: pycharm_configuration/f1.png
|
||||
* run migrations
|
||||
.. image:: pycharm_configuration/f2.png
|
||||
* run tests (with coverage)
|
||||
.. image:: pycharm_configuration/f3.png
|
||||
.. image:: pycharm_configuration/f4.png
|
||||
* debug tests
|
||||
.. image:: pycharm_configuration/f5.png
|
||||
* connect to shell inside docker container
|
||||
.. image:: pycharm_configuration/f6.png
|
||||
* and many others..
|
||||
|
||||
PyCharm Database Configuration
|
||||
------------------------------
|
||||
|
||||
This project also provide a configuration which allow browse project's database from PyCharm (this is enabled only for `docker-compose -f debug.yml up`).
|
||||
|
||||
.. image:: pycharm_configuration/d1.png
|
||||
|
||||
|
||||
Nevertheless, if you don't have proper driver installer, this will not work. This is how you can install it:
|
||||
|
||||
.. image:: pycharm_configuration/d2.png
|
||||
.. image:: pycharm_configuration/d3.png
|
||||
|
||||
Known issues
|
||||
------------
|
||||
|
||||
Most of the files from `.idea/` were added to `.gitignore` with a few exceptions, which were made, to provide "ready to go" configuration. After adding remote interpreter some of these files are altered by PyCharm:
|
||||
|
||||
.. image:: pycharm_configuration/git1.png
|
||||
|
||||
In theory you can remove them from repository, but then, other people will lose a ability to initialize a project from provided configurations as you did. To get rid of this annoying state, you can run command::
|
||||
|
||||
$ git update-index --assume-unchanged .idea/deployment.xml .idea/webServers.xml
|
||||
|
|
Before Width: | Height: | Size: 45 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 86 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 57 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 37 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/6.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/7.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/8.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/d1.png
Normal file
After Width: | Height: | Size: 192 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/d2.png
Normal file
After Width: | Height: | Size: 188 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/d3.png
Normal file
After Width: | Height: | Size: 65 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/f1.png
Normal file
After Width: | Height: | Size: 158 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/f2.png
Normal file
After Width: | Height: | Size: 129 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/f3.png
Normal file
After Width: | Height: | Size: 133 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/f4.png
Normal file
After Width: | Height: | Size: 198 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/f5.png
Normal file
After Width: | Height: | Size: 162 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/f6.png
Normal file
After Width: | Height: | Size: 130 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/git1.png
Normal file
After Width: | Height: | Size: 67 KiB |