diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..4899c4f91 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,32 @@ +**Note: for support questions, please use the `cookiecutter-django` tag on stackoverflow**. This repository's issues are reserved for feature requests and bug reports. If you need quick professional paid support for your project, contact support@cookiecutter.io. + +* **I'm submitting a ... ** + - [ ] bug report + - [ ] feature request + - [ ] support request => Please do not submit support request here, see note at the top of this template. + + +* **Do you want to request a *feature* or report a *bug*?** + + + +* **What is the current behavior?** + + + +* **If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem** + + +* **What is the expected behavior?** + + + +* **What is the motivation / use case for changing the behavior?** + + + +* **Please tell us about your environment:** + + + +* **Other information** (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc) diff --git a/.gitignore b/.gitignore index 393a1968c..1f80de173 100644 --- a/.gitignore +++ b/.gitignore @@ -1,44 +1,228 @@ -### OSX ### -.DS_Store -.AppleDouble -.LSOverride +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class -### SublimeText ### -# cache files for sublime text +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage.* +.cache/ +nosetests.xml +coverage.xml +*.cover +.hypothesis/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# Environments +.env +.venv +env/ +venv/ +ENV/ + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + + +### Linux template +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + + +### VisualStudioCode template +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + + +### Windows template +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msm +*.msp + +# Windows shortcuts +*.lnk + + +### SublimeText template +# Cache files for Sublime Text *.tmlanguage.cache *.tmPreferences.cache *.stTheme.cache -# workspace files are user-specific +# Workspace files are user-specific *.sublime-workspace -# project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using SublimeText +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text # *.sublime-project -# sftp configuration file +# SFTP configuration file sftp-config.json -# Generated files -*.log -*.pot -*.pyc -.idea -_build -*.egg-info/ +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache -# Project Specific Stuff -local_settings.py -project_slug -my_test_project/* +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings -# Generated when running py.test for the Cookiecutter Django generation tests -.cache/ -# Generated when running celery beat -celerybeat-schedule.db +### macOS template +# General +*.DS_Store +.AppleDouble +.LSOverride -# Unit test / coverage reports -.coverage -.tox -.cache +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### Vim template +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] + +# Session +Session.vim + +# Temporary +.netrwhist +# Auto-generated tag files +tags + + +### VirtualEnv template +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +pip-selfcheck.json + + +# Even though the project might be opened and edited +# in any of the JetBrains IDEs, it makes no sence whatsoever +# to 'run' anything within it since any particular cookiecutter +# is declarative by nature. +.idea/ diff --git a/CONTRIBUTORS.rst b/CONTRIBUTORS.rst index 60a299759..e46c5209a 100644 --- a/CONTRIBUTORS.rst +++ b/CONTRIBUTORS.rst @@ -63,7 +63,8 @@ Listed in alphabetical order. Bo Lopker `@blopker`_ Bouke Haarsma Brent Payne `@brentpayne`_ @brentpayne - Burhan Khalid `@burhan`_ @burhan + Bruno Alla               `@browniebroke`_ @_BrunoAlla + Burhan Khalid            `@burhan`_                   @burhan Catherine Devlin `@catherinedevlin`_ Cédric Gaspoz `@cgaspoz`_ Chris Curvey `@ccurvey`_ @@ -145,6 +146,7 @@ Listed in alphabetical order. Travis McNeill `@Travistock`_ @tavistock_esq Vitaly Babiy Vivian Guillen `@viviangb`_ + Wan Liuyang `@sfdye`_ @sfdye Will Farley `@goldhand`_ @g01dhand William Archinal `@archinal`_ Yaroslav Halchenko @@ -165,6 +167,7 @@ Listed in alphabetical order. .. _@bloodpet: https://github.com/bloodpet .. _@blopker: https://github.com/blopker .. _@bogdal: https://github.com/bogdal +.. _@browniebroke: https://github.com/browniebroke .. _@burhan: https://github.com/burhan .. _@c-rhodes: https://github.com/c-rhodes .. _@caffodian: https://github.com/caffodian @@ -221,6 +224,7 @@ Listed in alphabetical order. .. _@shireenrao: https://github.com/shireenrao .. _@webyneter: https://github.com/webyneter .. _@show0k: https://github.com/show0k +.. _@sfdye: https://github.com/sfdye .. _@shultz: https://github.com/shultz .. _@siauPatrick: https://github.com/siauPatrick .. _@slafs: https://github.com/slafs diff --git a/README.rst b/README.rst index 9f2af8495..2b239f784 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,9 @@ Powered by Cookiecutter_, Cookiecutter Django is a framework for jumpstarting pr * Documentation: https://cookiecutter-django.readthedocs.io/en/latest/ * See Troubleshooting_ for common errors and obstacles -* If you have problems with Cookiecutter Django, please open issues_ before sending emails to the maintainers. You will get a much, MUCH faster response. +* If you have problems with Cookiecutter Django, please open issues_ don't send emails to the maintainers. +* Need quick professional paid support? Contact `support@cookiecutter.io`_. This includes configuring your servers, +fixing bugs, reviewing your code and everything in between. .. _cookiecutter: https://github.com/audreyr/cookiecutter @@ -24,6 +26,7 @@ Powered by Cookiecutter_, Cookiecutter Django is a framework for jumpstarting pr .. _528: https://github.com/pydanny/cookiecutter-django/issues/528#issuecomment-212650373 .. _issues: https://github.com/pydanny/cookiecutter-django/issues/new +.. _support@cookiecutter.io: support@cookiecutter.io Features --------- @@ -40,7 +43,7 @@ Features * Grunt build for compass and livereload * Send emails via Anymail_ (using Mailgun_ by default, but switchable) * Media storage using Amazon S3 -* Docker support using docker-compose_ for development and production +* Docker support using docker-compose_ for development and production (using Caddy_ with LetsEncrypt_ support) * Procfile_ for deploying to Heroku * Instructions for deploying to PythonAnywhere_ * Run tests with unittest or py.test @@ -76,7 +79,8 @@ Optional Integrations .. _docker-compose: https://github.com/docker/compose .. _Opbeat: https://opbeat.com/ .. _PythonAnywhere: https://www.pythonanywhere.com/ - +.. _Caddy: https://caddyserver.com/ +.. _LetsEncrypt: https://letsencrypt.org/ Constraints ----------- @@ -171,7 +175,6 @@ Answer the prompts with your own desired options_. For example:: 2 - Grunt 3 - None Choose from 1, 2, 3, 4 [1]: 1 - use_lets_encrypt [n]: n Select open_source_license: 1 - MIT 2 - BSD diff --git a/cookiecutter.json b/cookiecutter.json index 5b443493c..8addeeada 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -20,7 +20,6 @@ "use_compressor": "n", "postgresql_version": ["9.6", "9.5", "9.4", "9.3", "9.2"], "js_task_runner": ["Gulp", "Grunt", "None"], - "use_lets_encrypt": "n", "custom_bootstrap_compilation": "n", "open_source_license": ["MIT", "BSD", "GPLv3", "Apache Software License 2.0", "Not open source"] } diff --git a/docs/deployment-with-docker.rst b/docs/deployment-with-docker.rst index cb428e8f4..fb383c3c5 100644 --- a/docs/deployment-with-docker.rst +++ b/docs/deployment-with-docker.rst @@ -17,7 +17,7 @@ of this application gets its configuration from. Notice how it provides configur * `postgres` service that runs the database * `redis` for caching -* `nginx` as reverse proxy +* `caddy` as webserver * `django` is the Django project run by gunicorn If you chose the `use_celery` option, there are two more services: @@ -25,10 +25,6 @@ If you chose the `use_celery` option, there are two more services: * `celeryworker` which runs the celery worker process * `celerybeat` which runs the celery beat process -If you chose the `use_letsencrypt` option, you also have: - -* `certbot` which keeps your certs from letsencrypt up-to-date - Populate .env With Your Environment Variables --------------------------------------------- @@ -57,66 +53,24 @@ It is always better to deploy a site behind HTTPS and will become crucial as the * If you are not using a subdomain of the domain name set in the project, then remember to put the your staging/production IP address in the :code:`DJANGO_ALLOWED_HOSTS` environment variable (see :ref:`settings`) before you deploy your website. Failure to do this will mean you will not have access to your website through the HTTP protocol. -* Access to the Django admin is set up by default to require HTTPS in production or once *live*. We recommend that you look into setting up the *Certbot and Let's Encrypt Setup* mentioned below or another HTTPS certification service. +* Access to the Django admin is set up by default to require HTTPS in production or once *live*. -Optional: nginx-proxy Setup ---------------------------- -By default, the application is configured to listen on all interfaces on port 80. If you want to change that, open the -`production.yml` file and replace `0.0.0.0` with your own ip. +HTTPS is configured by default +------------------------------ -If you are using `nginx-proxy`_ to run multiple application stacks on one host, remove the port setting entirely and add `VIRTUAL_HOST=example.com` to your env file. Here, replace example.com with the value you entered for `domain_name`. +The Caddy webserver used in the default configuration will get you a valid certificate from Lets Encrypt and update it automatically. All you need to do to enable this is to make sure that your DNS records are pointing to the server Caddy runs on. -This pass all incoming requests on `nginx-proxy`_ to the nginx service your application is using. +You can read more about this here at `Automatic HTTPS`_ in the Caddy docs. + +.. _Automatic HTTPS: https://caddyserver.com/docs/automatic-https -.. _nginx-proxy: https://github.com/jwilder/nginx-proxy Optional: Postgres Data Volume Modifications --------------------------------------------- Postgres is saving its database files to the `postgres_data` volume by default. Change that if you want something else and make sure to make backups since this is not done automatically. -Optional: Certbot and Let's Encrypt Setup ------------------------------------------- - -If you chose `use_letsencrypt` and will be using certbot for https, you must do the following before running anything with docker-compose: - -Replace dhparam.pem.example with a generated dhparams.pem file before running anything with docker-compose. You can generate this on ubuntu or OS X by running the following in the project root: - -:: - - $ openssl dhparam -out /path/to/project/compose/nginx/dhparams.pem 2048 - -If you would like to add additional subdomains to your certificate, you must add additional parameters to the certbot command in the `production.yml` file: - -Replace: - -:: - - command: bash -c "sleep 6 && certbot certonly -n --standalone -d {{ cookiecutter.domain_name }} --test --agree-tos --email {{ cookiecutter.email }} --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose --keep-until-expiring --preferred-challenges http-01" - -With: - -:: - - command: bash -c "sleep 6 && certbot certonly -n --standalone -d {{ cookiecutter.domain_name }} -d www.{{ cookiecutter.domain_name }} -d etc.{{ cookiecutter.domain_name }} --test --agree-tos --email {{ cookiecutter.email }} --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose --keep-until-expiring --preferred-challenges http-01" - -Please be cognizant of Certbot/Letsencrypt certificate requests limits when getting this set up. The provide a test server that does not count against the limit while you are getting set up. - -The certbot certificates expire after 3 months. -If you would like to set up autorenewal of your certificates, the following commands can be put into a bash script: - -:: - - #!/bin/bash - cd - docker-compose -f production.yml run --rm --name certbot certbot bash -c "sleep 6 && certbot certonly --standalone -d {{ cookiecutter.domain_name }} --test --agree-tos --email {{ cookiecutter.email }} --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose --keep-until-expiring --preferred-challenges http-01" - docker exec {{ cookiecutter.project_name }}_nginx_1 nginx -s reload - -And then set a cronjob by running `crontab -e` and placing in it (period can be adjusted as desired):: - - 0 4 * * 1 /path/to/bashscript/renew_certbot.sh - Run your app with docker-compose -------------------------------- @@ -154,7 +108,7 @@ If you want to scale your application, run:: docker-compose -f production.yml scale django=4 docker-compose -f production.yml scale celeryworker=2 -.. warning:: Don't run the scale command on postgres, celerybeat, certbot, or nginx. +.. warning:: Don't run the scale command on postgres, celerybeat, or caddy. If you have errors, you can always check your stack with `docker-compose`. Switch to your projects root directory and run:: diff --git a/docs/live-reloading-and-sass-compilation.rst b/docs/live-reloading-and-sass-compilation.rst index 5996bc327..7f978ede5 100644 --- a/docs/live-reloading-and-sass-compilation.rst +++ b/docs/live-reloading-and-sass-compilation.rst @@ -21,4 +21,4 @@ The base app will now run as it would with the usual ``manage.py runserver`` but To get live reloading to work you'll probably need to install an `appropriate browser extension`_ -.. _appropriate browser extension: http://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions- +.. _appropriate browser extension: http://livereload.com/extensions/ diff --git a/docs/project-generation-options.rst b/docs/project-generation-options.rst index 5ada6a3fa..5a0cffe65 100644 --- a/docs/project-generation-options.rst +++ b/docs/project-generation-options.rst @@ -72,8 +72,8 @@ js_task_runner [1] 2. Grunt_ 3. None -use_lets_encrypt [n] - Use `Let's Encrypt`_ as the certificate authority for this project. +custom_bootstrap_compilation [n] + If you use Grunt, scaffold out recompiling Bootstrap as as task. (Useful for letting you change Bootstrap variables in real time.) Consult project README for more details. open_source_license [1] Select a software license for the project. The choices are: diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index c8ac16aaf..c9fb43972 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -167,14 +167,6 @@ def remove_packageJSON_file(): PROJECT_DIRECTORY, filename )) -def remove_certbot_files(): - """ - Removes files needed for certbot if it isn't going to be used - """ - nginx_dir_location = os.path.join(PROJECT_DIRECTORY, 'compose/nginx') - for filename in ["nginx-secure.conf", "start.sh", "dhparams.example.pem"]: - file_name = os.path.join(nginx_dir_location, filename) - remove_file(file_name) def remove_copying_files(): """ @@ -229,26 +221,26 @@ def remove_open_source_files(): # dst = os.path.join(target_dir, name) # shutil.copyfile(src, dst) -# 1. Generates and saves random secret key +# Generates and saves random secret key make_secret_key(PROJECT_DIRECTORY) -# 2. Removes the taskapp if celery isn't going to be used +# Removes the taskapp if celery isn't going to be used if '{{ cookiecutter.use_celery }}'.lower() == 'n': remove_task_app(PROJECT_DIRECTORY) -# 3. Removes the .idea directory if PyCharm isn't going to be used +# Removes the .idea directory if PyCharm isn't going to be used if '{{ cookiecutter.use_pycharm }}'.lower() != 'y': remove_pycharm_dir(PROJECT_DIRECTORY) -# 4. Removes all heroku files if it isn't going to be used +# Removes all heroku files if it isn't going to be used if '{{ cookiecutter.use_heroku }}'.lower() != 'y': remove_heroku_files() -# 5. Removes all docker files if it isn't going to be used +# Removes all docker files if it isn't going to be used if '{{ cookiecutter.use_docker }}'.lower() != 'y': remove_docker_files() -# 6. Removes all JS task manager files if it isn't going to be used +# Removes all JS task manager files if it isn't going to be used if '{{ cookiecutter.js_task_runner}}'.lower() == 'gulp': remove_grunt_files() elif '{{ cookiecutter.js_task_runner}}'.lower() == 'grunt': @@ -257,11 +249,7 @@ else: remove_gulp_files() remove_grunt_files() -# 7. Removes all certbot/letsencrypt files if it isn't going to be used -if '{{ cookiecutter.use_lets_encrypt }}'.lower() != 'y': - remove_certbot_files() - -# 8. Display a warning if use_docker and use_grunt are selected. Grunt isn't +# Display a warning if use_docker and use_grunt are selected. Grunt isn't # supported by our docker config atm. if '{{ cookiecutter.js_task_runner }}'.lower() in ['grunt'] and '{{ cookiecutter.use_docker }}'.lower() == 'y': print( @@ -269,29 +257,15 @@ if '{{ cookiecutter.js_task_runner }}'.lower() in ['grunt'] and '{{ cookiecutter "can continue to use the project like you normally would, but you will need to setup Grunt manually." ) -# 9. Removes the certbot/letsencrypt files and display a warning if use_lets_encrypt is selected and use_docker isn't. -if '{{ cookiecutter.use_lets_encrypt }}'.lower() == 'y' and '{{ cookiecutter.use_docker }}'.lower() != 'y': - remove_certbot_files() - print( - "You selected to use Let's Encrypt and didn't select to use docker. This is NOT supported out of the box for now. You " - "can continue to use the project like you normally would, but Let's Encrypt files have been included." - ) -# 10. Directs the user to the documentation if certbot and docker are selected. -if '{{ cookiecutter.use_lets_encrypt }}'.lower() == 'y' and '{{ cookiecutter.use_docker }}'.lower() == 'y': - print( - "You selected to use Let's Encrypt, please see the documentation for instructions on how to use this in production. " - "You must generate a dhparams.pem file before running docker-compose in a production environment." - ) - -# 11. Removes files needed for the GPLv3 licence if it isn't going to be used. +# Removes files needed for the GPLv3 licence if it isn't going to be used. if '{{ cookiecutter.open_source_license}}' != 'GPLv3': remove_copying_files() -# 12. Remove Elastic Beanstalk files +# Remove Elastic Beanstalk files if '{{ cookiecutter.use_elasticbeanstalk_experimental }}'.lower() != 'y': remove_elasticbeanstalk() -# 13. Remove files conventional to opensource projects only. +# Remove files conventional to opensource projects only. if '{{ cookiecutter.open_source_license }}' == 'Not open source': remove_open_source_files() diff --git a/requirements.txt b/requirements.txt index 28095be3c..b6f1a0af3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ cookiecutter==1.5.1 flake8==3.4.1 # pyup: != 2.6.0 sh==1.12.14 -binaryornot==0.4.3 +binaryornot==0.4.4 # Testing -pytest==3.1.3 +pytest==3.2.1 pep8==1.7.0 -pyflakes==1.5.0 -tox==2.7.0 +pyflakes==1.6.0 +tox==2.8.0 pytest-cookies==0.2.0 diff --git a/{{cookiecutter.project_slug}}/.gitignore b/{{cookiecutter.project_slug}}/.gitignore index 710ba625d..6815c734d 100644 --- a/{{cookiecutter.project_slug}}/.gitignore +++ b/{{cookiecutter.project_slug}}/.gitignore @@ -1,82 +1,365 @@ -### OSX ### -.DS_Store -.AppleDouble -.LSOverride - -### SublimeText ### -# cache files for sublime text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache - -# workspace files are user-specific -*.sublime-workspace - -# project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using SublimeText -# *.sublime-project - -# sftp configuration file -sftp-config.json - -# Basics +### Python template +# Byte-compiled / optimized / DLL files +__pycache__/ *.py[cod] -__pycache__ +*$py.class -# Logs -logs -*.log +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs pip-log.txt -npm-debug.log* +pip-delete-this-directory.txt # Unit test / coverage reports +htmlcov/ +.tox/ .coverage -.tox +.coverage.* +.cache nosetests.xml -htmlcov +coverage.xml +*.cover +.hypothesis/ # Translations *.mo *.pot -# Pycharm -.idea/* -{% if cookiecutter.use_pycharm == 'y' %} +# Django stuff: +staticfiles/ + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# pyenv +.python-version + +# celery beat schedule file +celerybeat-schedule + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ + + +### Node template +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Typescript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + + +### Linux template +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# KDE directory preferences +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + + +### VisualStudioCode template +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + + +{% if cookiecutter.use_pycharm == 'y' -%} # Provided default Pycharm Run/Debug Configurations should be tracked by git # In case of local modifications made by Pycharm, use update-index command # for each changed file, like this: # git update-index --assume-unchanged .idea/{{cookiecutter.project_slug}}.iml -!.idea/runConfigurations/ -!.idea/{{cookiecutter.project_slug}}.iml -!.idea/vcs.xml -!.idea/webResources.xml +### JetBrains template +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties {% endif %} -# Vim -*~ -*.swp -*.swo +### Windows template +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db -# npm -node_modules/ +# Dump file +*.stackdump -# Compass -.sass-cache +# Folder config file +Desktop.ini -# virtual environments -.env +# Recycle Bin used on file shares +$RECYCLE.BIN/ -# User-uploaded media -{{ cookiecutter.project_slug }}/media/ +# Windows Installer files +*.cab +*.msi +*.msm +*.msp -{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' %} -# MailHog binary +# Windows shortcuts +*.lnk + + +### macOS template +# General +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + + +### SublimeText template +# Cache files for Sublime Text +*.tmlanguage.cache +*.tmPreferences.cache +*.stTheme.cache + +# Workspace files are user-specific +*.sublime-workspace + +# Project files should be checked into the repository, unless a significant +# proportion of contributors will probably not be using Sublime Text +# *.sublime-project + +# SFTP configuration file +sftp-config.json + +# Package control specific files +Package Control.last-run +Package Control.ca-list +Package Control.ca-bundle +Package Control.system-ca-bundle +Package Control.cache/ +Package Control.ca-certs/ +Package Control.merged-ca-bundle +Package Control.user-ca-bundle +oscrypto-ca-bundle.crt +bh_unicode_properties.cache + +# Sublime-github package stores a github token in this file +# https://packagecontrol.io/packages/sublime-github +GitHub.sublime-settings + + +### Vim template +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] + +# Session +Session.vim + +# Temporary +.netrwhist + +# Auto-generated tag files +tags + + +### VirtualEnv template +# Virtualenv +# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ +[Bb]in +[Ii]nclude +[Ll]ib +[Ll]ib64 +[Ll]ocal +[Ss]cripts +pyvenv.cfg +pip-selfcheck.json + + +{% if cookiecutter.use_mailhog == 'y' and cookiecutter.use_docker == 'n' -%} mailhog {% endif %} -staticfiles/ - -.cache/ +{{ cookiecutter.project_slug }}/media/ {{ cookiecutter.project_slug }}/static/build/ diff --git a/{{cookiecutter.project_slug}}/compose/caddy/Caddyfile b/{{cookiecutter.project_slug}}/compose/caddy/Caddyfile new file mode 100644 index 000000000..d36632e4b --- /dev/null +++ b/{{cookiecutter.project_slug}}/compose/caddy/Caddyfile @@ -0,0 +1,14 @@ +www.{% raw %}{$DOMAIN_NAME}{% endraw %} { + redir https://{{cookiecutter.domain_name}} +} + +{% raw %}{$DOMAIN_NAME}{% endraw %} { + proxy / django:5000 { + header_upstream Host {host} + header_upstream X-Real-IP {remote} + header_upstream X-Forwarded-Proto {scheme} + } + log stdout + errors stdout + gzip +} diff --git a/{{cookiecutter.project_slug}}/compose/caddy/Dockerfile b/{{cookiecutter.project_slug}}/compose/caddy/Dockerfile new file mode 100644 index 000000000..774b0bf5b --- /dev/null +++ b/{{cookiecutter.project_slug}}/compose/caddy/Dockerfile @@ -0,0 +1,2 @@ +FROM abiosoft/caddy:0.10.6 +COPY Caddyfile /etc/Caddyfile diff --git a/{{cookiecutter.project_slug}}/compose/django/Dockerfile-dev b/{{cookiecutter.project_slug}}/compose/django/Dockerfile-local similarity index 59% rename from {{cookiecutter.project_slug}}/compose/django/Dockerfile-dev rename to {{cookiecutter.project_slug}}/compose/django/Dockerfile-local index 673a06400..d2c56532a 100644 --- a/{{cookiecutter.project_slug}}/compose/django/Dockerfile-dev +++ b/{{cookiecutter.project_slug}}/compose/django/Dockerfile-local @@ -13,6 +13,14 @@ COPY ./compose/django/start-dev.sh /start-dev.sh RUN sed -i 's/\r//' /start-dev.sh RUN chmod +x /start-dev.sh +COPY ./compose/django/celery/worker/start-dev.sh /start-celeryworker-dev.sh +RUN sed -i 's/\r//' /start-celeryworker-dev.sh +RUN chmod +x /start-celeryworker-dev.sh + +COPY ./compose/django/celery/beat/start-dev.sh /start-celerybeat-dev.sh +RUN sed -i 's/\r//' /start-celerybeat-dev.sh +RUN chmod +x /start-celerybeat-dev.sh + WORKDIR /app ENTRYPOINT ["/entrypoint.sh"] diff --git a/{{cookiecutter.project_slug}}/compose/django/celery/beat/start-dev.sh b/{{cookiecutter.project_slug}}/compose/django/celery/beat/start-dev.sh new file mode 100644 index 000000000..987d7259e --- /dev/null +++ b/{{cookiecutter.project_slug}}/compose/django/celery/beat/start-dev.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +set -o errexit +set -o nounset +set -o xtrace + +rm -f './celerybeat.pid' +celery -A {{cookiecutter.project_slug}}.taskapp beat -l INFO diff --git a/{{cookiecutter.project_slug}}/compose/django/celery/worker/start-dev.sh b/{{cookiecutter.project_slug}}/compose/django/celery/worker/start-dev.sh new file mode 100644 index 000000000..594065e6c --- /dev/null +++ b/{{cookiecutter.project_slug}}/compose/django/celery/worker/start-dev.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -o errexit +set -o nounset +set -o xtrace + +celery -A {{cookiecutter.project_slug}}.taskapp worker -l INFO diff --git a/{{cookiecutter.project_slug}}/compose/nginx/Dockerfile b/{{cookiecutter.project_slug}}/compose/nginx/Dockerfile deleted file mode 100644 index 25b48cd95..000000000 --- a/{{cookiecutter.project_slug}}/compose/nginx/Dockerfile +++ /dev/null @@ -1,12 +0,0 @@ -FROM nginx:latest -ADD nginx.conf /etc/nginx/nginx.conf - -{% if cookiecutter.use_lets_encrypt == 'y' and cookiecutter.use_docker == 'y' %} -# installs the `ps` command in the nginx image -RUN apt-get update && apt-get install -y procps - -ADD start.sh /start.sh -ADD nginx-secure.conf /etc/nginx/nginx-secure.conf -ADD dhparams.pem /etc/ssl/private/dhparams.pem -CMD /start.sh -{% endif %} diff --git a/{{cookiecutter.project_slug}}/compose/nginx/dhparams.example.pem b/{{cookiecutter.project_slug}}/compose/nginx/dhparams.example.pem deleted file mode 100755 index e88d8123f..000000000 --- a/{{cookiecutter.project_slug}}/compose/nginx/dhparams.example.pem +++ /dev/null @@ -1,3 +0,0 @@ ------BEGIN DH PARAMETERS----- -EXAMPLE_FILE ------END DH PARAMETERS----- diff --git a/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf b/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf deleted file mode 100755 index c3f46b84e..000000000 --- a/{{cookiecutter.project_slug}}/compose/nginx/nginx-secure.conf +++ /dev/null @@ -1,98 +0,0 @@ -user nginx; -worker_processes 1; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - - -events { - worker_connections 1024; -} - -http { - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - proxy_headers_hash_bucket_size 52; - - gzip on; - - upstream app { - server django:5000; - } - server { - listen 80; - server_name ___my.example.com___ www.___my.example.com___; - - location /.well-known/acme-challenge { - # Since the certbot container isn't up constantly, need to resolve ip dynamically using docker's dns - resolver ___NAMESERVER___; - set $certbot_addr_port certbot:80; - proxy_pass http://$certbot_addr_port; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header X-Forwarded-Proto $scheme; - } - - location / { - return 301 https://$server_name$request_uri; - } - - } - - server { - listen 443; - server_name ___my.example.com___ www.___my.example.com___; - - ssl on; - ssl_certificate /etc/letsencrypt/live/___my.example.com___/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/___my.example.com___/privkey.pem; - ssl_session_timeout 5m; - ssl_protocols TLSv1 TLSv1.1 TLSv1.2; - ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; - ssl_prefer_server_ciphers on; - - ssl_session_cache shared:SSL:10m; - ssl_dhparam /etc/ssl/private/dhparams.pem; - - location /.well-known/acme-challenge { - resolver ___NAMESERVER___; - set $certbot_addr_port certbot:443; - proxy_pass http://$certbot_addr_port; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header X-Forwarded-Proto https; - } - - location / { - # checks for static file, if not found proxy to app - try_files $uri @proxy_to_app; - } - - # cookiecutter-django app - location @proxy_to_app { - proxy_set_header X-Forwarded-Proto https; - proxy_set_header X-Url-Scheme $scheme; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - - proxy_pass http://app; - - } - - } - -} diff --git a/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf b/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf deleted file mode 100644 index 9573effef..000000000 --- a/{{cookiecutter.project_slug}}/compose/nginx/nginx.conf +++ /dev/null @@ -1,61 +0,0 @@ -user nginx; -worker_processes 1; - -error_log /var/log/nginx/error.log warn; -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - - log_format main '$remote_addr - $remote_user [$time_local] "$request" ' - '$status $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; - - access_log /var/log/nginx/access.log main; - - sendfile on; - #tcp_nopush on; - - keepalive_timeout 65; - - #gzip on; - - upstream app { - server django:5000; - } - - server { - listen 80; - charset utf-8; - - {% if cookiecutter.use_lets_encrypt == 'y' and cookiecutter.use_docker == 'y' %} - server_name ___my.example.com___ ; - - location /.well-known/acme-challenge { - proxy_pass http://certbot:80; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $remote_addr; - proxy_set_header X-Forwarded-Proto https; - } - {% endif %} - - location / { - # checks for static file, if not found proxy to app - try_files $uri @proxy_to_app; - } - - # cookiecutter-django app - location @proxy_to_app { - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - proxy_pass http://app; - - } - } -} diff --git a/{{cookiecutter.project_slug}}/compose/nginx/start.sh b/{{cookiecutter.project_slug}}/compose/nginx/start.sh deleted file mode 100755 index fa40ed9ab..000000000 --- a/{{cookiecutter.project_slug}}/compose/nginx/start.sh +++ /dev/null @@ -1,62 +0,0 @@ -echo sleep 5 -sleep 5 - -echo build starting nginx config - - -echo replacing ___my.example.com___/$MY_DOMAIN_NAME - -# Put your domain name into the nginx reverse proxy config. -sed -i "s/___my.example.com___/$MY_DOMAIN_NAME/g" /etc/nginx/nginx.conf - -cat /etc/nginx/nginx.conf -echo . -echo Firing up nginx in the background. -nginx - -# # Check user has specified domain name -if [ -z "$MY_DOMAIN_NAME" ]; then - echo "Need to set MY_DOMAIN_NAME (to a letsencrypt-registered name)." - exit 1 -fi - -# This bit waits until the letsencrypt container has done its thing. -# We see the changes here bceause there's a docker volume mapped. -echo Waiting for folder /etc/letsencrypt/live/$MY_DOMAIN_NAME to exist -while [ ! -d /etc/letsencrypt/live/$MY_DOMAIN_NAME ] ; -do - sleep 2 -done - -while [ ! -f /etc/letsencrypt/live/$MY_DOMAIN_NAME/fullchain.pem ] ; -do - echo Waiting for file fullchain.pem to exist - sleep 2 -done - -while [ ! -f /etc/letsencrypt/live/$MY_DOMAIN_NAME/privkey.pem ] ; -do - echo Waiting for file privkey.pem to exist - sleep 2 -done - -# This is added so that when the certificate is being renewed or is already in place, nginx waits for everything to be good. -sleep 15 - -echo replacing ___my.example.com___/$MY_DOMAIN_NAME - - -# Put your domain name into the nginx reverse proxy config. -sed -i "s/___my.example.com___/$MY_DOMAIN_NAME/g" /etc/nginx/nginx-secure.conf - -# Add the system's nameserver (the docker network dns) so we can resolve container names in nginx -NAMESERVER=`cat /etc/resolv.conf | grep "nameserver" | awk '{print $2}' | tr '\n' ' '` -echo replacing ___NAMESERVER___/$NAMESERVER -sed -i "s/___NAMESERVER___/$NAMESERVER/g" /etc/nginx/nginx-secure.conf - - -#go! -kill $(ps aux | grep 'nginx' | grep -v 'grep' | awk '{print $2}') -cp /etc/nginx/nginx-secure.conf /etc/nginx/nginx.conf - -nginx -g 'daemon off;' diff --git a/{{cookiecutter.project_slug}}/config/settings/production.py b/{{cookiecutter.project_slug}}/config/settings/production.py index ca79c1634..bf031d351 100644 --- a/{{cookiecutter.project_slug}}/config/settings/production.py +++ b/{{cookiecutter.project_slug}}/config/settings/production.py @@ -1,7 +1,9 @@ """ Production Configurations -- Use Amazon's S3 for storing static files and uploaded media +{% if cookiecutter.use_whitenoise == 'y' -%} +- Use WhiteNoise for serving static files{% endif %} +- Use Amazon's S3 for storing {% if cookiecutter.use_whitenoise == 'n' -%}static files and {% endif %}uploaded media - Use mailgun to send emails - Use Redis for cache {% if cookiecutter.use_sentry_for_error_reporting == 'y' %} @@ -12,7 +14,6 @@ Production Configurations {% endif %} """ -from boto.s3.connection import OrdinaryCallingFormat {% if cookiecutter.use_sentry_for_error_reporting == 'y' %} import logging {% endif %} @@ -98,7 +99,6 @@ AWS_SECRET_ACCESS_KEY = env('DJANGO_AWS_SECRET_ACCESS_KEY') AWS_STORAGE_BUCKET_NAME = env('DJANGO_AWS_STORAGE_BUCKET_NAME') AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False -AWS_S3_CALLING_FORMAT = OrdinaryCallingFormat() # AWS cache settings, don't change unless you know what you're doing: AWS_EXPIRY = 60 * 60 * 24 * 7 @@ -115,11 +115,12 @@ AWS_HEADERS = { # stored files. {% if cookiecutter.use_whitenoise == 'y' -%} MEDIA_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME +DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' {% else %} # See:http://stackoverflow.com/questions/10390244/ -from storages.backends.s3boto import S3BotoStorage -StaticRootS3BotoStorage = lambda: S3BotoStorage(location='static') -MediaRootS3BotoStorage = lambda: S3BotoStorage(location='media') +from storages.backends.s3boto3 import S3Boto3Storage +StaticRootS3BotoStorage = lambda: S3Boto3Storage(location='static') +MediaRootS3BotoStorage = lambda: S3Boto3Storage(location='media') DEFAULT_FILE_STORAGE = 'config.settings.production.MediaRootS3BotoStorage' MEDIA_URL = 'https://s3.amazonaws.com/%s/media/' % AWS_STORAGE_BUCKET_NAME @@ -141,7 +142,7 @@ INSTALLED_APPS = ['collectfast', ] + INSTALLED_APPS {% if cookiecutter.use_compressor == 'y'-%} # COMPRESSOR # ------------------------------------------------------------------------------ -COMPRESS_STORAGE = 'storages.backends.s3boto.S3BotoStorage' +COMPRESS_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' COMPRESS_URL = STATIC_URL COMPRESS_ENABLED = env.bool('COMPRESS_ENABLED', default=True) {%- endif %} diff --git a/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst b/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst index 551da194c..af3b826a7 100644 --- a/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst +++ b/{{cookiecutter.project_slug}}/docs/pycharm/configuration.rst @@ -25,14 +25,6 @@ Switch to *Docker Compose* and select `local.yml` file from directory of your pr .. image:: images/4.png -Because Pycharm restarts container every time you use Configuration Run, to not have server restarted during running tests, we defined second service in `local.yml` file called pycharm. To use it, you have to add interpreter of second service as well. - -.. image:: images/5.png - -The final result should be: - -.. image:: images/6.png - Having that, click *OK*. Close *Settings* panel, and wait few seconds... .. image:: images/7.png diff --git a/{{cookiecutter.project_slug}}/docs/pycharm/images/5.png b/{{cookiecutter.project_slug}}/docs/pycharm/images/5.png deleted file mode 100644 index 39fac9593..000000000 Binary files a/{{cookiecutter.project_slug}}/docs/pycharm/images/5.png and /dev/null differ diff --git a/{{cookiecutter.project_slug}}/docs/pycharm/images/6.png b/{{cookiecutter.project_slug}}/docs/pycharm/images/6.png deleted file mode 100644 index 0cd70d249..000000000 Binary files a/{{cookiecutter.project_slug}}/docs/pycharm/images/6.png and /dev/null differ diff --git a/{{cookiecutter.project_slug}}/env.example b/{{cookiecutter.project_slug}}/env.example index 138b75fd9..cbde76499 100644 --- a/{{cookiecutter.project_slug}}/env.example +++ b/{{cookiecutter.project_slug}}/env.example @@ -3,6 +3,9 @@ POSTGRES_PASSWORD=mysecretpass POSTGRES_USER=postgresuser +# Domain name, used by caddy +DOMAIN_NAME={{ cookiecutter.domain_name }} + # General settings # DJANGO_READ_DOT_ENV_FILE=True DJANGO_ADMIN_URL= @@ -30,9 +33,9 @@ DJANGO_ACCOUNT_ALLOW_REGISTRATION=True DJANGO_SENTRY_DSN= {% endif %} {% if cookiecutter.use_opbeat == 'y' -%} -DJANGO_OPBEAT_ORGANIZATION_ID -DJANGO_OPBEAT_APP_ID -DJANGO_OPBEAT_SECRET_TOKEN +DJANGO_OPBEAT_ORGANIZATION_ID= +DJANGO_OPBEAT_APP_ID= +DJANGO_OPBEAT_SECRET_TOKEN= {% endif %} {% if cookiecutter.use_compressor == 'y' -%} COMPRESS_ENABLED= diff --git a/{{cookiecutter.project_slug}}/local.yml b/{{cookiecutter.project_slug}}/local.yml index a7e25faec..011e302ee 100644 --- a/{{cookiecutter.project_slug}}/local.yml +++ b/{{cookiecutter.project_slug}}/local.yml @@ -5,19 +5,10 @@ volumes: postgres_backup_dev: {} services: - postgres: - build: ./compose/postgres - volumes: - - postgres_data_dev:/var/lib/postgresql/data - - postgres_backup_dev:/backups - environment: - - POSTGRES_USER={{cookiecutter.project_slug}} - - django: + django: &django build: context: . - dockerfile: ./compose/django/Dockerfile-dev - command: /start-dev.sh + dockerfile: ./compose/django/Dockerfile-local depends_on: - postgres{% if cookiecutter.use_mailhog == 'y' %} - mailhog{% endif %} @@ -25,30 +16,47 @@ services: environment: - POSTGRES_USER={{cookiecutter.project_slug}} - USE_DOCKER=yes - volumes: - - .:/app ports: - "8000:8000" + command: /start-dev.sh -{% if cookiecutter.use_pycharm == 'y' %} - pycharm: - build: - context: . - dockerfile: ./compose/django/Dockerfile-dev - depends_on: - - postgres + postgres: + build: ./compose/postgres + volumes: + - postgres_data_dev:/var/lib/postgresql/data + - postgres_backup_dev:/backups environment: - POSTGRES_USER={{cookiecutter.project_slug}} - volumes: - - .:/app -{% endif %} - {% if cookiecutter.use_mailhog == 'y' %} mailhog: image: mailhog/mailhog:v1.0.0 ports: - "8025:8025" {% endif %} +{% if cookiecutter.use_celery == 'y' %} + redis: + image: redis:3.0 + + celeryworker: + # https://github.com/docker/compose/issues/3220 + <<: *django + depends_on: + - redis + - postgres{% if cookiecutter.use_mailhog == 'y' %} + - mailhog{% endif %} + ports: [] + command: /start-celeryworker-dev.sh + + celerybeat: + # https://github.com/docker/compose/issues/3220 + <<: *django + depends_on: + - redis + - postgres{% if cookiecutter.use_mailhog == 'y' %} + - mailhog{% endif %} + ports: [] + command: /start-celerybeat-dev.sh +{% endif %} node: build: diff --git a/{{cookiecutter.project_slug}}/production.yml b/{{cookiecutter.project_slug}}/production.yml index 677bf84f3..bfa9636a8 100644 --- a/{{cookiecutter.project_slug}}/production.yml +++ b/{{cookiecutter.project_slug}}/production.yml @@ -3,15 +3,9 @@ version: '2' volumes: postgres_data: {} postgres_backup: {} + caddy: {} services: - postgres: - build: ./compose/postgres - volumes: - - postgres_data:/var/lib/postgresql/data - - postgres_backup:/backups - env_file: .env - django: build: context: . @@ -23,36 +17,23 @@ services: command: /gunicorn.sh env_file: .env - nginx: - build: ./compose/nginx + postgres: + build: ./compose/postgres + volumes: + - postgres_data:/var/lib/postgresql/data + - postgres_backup:/backups + env_file: .env + + caddy: + build: ./compose/caddy depends_on: - django -{% if cookiecutter.use_lets_encrypt == 'y' %} - - certbot - environment: - - MY_DOMAIN_NAME={{ cookiecutter.domain_name }} -{% endif %} ports: - "0.0.0.0:80:80" -{% if cookiecutter.use_lets_encrypt == 'y' %} - "0.0.0.0:443:443" volumes: - - /etc/letsencrypt:/etc/letsencrypt - - /var/lib/letsencrypt:/var/lib/letsencrypt - - certbot: - image: quay.io/letsencrypt/letsencrypt - command: bash -c "sleep 6 && certbot certonly -n --standalone -d {{ cookiecutter.domain_name }} --test --agree-tos --email {{ cookiecutter.email }} --server https://acme-v01.api.letsencrypt.org/directory --rsa-key-size 4096 --verbose --keep-until-expiring --preferred-challenges http-01" - entrypoint: "" - volumes: - - /etc/letsencrypt:/etc/letsencrypt - - /var/lib/letsencrypt:/var/lib/letsencrypt - ports: - - "80" - - "443" - environment: - - TERM=xterm -{% endif %} + - caddy:/root/.caddy + env_file: .env redis: image: redis:3.0 diff --git a/{{cookiecutter.project_slug}}/requirements/base.txt b/{{cookiecutter.project_slug}}/requirements/base.txt index 2227e92cc..0e15afab5 100644 --- a/{{cookiecutter.project_slug}}/requirements/base.txt +++ b/{{cookiecutter.project_slug}}/requirements/base.txt @@ -9,14 +9,13 @@ wheel==0.29.0 django==1.10.7 # pyup: >=1.10,<1.11 # Configuration -django-environ==0.4.3 +django-environ==0.4.4 {% if cookiecutter.use_whitenoise == 'y' -%} whitenoise==3.3.0 {%- endif %} # Forms -django-braces==1.11.0 django-crispy-forms==1.6.1 # Models @@ -30,14 +29,14 @@ argon2-cffi==16.3.0 # For user registration, either via email or social # Well-built with regular release cycles! -django-allauth==0.32.0 +django-allauth==0.33.0 {% if cookiecutter.windows == 'y' -%} # On Windows, you must download/install psycopg2 manually # from http://www.lfd.uci.edu/~gohlke/pythonlibs/#psycopg {% else %} # Python-PostgreSQL Database Adapter -psycopg2==2.7.3 +psycopg2==2.7.3.1 {%- endif %} # Unicode slugification @@ -56,7 +55,7 @@ celery==3.1.25 {% if cookiecutter.use_compressor == "y" %} rcssmin==1.0.6 {% if cookiecutter.windows == 'y' %}--install-option="--without-c-extensions"{% endif %} -django-compressor==2.1.1 +django-compressor==2.2 {% endif %} # Your custom requirements go here diff --git a/{{cookiecutter.project_slug}}/requirements/local.txt b/{{cookiecutter.project_slug}}/requirements/local.txt index 0abe9c1fe..4808d8862 100644 --- a/{{cookiecutter.project_slug}}/requirements/local.txt +++ b/{{cookiecutter.project_slug}}/requirements/local.txt @@ -5,10 +5,10 @@ coverage==4.4.1 django-coverage-plugin==1.5.0 Sphinx==1.6.3 -django-extensions==1.8.1 +django-extensions==1.9.0 Werkzeug==0.12.2 django-test-plus==1.0.18 -factory-boy==2.9.0 +factory-boy==2.9.2 django-debug-toolbar==1.8 @@ -16,4 +16,4 @@ django-debug-toolbar==1.8 ipdb==0.10.3 pytest-django==3.1.2 -pytest-sugar==0.8.0 +pytest-sugar==0.9.0 diff --git a/{{cookiecutter.project_slug}}/requirements/production.txt b/{{cookiecutter.project_slug}}/requirements/production.txt index bdb9da9a2..b9f09ca75 100644 --- a/{{cookiecutter.project_slug}}/requirements/production.txt +++ b/{{cookiecutter.project_slug}}/requirements/production.txt @@ -6,7 +6,7 @@ # Python-PostgreSQL Database Adapter # If using Win for dev, this assumes Unix in prod # ------------------------------------------------ -psycopg2==2.7.3 +psycopg2==2.7.3.1 {%- endif %} # WSGI Handler @@ -16,8 +16,8 @@ gunicorn==19.7.1 # Static and Media Storage # ------------------------------------------------ -boto==2.48.0 -django-storages-redux==1.3.3 +boto3==1.4.7 +django-storages==1.6.5 {% if cookiecutter.use_whitenoise != 'y' -%} Collectfast==0.5.2 {%- endif %} diff --git a/{{cookiecutter.project_slug}}/requirements/test.txt b/{{cookiecutter.project_slug}}/requirements/test.txt index 485f9f702..c12222eb1 100644 --- a/{{cookiecutter.project_slug}}/requirements/test.txt +++ b/{{cookiecutter.project_slug}}/requirements/test.txt @@ -4,14 +4,14 @@ {% if cookiecutter.windows == 'y' -%} # Python-PostgreSQL Database Adapter # If using Win for dev, this assumes Unix in test/prod -psycopg2==2.7.3 +psycopg2==2.7.3.1 {%- endif %} coverage==4.4.1 flake8==3.4.1 # pyup: != 2.6.0 django-test-plus==1.0.18 -factory-boy==2.9.0 +factory-boy==2.9.2 # pytest pytest-django==3.1.2 -pytest-sugar==0.8.0 +pytest-sugar==0.9.0 diff --git a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/base.html b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/base.html index e49aaa216..a75281f72 100644 --- a/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/base.html +++ b/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/templates/base.html @@ -1,4 +1,4 @@ -{% raw %}{% load staticfiles i18n {% endraw %}{% if cookiecutter.use_compressor == "y" %}compress{% endif %}{% raw %}%} +{% raw %}{% load static i18n {% endraw %}{% if cookiecutter.use_compressor == "y" %}compress{% endif %}{% raw %}%}