Merge 1b1c02cc40
into 1616332af6
|
@ -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"]
|
||||
|
|
|
@ -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/'))
|
||||
|
||||
|
|
19
{{cookiecutter.repo_name}}/.gitignore
vendored
|
@ -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
|
||||
|
||||
|
|
11
{{cookiecutter.repo_name}}/.idea/dataSources.local.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="dataSourceStorageLocal">
|
||||
<data-source name="PostgreSQL - postgres@localhost" uuid="4591ae40-df2d-47bb-b164-7130902f1eac">
|
||||
<secret-storage>master_key</secret-storage>
|
||||
<user-name>postgres</user-name>
|
||||
<schema-pattern>postgres.pg_catalog postgres.public</schema-pattern>
|
||||
<default-schemas>postgres.pg_catalog postgres.public</default-schemas>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
12
{{cookiecutter.repo_name}}/.idea/dataSources.xml
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" hash="1472382126">
|
||||
<data-source source="LOCAL" name="PostgreSQL - postgres@localhost" uuid="4591ae40-df2d-47bb-b164-7130902f1eac">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql://localhost:25432/postgres</jdbc-url>
|
||||
<libraries />
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
8
{{cookiecutter.repo_name}}/.idea/modules.xml
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/{{ cookiecutter.repo_name }}.iml" filepath="$PROJECT_DIR$/.idea/{{ cookiecutter.repo_name }}.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,32 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: migrate" type="Python.DjangoServer" factoryName="Django server" singleton="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://$PROJECT_DIR$/dev.yml:pycharm/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.repo_name }}" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="launchJavascriptDebuger" value="false" />
|
||||
<option name="host" value="" />
|
||||
<option name="additionalOptions" value="" />
|
||||
<option name="browserUrl" value="" />
|
||||
<option name="runTestServer" value="false" />
|
||||
<option name="runNoReload" value="false" />
|
||||
<option name="useCustomRunCommand" value="true" />
|
||||
<option name="customRunCommand" value="migrate" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,33 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: runserver" type="Python.DjangoServer" factoryName="Django server" singleton="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://$PROJECT_DIR$/dev.yml:django/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.repo_name }}" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="launchJavascriptDebuger" value="false" />
|
||||
<option name="port" value="8000" />
|
||||
<option name="host" value="0.0.0.0" />
|
||||
<option name="additionalOptions" value="" />
|
||||
<option name="browserUrl" value="" />
|
||||
<option name="runTestServer" value="false" />
|
||||
<option name="runNoReload" value="false" />
|
||||
<option name="useCustomRunCommand" value="false" />
|
||||
<option name="customRunCommand" value="" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,33 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: runserver_plus" type="Python.DjangoServer" factoryName="Django server" singleton="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://$PROJECT_DIR$/dev.yml:django/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.repo_name }}" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="launchJavascriptDebuger" value="false" />
|
||||
<option name="port" value="8000" />
|
||||
<option name="host" value="0.0.0.0" />
|
||||
<option name="additionalOptions" value="" />
|
||||
<option name="browserUrl" value="" />
|
||||
<option name="runTestServer" value="false" />
|
||||
<option name="runNoReload" value="false" />
|
||||
<option name="useCustomRunCommand" value="true" />
|
||||
<option name="customRunCommand" value="runserver_plus" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,30 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - all" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://$PROJECT_DIR$/dev.yml:pycharm/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="false" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.repo_name }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="TARGET" value="." />
|
||||
<option name="SETTINGS_FILE" value="" />
|
||||
<option name="CUSTOM_SETTINGS" value="false" />
|
||||
<option name="USE_OPTIONS" value="false" />
|
||||
<option name="OPTIONS" value="" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,30 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - class: TestUser" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://$PROJECT_DIR$/dev.yml:pycharm/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.repo_name }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="TARGET" value="{{ cookiecutter.repo_name }}.users.tests.test_models.TestUser" />
|
||||
<option name="SETTINGS_FILE" value="" />
|
||||
<option name="CUSTOM_SETTINGS" value="false" />
|
||||
<option name="USE_OPTIONS" value="false" />
|
||||
<option name="OPTIONS" value="" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,30 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - file: test_models" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://$PROJECT_DIR$/dev.yml:pycharm/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.repo_name }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="TARGET" value="{{ cookiecutter.repo_name }}.users.tests.test_models" />
|
||||
<option name="SETTINGS_FILE" value="" />
|
||||
<option name="CUSTOM_SETTINGS" value="false" />
|
||||
<option name="USE_OPTIONS" value="false" />
|
||||
<option name="OPTIONS" value="" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,30 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - module: users" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://$PROJECT_DIR$/dev.yml:pycharm/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.repo_name }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="TARGET" value="{{ cookiecutter.repo_name }}.users" />
|
||||
<option name="SETTINGS_FILE" value="" />
|
||||
<option name="CUSTOM_SETTINGS" value="false" />
|
||||
<option name="USE_OPTIONS" value="false" />
|
||||
<option name="OPTIONS" value="" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
|
@ -0,0 +1,30 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Docker: tests - specific: test_get_absolute_url" type="DjangoTestsConfigurationType" factoryName="Django tests" singleton="true">
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
<env name="DJANGO_SETTINGS_MODULE" value="config.settings.local" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="docker-compose://$PROJECT_DIR$/dev.yml:pycharm/python" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<module name="{{ cookiecutter.repo_name }}" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" runner="coverage.py" />
|
||||
<PathMappingSettings>
|
||||
<option name="pathMappings">
|
||||
<list>
|
||||
<mapping local-root="$PROJECT_DIR$" remote-root="/app" />
|
||||
</list>
|
||||
</option>
|
||||
</PathMappingSettings>
|
||||
<option name="TARGET" value="{{ cookiecutter.repo_name }}.users.tests.test_models.TestUser.test_get_absolute_url" />
|
||||
<option name="SETTINGS_FILE" value="" />
|
||||
<option name="CUSTOM_SETTINGS" value="false" />
|
||||
<option name="USE_OPTIONS" value="false" />
|
||||
<option name="OPTIONS" value="" />
|
||||
<method />
|
||||
</configuration>
|
||||
</component>
|
14
{{cookiecutter.repo_name}}/.idea/webResources.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="WebResourcesPaths">
|
||||
<contentEntries>
|
||||
<entry url="file://$PROJECT_DIR$">
|
||||
<entryData>
|
||||
<resourceRoots>
|
||||
<path value="file://$PROJECT_DIR$/{{ cookiecutter.repo_name }}/static" />
|
||||
</resourceRoots>
|
||||
</entryData>
|
||||
</entry>
|
||||
</contentEntries>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="django" name="Django">
|
||||
<configuration>
|
||||
<option name="rootFolder" value="$MODULE_DIR$" />
|
||||
<option name="settingsModule" value="config/settings/local.py" />
|
||||
<option name="manageScript" value="manage.py" />
|
||||
<option name="environment" value="<map/>" />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<excludeFolder url="file://$MODULE_DIR$/.idea" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.sass-cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/node_modules" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Remote Python 2.7.11 Docker Compose" jdkType="Python SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="TemplatesService">
|
||||
<option name="TEMPLATE_CONFIGURATION" value="Django" />
|
||||
<option name="TEMPLATE_FOLDERS">
|
||||
<list>
|
||||
<option value="$MODULE_DIR$/{{ cookiecutter.repo_name }}/templates" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</module>
|
22
{{cookiecutter.repo_name}}/compose/base/Dockerfile
Normal file
|
@ -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
|
17
{{cookiecutter.repo_name}}/compose/debug/Dockerfile
Normal file
|
@ -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"]
|
28
{{cookiecutter.repo_name}}/compose/debug/entrypoint.sh
Executable file
|
@ -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
|
|
@ -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-----
|
|
@ -0,0 +1 @@
|
|||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDTRjg6RiH6BEGmC2CBbLdLbKbizINCtunbAIwhQmjyV/MYS/xvYskAAL9209KcmgRf0VdNw37gpfBn6Yau/4Eh+REvsGIM/Mh6K0i3ZcTrbnx3/LYbwfVXXzha1IOh8RwcUZdRjOOGy2uf9diacgBiAe/xFz0oKeUuvpuIqj8ppHph4BrCp2gUzfTc8kSgOjY8MtRuFLyyBDCNlxD+6gB3Nug2kNpi8+AzcqaAFwdaQE9xSBNNmTNsnUOiaqWrUtkAH5iDeyEaogfBRV1vYbW1G0Aw2D9dJc9evVhuLWyBhhFJwuSXvFWVXwvNum/drFkngddYADgj8vfLbffsOS+R pubkey2docker
|
83
{{cookiecutter.repo_name}}/compose/debug/sshd_config
Normal file
|
@ -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
|
12
{{cookiecutter.repo_name}}/compose/debug/welcome_msg
Normal file
|
@ -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
|
||||
|
0
{{cookiecutter.repo_name}}/compose/django/gunicorn.sh
Normal file → Executable file
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
120
{{cookiecutter.repo_name}}/docs/docker_remote_debugging.rst
Normal file
|
@ -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
|
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/1.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/2.png
Normal file
After Width: | Height: | Size: 86 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/3.png
Normal file
After Width: | Height: | Size: 93 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/4.png
Normal file
After Width: | Height: | Size: 53 KiB |
BIN
{{cookiecutter.repo_name}}/docs/pycharm_configuration/5.png
Normal file
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 |
|
@ -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",
|
||||
|
|