diff --git a/cookiecutter.json b/cookiecutter.json index 28d31fe36..9e75f14b3 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -15,6 +15,7 @@ "use_sentry": "n", "use_newrelic": "n", "use_opbeat": "n", + "use_pycharm": "n", "windows": "n", "use_python2": "n", "open_source_license": ["MIT", "BSD", "Not open source"] diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 107d6f98d..5efb3f67f 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -127,3 +127,7 @@ if '{{ cookiecutter.use_celery }}'.lower() == 'n': # 3. Copy files from /docs/ to {{ cookiecutter.repo_name }}/docs/ # copy_doc_files(PROJECT_DIRECTORY) + +if '{{cookiecutter.use_pycharm}}' != 'y': + shutil.rmtree(os.path.join(PROJECT_DIRECTORY, '.idea/')) + diff --git a/{{cookiecutter.repo_name}}/.gitignore b/{{cookiecutter.repo_name}}/.gitignore index 4b288b5b7..0ac2f0c84 100644 --- a/{{cookiecutter.repo_name}}/.gitignore +++ b/{{cookiecutter.repo_name}}/.gitignore @@ -37,8 +37,25 @@ htmlcov *.mo *.pot +{% if cookiecutter.use_pycharm == 'y' %} # Pycharm -.idea +.idea/* +!.idea/{{cookiecutter.repo_name}}.iml +!.idea/dataSources.xml +!.idea/dataSources.local.xml +!.idea/deployment.xml +!.idea/modules.xml +!.idea/webResources.xml +!.idea/webServers.xml +!.idea/runConfigurations +!.idea/runConfigurations/build.xml +!.idea/runConfigurations/compass.xml +!.idea/runConfigurations/Docker__*.xml +!.idea/runConfigurations/serve.xml +!.idea/runConfigurations/start_email_server.xml +!.idea/runConfigurations/stop_email_server.xml +!.idea/runConfigurations/watch.xml +{% endif %} # Vim diff --git a/{{cookiecutter.repo_name}}/.idea/dataSources.local.xml b/{{cookiecutter.repo_name}}/.idea/dataSources.local.xml new file mode 100644 index 000000000..66988a50e --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/dataSources.local.xml @@ -0,0 +1,11 @@ + + + + + master_key + postgres + postgres.pg_catalog postgres.public + postgres.pg_catalog postgres.public + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/dataSources.xml b/{{cookiecutter.repo_name}}/.idea/dataSources.xml new file mode 100644 index 000000000..a66c9b38d --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/dataSources.xml @@ -0,0 +1,12 @@ + + + + + postgresql + true + org.postgresql.Driver + jdbc:postgresql://localhost:25432/postgres + + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/modules.xml b/{{cookiecutter.repo_name}}/.idea/modules.xml new file mode 100644 index 000000000..21b6ceb82 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__migrate.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__migrate.xml new file mode 100644 index 000000000..a2777b0d6 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__migrate.xml @@ -0,0 +1,32 @@ + + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver.xml new file mode 100644 index 000000000..b4a02fb38 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver.xml @@ -0,0 +1,33 @@ + + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver_plus.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver_plus.xml new file mode 100644 index 000000000..6a12a1409 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__runserver_plus.xml @@ -0,0 +1,33 @@ + + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___all.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___all.xml new file mode 100644 index 000000000..d7ab31a33 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___all.xml @@ -0,0 +1,30 @@ + + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___class__TestUser.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___class__TestUser.xml new file mode 100644 index 000000000..eda236096 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___class__TestUser.xml @@ -0,0 +1,30 @@ + + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___file__test_models.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___file__test_models.xml new file mode 100644 index 000000000..bb59c33c4 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___file__test_models.xml @@ -0,0 +1,30 @@ + + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___module__users.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___module__users.xml new file mode 100644 index 000000000..4f1f13a30 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___module__users.xml @@ -0,0 +1,30 @@ + + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___specific__test_get_absolute_url.xml b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___specific__test_get_absolute_url.xml new file mode 100644 index 000000000..a6a121df8 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/runConfigurations/Docker__tests___specific__test_get_absolute_url.xml @@ -0,0 +1,30 @@ + + + + \ No newline at end of file diff --git a/{{cookiecutter.repo_name}}/.idea/webResources.xml b/{{cookiecutter.repo_name}}/.idea/webResources.xml new file mode 100644 index 000000000..e0fc860f5 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/webResources.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/{{cookiecutter.repo_name}}/.idea/{{cookiecutter.repo_name}}.iml b/{{cookiecutter.repo_name}}/.idea/{{cookiecutter.repo_name}}.iml new file mode 100644 index 000000000..6ae0a0626 --- /dev/null +++ b/{{cookiecutter.repo_name}}/.idea/{{cookiecutter.repo_name}}.iml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/{{cookiecutter.repo_name}}/compose/base/Dockerfile b/{{cookiecutter.repo_name}}/compose/base/Dockerfile new file mode 100644 index 000000000..7c68bfc93 --- /dev/null +++ b/{{cookiecutter.repo_name}}/compose/base/Dockerfile @@ -0,0 +1,22 @@ +FROM python:2.7 +ENV PYTHONUNBUFFERED 1 + +RUN apt-get update && \ + apt-get install -y ruby-compass && \ + rm -rf /var/lib/apt/lists/* + +# Install Node.js +RUN cd /tmp && \ + wget http://nodejs.org/dist/node-latest.tar.gz && \ + tar xvzf node-latest.tar.gz && \ + rm -f node-latest.tar.gz && \ + cd node-v* && \ + ./configure && \ + CXX="g++ -Wno-unused-local-typedefs" make && \ + CXX="g++ -Wno-unused-local-typedefs" make install && \ + cd /tmp && \ + rm -rf /tmp/node-v* && \ + npm install -g npm && \ + printf '\n# Node.js\nexport PATH="node_modules/.bin:$PATH"' >> /root/.bashrc + +RUN npm install -g grunt-cli diff --git a/{{cookiecutter.repo_name}}/compose/debug/Dockerfile b/{{cookiecutter.repo_name}}/compose/debug/Dockerfile new file mode 100644 index 000000000..37784d0b4 --- /dev/null +++ b/{{cookiecutter.repo_name}}/compose/debug/Dockerfile @@ -0,0 +1,17 @@ +FROM {{ cookiecutter.repo_name|replace('_', '') }}_django + +# Install OpenSSH +RUN apt-get update && \ + apt-get -y install openssh-server && \ + rm -rf /var/lib/apt/lists/* + +# sshd needs this directory to run +RUN mkdir -p /var/run/sshd + +# Copy configuration and entrypoint script +COPY sshd_config /etc/ssh/sshd_config + +EXPOSE 22 +EXPOSE 8000 + +ENTRYPOINT ["/app/compose/debug/entrypoint.sh"] diff --git a/{{cookiecutter.repo_name}}/compose/debug/entrypoint.sh b/{{cookiecutter.repo_name}}/compose/debug/entrypoint.sh new file mode 100755 index 000000000..48c979937 --- /dev/null +++ b/{{cookiecutter.repo_name}}/compose/debug/entrypoint.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +/app/compose/django/entrypoint.sh 'env > /tmp/environment' + +USER=docker_{{ cookiecutter.repo_name }} + +# rename django username to docker_{{ cookiecutter.repo_name }} +usermod -l $USER -m -d /home/$USER django +groupmod -n $USER django +sed -i "s/django/$USER/g" /tmp/environment + +mkdir /home/$USER/.ssh +cat /app/compose/debug/keys_to_docker/id_rsa.pub > /home/$USER/.ssh/authorized_keys + +chmod 755 /home/$USER +chmod 700 /home/$USER/.ssh +chmod 600 /home/$USER/.ssh/authorized_keys +cp /tmp/environment /home/$USER/.ssh/environment + +chown -R $USER:$USER /home/$USER + +echo "$USER:docker" | chpasswd + +service ssh start + +cat /app/compose/debug/welcome_msg + +sleep infinity diff --git a/{{cookiecutter.repo_name}}/compose/debug/keys_to_docker/id_rsa b/{{cookiecutter.repo_name}}/compose/debug/keys_to_docker/id_rsa new file mode 100644 index 000000000..4c0fd606e --- /dev/null +++ b/{{cookiecutter.repo_name}}/compose/debug/keys_to_docker/id_rsa @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpQIBAAKCAQEA00Y4OkYh+gRBpgtggWy3S2ym4syDQrbp2wCMIUJo8lfzGEv8 +b2LJAAC/dtPSnJoEX9FXTcN+4KXwZ+mGrv+BIfkRL7BiDPzIeitIt2XE6258d/y2 +G8H1V184WtSDofEcHFGXUYzjhstrn/XYmnIAYgHv8Rc9KCnlLr6biKo/KaR6YeAa +wqdoFM303PJEoDo2PDLUbhS8sgQwjZcQ/uoAdzboNpDaYvPgM3KmgBcHWkBPcUgT +TZkzbJ1Domqlq1LZAB+Yg3shGqIHwUVdb2G1tRtAMNg/XSXPXr1Ybi1sgYYRScLk +l7xVlV8Lzbpv3axZJ4HXWAA4I/L3y2337DkvkQIDAQABAoIBAQCmWfnX2HTUORm/ +teGMxp8kIi7dEQ6hLwi/SZUMcw/TEXD1Ro9C3NNKz0vyMiL470RWdax6LF3wYHgE +OZm0nLV+nG/tzsHFXBw2JXKiBN2iSmJyz2ZMQNH+s5jZ286xafkqSwwMSBS2g+EA +GEEuimjGwqO8fwHGaAZuYeJxHyuQiuSkpeMZiSCAAIRa64Lc9cA9KOF2Gel8D/ua +NsffhPxqSwKI1jxkgBXekvA4jQLaubQTU9VUkb9d4oiRctacPzu/TWojXrlqPfph +7ZcDXTPIp9aktHQtzcW6lBojIHAQGFxCaVIWFE5caOJVkxiz31VeFFHOt+n3I6dF +fB9maX6BAoGBAPSuH92uJSrvlcDsndBylW0v/rJHaFoYU3WVIO57N56z22bKRwCg +9Ew+WFfrboMbWk7uVLEzvVXuY3r1n+9uYT136ib3dLoGYArPlHO6qo8bpkTR1CkR +zYW91yHnHt7TW1HX1iq8zlhVEPW7cRn+1U7VORdNtsLDN02QGEuFM+65AoGBAN0M +c6vIpzfkGIUVoLI/o6sJ6n+aOCPSyORvG6UWdc7M9Hhsptqv1CCUfMADO+Hr6EKg +lBukZ9ixTh83MCzIKVcJhIaCKwf4loqDVnBGSpZh6jmR8M3XhkTYJXZ6s3Po9pXq +zsTK1YTplvNNWHmlDbR1YVPnbpfw898heIP1EhuZAoGBALqyGhJ2DFokkWmxogEp +TScRFhBGODN2mEgB0Czny9rGdcSK1359UarTb2k2dQ6I0nGjnO/RAMkOqs1pme2B +laTnWLz+2AwRTTsyhJ2Bcx7bBBVC3dWwhddksUBnL8DqGKXsQLg/dFsmHVjC+1vQ +fEY4n+VOIQOfHRWLu130d1nRAoGADgtwfgWtujtf43TQVQL+HyvuHlVqI7yMzxbQ +Jtkaex1CmzQsFdD+JWPJ2VlbQKuAgls5jdgQURBS6mDTSsUc+067gOBcY5FD32Eg +6NlOe+eUvjurlSiQe2dQWgrJxB+VK0lUAeTxVBSTZroPWQtHp6Odn3sg576DgDXc +NmYn1GECgYEA0N1ML106sS0BZauMhGvXMapNJgSg35z8TtbcHdgb+tkQigXM7g1c +4/MAHcEcs9c1iM6QtirefqUY6g5RFEIu0Wkmf6iwctmQQbMnrwB8yg+07HLahLim +SYMBxjdAP4SsmqHKU6Er9hRLvWlVKD1PtRYrhGpZpDq+PSPoQh0Kg8c= +-----END RSA PRIVATE KEY----- diff --git a/{{cookiecutter.repo_name}}/compose/debug/keys_to_docker/id_rsa.pub b/{{cookiecutter.repo_name}}/compose/debug/keys_to_docker/id_rsa.pub new file mode 100644 index 000000000..0e41ced2e --- /dev/null +++ b/{{cookiecutter.repo_name}}/compose/debug/keys_to_docker/id_rsa.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTRjg6RiH6BEGmC2CBbLdLbKbizINCtunbAIwhQmjyV/MYS/xvYskAAL9209KcmgRf0VdNw37gpfBn6Yau/4Eh+REvsGIM/Mh6K0i3ZcTrbnx3/LYbwfVXXzha1IOh8RwcUZdRjOOGy2uf9diacgBiAe/xFz0oKeUuvpuIqj8ppHph4BrCp2gUzfTc8kSgOjY8MtRuFLyyBDCNlxD+6gB3Nug2kNpi8+AzcqaAFwdaQE9xSBNNmTNsnUOiaqWrUtkAH5iDeyEaogfBRV1vYbW1G0Aw2D9dJc9evVhuLWyBhhFJwuSXvFWVXwvNum/drFkngddYADgj8vfLbffsOS+R pubkey2docker diff --git a/{{cookiecutter.repo_name}}/compose/debug/sshd_config b/{{cookiecutter.repo_name}}/compose/debug/sshd_config new file mode 100644 index 000000000..dfe7ae80e --- /dev/null +++ b/{{cookiecutter.repo_name}}/compose/debug/sshd_config @@ -0,0 +1,83 @@ +# What ports, IPs and protocols we listen for +Port 22 + +# The option AllowUsers specifies and controls which users can access ssh +# services. Multiple users can be specified, separated by spaces. +#AllowUsers SystemUsername/ + +Protocol 2 + +# The option ListenAddress specifies the IP address of the interface network +# on which the ssh daemon server socket is bind. The default is 0.0.0.0; to +# improve security you may specify only the required ones to limit possible +# addresses. +ListenAddress 0.0.0.0 + +# The option HostKey specifies the location containing the private host key. +HostKey /etc/ssh/ssh_host_rsa_key +HostKey /etc/ssh/ssh_host_dsa_key + +# The option SyslogFacility specifies the facility code used when logging +# messages from sshd. The facility specifies the subsystem that produced the +# message--in our case, AUTH. +SyslogFacility AUTH + +# The option LogLevel specifies the level that is used when logging messages +# from sshd.INFO is a good choice. See the man page for sshd for more +# information on other possibilities. +LogLevel INFO + +UsePrivilegeSeparation yes + +# The option LoginGraceTime specifies how long in seconds after a connection +# request the server will wait before disconnecting if the user has not +# successfully logged in. +LoginGraceTime 120 + +# The option PermitRootLogin specifies whether root can log in using ssh. +# Never say yes to this option. +PermitRootLogin no + +# The option StrictModes specifies whether ssh should check user's permissions +# in their home directory and rhosts files before accepting login. This option +# must always be set to yes because sometimes users may accidentally leave +# their directory or files world-writable. +StrictModes yes + +PubkeyAuthentication yes +PasswordAuthentication yes +RSAAuthentication no +HostbasedAuthentication no + +# The option IgnoreRhosts specifies whether rhosts or shosts files should not +# be used in authentication. For security reasons it is recommended to no use +# rhosts or shosts files for authentication. +IgnoreRhosts yes + +# The option RhostsRSAAuthentication specifies whether to try rhosts +# authentication in concert with RSA host authentication. +RhostsRSAAuthentication no + +# The option PermitEmptyPasswords specifies whether the server allows logging +# in to accounts with a null password. If you intend to use the scp utility +# to make automatic backups over the network, you must set this option to yes +PermitEmptyPasswords no + +# Specifies the maximum number of concurrent unauthenticated connections to +# the SSH daemon. Additional connections will be dropped until authentication +# succeeds or the LoginGraceTime expires for a connection. +MaxStartups 10:30:60 + +#Subsystem sftp /usr/lib/openssh/sftp-server +Subsystem sftp internal-sftp + +# The option PrintMotd specifies whether the ssh daemon should print the +# contents of the /etc/motd file when a user logs in interactively. The +# /etc/motd file is also known as the message of the day. +PrintMotd no + +KeepAlive yes +PrintLastLog yes +UsePAM yes + +PermitUserEnvironment yes diff --git a/{{cookiecutter.repo_name}}/compose/debug/welcome_msg b/{{cookiecutter.repo_name}}/compose/debug/welcome_msg new file mode 100644 index 000000000..4b3c5b8ed --- /dev/null +++ b/{{cookiecutter.repo_name}}/compose/debug/welcome_msg @@ -0,0 +1,12 @@ + +You can now debug your project remotly using ssh connection: + + User: docker_light + Password: docker + +You can also login without password, using debug-only ssh key: + + $ ssh -i compose/debug/keys_to_docker/id_rsa docker_{{ cookiecutter.repo_name }}@localhost -p 2222 + +Read more about remote debugging with various IDE (PyCharm, etc) in docs/docker_remote_debugging.rst + diff --git a/{{cookiecutter.repo_name}}/compose/django/gunicorn.sh b/{{cookiecutter.repo_name}}/compose/django/gunicorn.sh old mode 100644 new mode 100755 diff --git a/{{cookiecutter.repo_name}}/config/settings/common.py b/{{cookiecutter.repo_name}}/config/settings/common.py index d9e5e0e94..f21089f71 100644 --- a/{{cookiecutter.repo_name}}/config/settings/common.py +++ b/{{cookiecutter.repo_name}}/config/settings/common.py @@ -99,7 +99,7 @@ MANAGERS = ADMINS # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = { # Raises ImproperlyConfigured exception if DATABASE_URL not in os.environ - 'default': env.db("DATABASE_URL", default="postgres://{% if cookiecutter.windows == 'y' %}localhost{% endif %}/{{cookiecutter.repo_name}}"), + 'default': env.db('DATABASE_URL', default='postgres://{% if cookiecutter.windows == "y" %}localhost{% endif %}/{{cookiecutter.repo_name}}'), } DATABASES['default']['ATOMIC_REQUESTS'] = True diff --git a/{{cookiecutter.repo_name}}/dev.yml b/{{cookiecutter.repo_name}}/dev.yml index b48f53c89..674f14228 100644 --- a/{{cookiecutter.repo_name}}/dev.yml +++ b/{{cookiecutter.repo_name}}/dev.yml @@ -25,3 +25,16 @@ services: - "8000:8000" links: - postgres + + pycharm: + build: + context: . + dockerfile: Dockerfile-dev + depends_on: + - postgres + environment: + - POSTGRES_USER={{cookiecutter.repo_name}} + volumes: + - .:/app + links: + - postgres 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..995558e22 --- /dev/null +++ b/{{cookiecutter.repo_name}}/docs/docker_remote_debugging.rst @@ -0,0 +1,120 @@ +Docker Remote Debugging +======================= + +To connect to python remote interpreter, ssh connection has to be established. You may have heard about article |docker-ssh-considered-evil|_ + +.. _docker-ssh-considered-evil: https://jpetazzo.github.io/2014/06/23/docker-ssh-considered-evil/ +.. |docker-ssh-considered-evil| replace:: *If you run SSHD in your Docker containers, you're doing it wrong!* + + +There is a better tool to login into container if you want to access to shell, i.e. `docker exec`_. However, connecting to remote interpreter is a different thing, much more difficult. You can read more about `attempts on StackOverflow`_. + +.. _docker exec: https://docs.docker.com/reference/commandline/exec/ +.. _attempts on StackOverflow: http://stackoverflow.com/a/28675525/338581 + +To avoid putting sshd into production-ready docker image, we create another docker image on top of main ``{{ cookiecutter.repo_name|replace('_', '') }}_django`` image from `compose/debug/Dockerfile <../compose/debug/Dockerfile>`_. That's why you have to first build main `Dockerfile <../Dockerfile>`_, and you can do that by:: + + $ docker-compose -f dev.yml build + +After that, you can build and run debug container:: + + $ docker-compose -f debug.yml build + $ 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. + +You can test ssh conection using password *docker*, by:: + + ssh docker_{{ cookiecutter.repo_name }}@localhost -p 2222 + +or you can also use ssh-key:: + + ssh -i compose/debug/keys_to_docker/id_rsa docker_{{ cookiecutter.repo_name }}@localhost -p 2222 + + +PyCharm +^^^^^^^ + +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 +----------------------------------- + +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 diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/1.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/1.png new file mode 100644 index 000000000..062dee2cd Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/1.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/2.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/2.png new file mode 100644 index 000000000..4e78bb4d1 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/2.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/3.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/3.png new file mode 100644 index 000000000..f82e21661 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/3.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/4.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/4.png new file mode 100644 index 000000000..8bdf7c12b Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/4.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/5.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/5.png new file mode 100644 index 000000000..6d48310f8 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/5.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/6.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/6.png new file mode 100644 index 000000000..adac762be Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/6.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/7.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/7.png new file mode 100644 index 000000000..35c88dca7 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/7.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/8.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/8.png new file mode 100644 index 000000000..9fca63a84 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/8.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/d1.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/d1.png new file mode 100644 index 000000000..51a1fdc19 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/d1.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/d2.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/d2.png new file mode 100644 index 000000000..c2201ba83 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/d2.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/d3.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/d3.png new file mode 100644 index 000000000..dc7bda3b6 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/d3.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f1.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f1.png new file mode 100644 index 000000000..43f891eeb Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f1.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f2.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f2.png new file mode 100644 index 000000000..144797f8a Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f2.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f3.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f3.png new file mode 100644 index 000000000..eb2933d9b Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f3.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f4.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f4.png new file mode 100644 index 000000000..34bb2c006 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f4.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f5.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f5.png new file mode 100644 index 000000000..014741582 Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f5.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f6.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f6.png new file mode 100644 index 000000000..17db0daca Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/f6.png differ diff --git a/{{cookiecutter.repo_name}}/docs/pycharm_configuration/git1.png b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/git1.png new file mode 100644 index 000000000..fdbc2085b Binary files /dev/null and b/{{cookiecutter.repo_name}}/docs/pycharm_configuration/git1.png differ diff --git a/{{cookiecutter.repo_name}}/package.json b/{{cookiecutter.repo_name}}/package.json index c5846fd73..bf85efb93 100644 --- a/{{cookiecutter.repo_name}}/package.json +++ b/{{cookiecutter.repo_name}}/package.json @@ -4,6 +4,7 @@ "dependencies": {}, "devDependencies": { "grunt": "~0.4.5", + "grunt-cli": "^0.1.13", "grunt-contrib-watch": "~0.6.1", "grunt-bg-shell": "~2.3.1", "connect-livereload": "~0.3.2",