forkcms_3_deploy 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # ForkCMS Deploy gem
2
+ This is a gem that enables you to deploy a ForkCMS 3.x.x install to your server. It was built specific for Fork CMS so your Capfile will be neat and tidy.
3
+
4
+ ## Installation
5
+ The recipe is available in the forkcms_deploy gem, which can be installed via [RubyGems.org](http://rubygems.org)
6
+ gem install forkcms_3_deploy
7
+
8
+ ## Available recipes
9
+ * forkcms_3_deploy - ForkCMS specific tasks.
10
+ * forkcms_3_deploy/defaults - Best practices for each deployment.
11
+
12
+ ## Example recipe
13
+ This recipe will deploy the ForkCMS-instance to your-app.com.
14
+
15
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
16
+
17
+ # set your application name here
18
+ set :application, "your-app.com" # eg.: sumocoders.be
19
+
20
+ # set user to use on server
21
+ set :user, "your-user" # eg.: sumocoders
22
+
23
+ # deploy to path (on server)
24
+ set :deploy_to, "/home/#{user}/apps/#{application}" # eg.: /home/sumocoders/apps/sumocoders.be
25
+
26
+ # set document_root
27
+ set :document_root, "/home/#{user}/www.your-app.com" # eg.: /home/sumocoders/default_www
28
+
29
+ # define roles
30
+ server "your-app.com", :app, :web, :db, :primary => true # eg.: crsolutions.be
31
+
32
+ # git repo & branch
33
+ set :repository, "git@your-git.com:your-app.git" # eg.: git@crsolutions.be:sumocoders.be.git
34
+ set :branch, "master"
35
+
36
+ # set version control type and copy strategy
37
+ set :scm, :git
38
+ set :copy_strategy, :checkout
39
+
40
+ begin
41
+ require 'forkcms_3_deploy'
42
+ require 'forkcms_3_deploy/defaults' # optional, contains best practices
43
+ rescue LoadError
44
+ $stderr.puts <<-INSTALL
45
+ You need the forkcms_3_deploy gem (which simplifies this Capfile) to deploy this application
46
+ Install the gem like this:
47
+ gem install forkcms_deploy
48
+ INSTALL
49
+ exit 1
50
+ end
data/Rakefile ADDED
@@ -0,0 +1,15 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "forkcms_3_deploy"
5
+ gemspec.summary = "Deployment for Fork 3.x.x with Capistrano"
6
+ gemspec.description = "Deployment for Fork 3.x.x with Capistrano"
7
+ gemspec.email = "info@sumocoders.be"
8
+ gemspec.homepage = "https://github.com/sumocoders/forkcms_3_deploy"
9
+ gemspec.authors = ['Tijs Verkoyen', 'Sam Tubbax']
10
+ gemspec.add_dependency 'capistrano', '>=2.0.0'
11
+ end
12
+ Jeweler::GemcutterTasks.new
13
+ rescue LoadError
14
+ puts "Jeweler not available. Install it with: gem install jeweler"
15
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.1.0
@@ -0,0 +1,45 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "forkcms_3_deploy"
8
+ s.version = "1.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Tijs Verkoyen", "Sam Tubbax"]
12
+ s.date = "2011-11-12"
13
+ s.description = "Deployment for Fork 3.x.x with Capistrano"
14
+ s.email = "info@sumocoders.be"
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "README.md",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "forkcms_3_deploy.gemspec",
23
+ "lib/forkcms_3_deploy.rb",
24
+ "lib/forkcms_3_deploy/defaults.rb",
25
+ "lib/forkcms_3_deploy/forkcms.rb",
26
+ "lib/forkcms_3_deploy/overwrites.rb"
27
+ ]
28
+ s.homepage = "https://github.com/sumocoders/forkcms_3_deploy"
29
+ s.require_paths = ["lib"]
30
+ s.rubygems_version = "1.8.11"
31
+ s.summary = "Deployment for Fork 3.x.x with Capistrano"
32
+
33
+ if s.respond_to? :specification_version then
34
+ s.specification_version = 3
35
+
36
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
37
+ s.add_runtime_dependency(%q<capistrano>, [">= 2.0.0"])
38
+ else
39
+ s.add_dependency(%q<capistrano>, [">= 2.0.0"])
40
+ end
41
+ else
42
+ s.add_dependency(%q<capistrano>, [">= 2.0.0"])
43
+ end
44
+ end
45
+
@@ -0,0 +1,2 @@
1
+ require 'forkcms_3_deploy/forkcms'
2
+ require 'forkcms_3_deploy/overwrites'
@@ -0,0 +1,26 @@
1
+ configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
2
+
3
+ configuration.load do
4
+ # don't use sudo, on most shared setups we won't have sudo-access
5
+ set :use_sudo, false
6
+
7
+ # we're on a share setup so group_writable isn't allowed
8
+ set :group_writable, false
9
+
10
+ # 3 releases should be enough.
11
+ set :keep_releases, 3
12
+
13
+ # remote caching will keep a local git repo on the server you're deploying to and simply run a fetch from that
14
+ # rather than an entire clone. This is probably the best option and will only fetch the differences each deploy
15
+ set :deploy_via, :remote_cache
16
+
17
+ # set the value for pseudo terminals in Capistrano
18
+ default_run_options[:pty] = true
19
+
20
+ # your computer must be running ssh-agent for the git checkout to work from the server to the git server
21
+ set :ssh_options, { :forward_agent => true }
22
+
23
+ # set version control type and copy strategy
24
+ set :scm, :git
25
+ set :copy_strategy, :checkout
26
+ end
@@ -0,0 +1,104 @@
1
+ configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
2
+
3
+ configuration.load do
4
+ # define some extra folder to create
5
+ set :shared_children, %w(files config/frontend config/backend config/library)
6
+
7
+ # custom events configuration
8
+ after 'deploy:setup' do
9
+ forkcms.link_document_root
10
+ end
11
+
12
+ after 'deploy:update_code' do
13
+ forkcms.link_configs
14
+ forkcms.link_files
15
+ end
16
+
17
+ # Fork CMS specific tasks
18
+ namespace :forkcms do
19
+ desc 'Clear the frontend and backend cache-folders'
20
+ task :clear_cached do
21
+ # remove frontend cached data
22
+ run %{
23
+ rm -rf #{current_path}/frontend/cache/cached_templates/* &&
24
+ rm -rf #{current_path}/frontend/cache/locale/* &&
25
+ rm -rf #{current_path}/frontend/cache/minified_css/* &&
26
+ rm -rf #{current_path}/frontend/cache/minified_js/* &&
27
+ rm -rf #{current_path}/frontend/cache/navigation/* &&
28
+ rm -rf #{current_path}/frontend/cache/statistics/* &&
29
+ rm -rf #{current_path}/frontend/cache/templates/*
30
+ }
31
+
32
+ # remove backend cached data
33
+ run %{
34
+ rm -rf #{current_path}/backend/cache/analytics/* &&
35
+ rm -rf #{current_path}/backend/cache/cronjobs/* &&
36
+ rm -rf #{current_path}/backend/cache/locale/* &&
37
+ rm -rf #{current_path}/backend/cache/mailmotor/* &&
38
+ rm -rf #{current_path}/backend/cache/templates/*
39
+ }
40
+ end
41
+
42
+ desc 'Link the config files'
43
+ task :link_configs do
44
+ # create config files
45
+ path_library = <<-CONFIG
46
+ <?php
47
+ // custom constant used by the init classes
48
+ define('INIT_PATH_LIBRARY', '#{current_path}/library');
49
+ ?>
50
+ CONFIG
51
+
52
+ # upload the files
53
+ put path_library, "#{shared_path}/config/frontend/config.php"
54
+ put path_library, "#{shared_path}/config/backend/config.php"
55
+
56
+ # change the path to current_path
57
+ run "if [ -f #{shared_path}/config/library/globals.php ]; then sed -i 's/#{version_dir}\\/[0-9]*/#{current_dir}/' #{shared_path}/config/library/globals.php; fi"
58
+
59
+ # create dirs
60
+ run %{
61
+ mkdir -p #{release_path}/frontend/cache/config &&
62
+ mkdir -p #{release_path}/backend/cache/config
63
+ }
64
+
65
+ # symlink the globals
66
+ run %{
67
+ ln -sf #{shared_path}/config/library/globals_backend.php #{release_path}/library/globals_backend.php &&
68
+ ln -sf #{shared_path}/config/library/globals_frontend.php #{release_path}/library/globals_frontend.php &&
69
+ ln -sf #{shared_path}/config/library/globals.php #{release_path}/library/globals.php &&
70
+ ln -sf #{shared_path}/config/frontend/config.php #{release_path}/frontend/cache/config/config.php &&
71
+ ln -sf #{shared_path}/config/backend/config.php #{release_path}/backend/cache/config/config.php
72
+ }
73
+ end
74
+
75
+ desc 'link the document root to the current/default_www-folder'
76
+ task :link_document_root do
77
+ # create symlink for document_root if it doesn't exists
78
+ documentRootExists = capture("if [ ! -e #{document_root} ]; then ln -sf #{current_path} #{document_root}; echo 'no'; fi").chomp
79
+
80
+ unless documentRootExists == 'no'
81
+ warn "Warning: Document root (#{document_root}) already exists"
82
+ warn 'to link it to the Fork deploy issue the following command:'
83
+ warn ' ln -sf #{current_path} #{document_root}'
84
+ end
85
+ end
86
+
87
+ desc 'Create needed symlinks'
88
+ task :link_files do
89
+ # get the list of folders in /frontend/files
90
+ folders = capture("ls -1 #{release_path}/frontend/files").split(/\r?\n/)
91
+
92
+ # loop the folders
93
+ folders.each do |folder|
94
+ # copy them to the shared path, remove them from the release and symlink them
95
+ run %{
96
+ mkdir -p #{shared_path}/files/#{folder} &&
97
+ cp -r #{release_path}/frontend/files/#{folder} #{shared_path}/files/ &&
98
+ rm -rf #{release_path}/frontend/files/#{folder} &&
99
+ ln -s #{shared_path}/files/#{folder} #{release_path}/frontend/files/#{folder}
100
+ }
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,31 @@
1
+ configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
2
+
3
+ configuration.load do
4
+ # Deployment process
5
+ namespace :deploy do
6
+ desc 'Prepares the servers for deployment.'
7
+ task :setup, :except => { :no_release => true } do
8
+ # this method is overwritten because Fork CMS isn't a Rails-application
9
+
10
+ # define folders to create
11
+ dirs = [deploy_to, releases_path, shared_path]
12
+
13
+ # add folder that aren't standard
14
+ dirs += shared_children.map { |d| File.join(shared_path, d) }
15
+
16
+ # create the dirs
17
+ run %{
18
+ #{try_sudo} mkdir -p #{dirs.join(' ')} &&
19
+ #{try_sudo} chmod g+w #{dirs.join(' ')}
20
+ }
21
+ end
22
+
23
+ task :finalize_update, :except => { :no_release => true } do
24
+ # Fork CMS isn't a Rails-application so don't do Rails specific stuff
25
+ run 'chmod -R g+w #{latest_release}' if fetch(:group_writable, true)
26
+ end
27
+
28
+ # overrule restart
29
+ task :restart do; end
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: forkcms_3_deploy
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 0
10
+ version: 1.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Tijs Verkoyen
14
+ - Sam Tubbax
15
+ autorequire:
16
+ bindir: bin
17
+ cert_chain: []
18
+
19
+ date: 2011-11-12 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: capistrano
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 15
30
+ segments:
31
+ - 2
32
+ - 0
33
+ - 0
34
+ version: 2.0.0
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: Deployment for Fork 3.x.x with Capistrano
38
+ email: info@sumocoders.be
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - README.md
45
+ files:
46
+ - README.md
47
+ - Rakefile
48
+ - VERSION
49
+ - forkcms_3_deploy.gemspec
50
+ - lib/forkcms_3_deploy.rb
51
+ - lib/forkcms_3_deploy/defaults.rb
52
+ - lib/forkcms_3_deploy/forkcms.rb
53
+ - lib/forkcms_3_deploy/overwrites.rb
54
+ homepage: https://github.com/sumocoders/forkcms_3_deploy
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.8.11
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Deployment for Fork 3.x.x with Capistrano
87
+ test_files: []
88
+