diff --git a/.gitignore b/.gitignore index 894a44c..7a37cb5 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,5 @@ venv.bak/ # mypy .mypy_cache/ + +/static diff --git a/Capfile b/Capfile new file mode 100644 index 0000000..fb949cd --- /dev/null +++ b/Capfile @@ -0,0 +1,39 @@ +# Load DSL and set up stages +require "capistrano/setup" + +# Include default deployment tasks +require "capistrano/deploy" + +# Load the SCM plugin appropriate to your project: +# +# require "capistrano/scm/hg" +# install_plugin Capistrano::SCM::Hg +# or +# require "capistrano/scm/svn" +# install_plugin Capistrano::SCM::Svn +# or +require "capistrano/scm/git" +install_plugin Capistrano::SCM::Git + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# +# require "capistrano/rvm" +# require "capistrano/rbenv" +# require "capistrano/chruby" +# require "capistrano/bundler" +# require "capistrano/rails/assets" +# require "capistrano/rails/migrations" +require "capistrano/passenger" +require "capistrano/django/venv" + +# Load custom tasks from `lib/capistrano/tasks` if you have any defined +Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..ebf2bc8 --- /dev/null +++ b/Gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +source 'https://rubygems.org' + +git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } + +gem 'capistrano-django-venv', github: 'tnantoka/capistrano-django-venv' +gem 'capistrano-passenger' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..51a056b --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,39 @@ +GIT + remote: https://github.com/tnantoka/capistrano-django-venv + revision: 2038342d829253b51420d2020d84ca641a932e1d + specs: + capistrano-django-venv (0.1.0) + capistrano (~> 3) + +GEM + remote: https://rubygems.org/ + specs: + airbrussh (1.3.0) + sshkit (>= 1.6.1, != 1.7.0) + capistrano (3.11.0) + airbrussh (>= 1.0.0) + i18n + rake (>= 10.0.0) + sshkit (>= 1.9.0) + capistrano-passenger (0.2.0) + capistrano (~> 3.0) + concurrent-ruby (1.0.5) + i18n (1.1.0) + concurrent-ruby (~> 1.0) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (5.0.2) + rake (12.3.1) + sshkit (1.17.0) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) + +PLATFORMS + ruby + +DEPENDENCIES + capistrano-django-venv! + capistrano-passenger + +BUNDLED WITH + 1.16.4 diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 0000000..f219cc6 --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,11 @@ +lock '~> 3.11.0' + +set :application, 'timecrowd-django-example' +set :repo_url, 'git@github.com:timecrowd-blog/timecrowd-django-example.git' +set :deploy_to, '/var/www/timecrowd-django-example' + +set :project, 'mysite' +append :linked_files, 'mysite/.env' +append :linked_dirs, 'venv', 'public/static' + +set :passenger_restart_with_touch, true diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 0000000..539122b --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1 @@ +server 'timecrowd-blog', roles: %w{app db web} diff --git a/config/httpd.conf b/config/httpd.conf new file mode 100644 index 0000000..cbd3a41 --- /dev/null +++ b/config/httpd.conf @@ -0,0 +1,16 @@ + + ServerName django.blog.timecrowd.net + + DocumentRoot /var/www/timecrowd-django-example/current/public + PassengerAppRoot /var/www/timecrowd-django-example/current + + PassengerAppType wsgi + PassengerStartupFile /var/www/timecrowd-django-example/current/mysite/mysite/wsgi.py + PassengerPython /var/www/timecrowd-django-example/current/venv/bin/python + + + Allow from all + Options -MultiViews + Options FollowSymLinks + + diff --git a/mysite/mysite/settings.py b/mysite/mysite/settings.py index b1352fe..bfc9310 100644 --- a/mysite/mysite/settings.py +++ b/mysite/mysite/settings.py @@ -28,7 +28,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = os.getenv('DEBUG') == '1' -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['*'] # Application definition @@ -123,6 +123,7 @@ # https://docs.djangoproject.com/en/2.1/howto/static-files/ STATIC_URL = '/static/' +STATIC_ROOT = os.getenv('STATIC_ROOT') SOCIAL_AUTH_TIMECROWD_KEY = os.getenv('SOCIAL_AUTH_TIMECROWD_KEY') SOCIAL_AUTH_TIMECROWD_SECRET = os.getenv('SOCIAL_AUTH_TIMECROWD_SECRET') diff --git a/mysite/mysite/wsgi.py b/mysite/mysite/wsgi.py index 77f71eb..bd0e63d 100644 --- a/mysite/mysite/wsgi.py +++ b/mysite/mysite/wsgi.py @@ -8,9 +8,13 @@ """ import os +import sys from django.core.wsgi import get_wsgi_application +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.append(BASE_DIR) + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings') application = get_wsgi_application()