Skip to content

Commit

Permalink
Deploy with capistrano
Browse files Browse the repository at this point in the history
  • Loading branch information
tnantoka committed Aug 24, 2018
1 parent b0dea24 commit 92df10c
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -102,3 +102,5 @@ venv.bak/

# mypy
.mypy_cache/

/static
39 changes: 39 additions & 0 deletions 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 }
8 changes: 8 additions & 0 deletions 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'
39 changes: 39 additions & 0 deletions 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
11 changes: 11 additions & 0 deletions 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
1 change: 1 addition & 0 deletions config/deploy/production.rb
@@ -0,0 +1 @@
server 'timecrowd-blog', roles: %w{app db web}
16 changes: 16 additions & 0 deletions config/httpd.conf
@@ -0,0 +1,16 @@
<VirtualHost *:80>
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

<Directory /var/www/timecrowd-django-example/current>
Allow from all
Options -MultiViews
Options FollowSymLinks
</Directory>
</VirtualHost>
3 changes: 2 additions & 1 deletion mysite/mysite/settings.py
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
4 changes: 4 additions & 0 deletions mysite/mysite/wsgi.py
Expand Up @@ -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()

0 comments on commit 92df10c

Please sign in to comment.