aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks/install.rake
blob: 7d8ecdce0066cc072bf4324d44958c637c0ce98f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
task :package do
  release_name = Time.now.strftime('%Y%m%d%H%M%S')

  rm_rf "tmp/package"
  mkdir_p "tmp/package"

  sh "git archive --format=tar --output=tmp/package/stif-boiv-release-#{release_name}.tar HEAD"

  sh "bundle package --all"
  sh "bundle exec rake assets:clobber RAILS_ENV=production"
  sh "bundle exec rake assets:precompile RAILS_ENV=production"
  sh "bundle exec rake i18n:js:export RAILS_ENV=production"
  sh "tar -rf tmp/package/stif-boiv-release-#{release_name}.tar vendor/cache"
  sh "tar -rf tmp/package/stif-boiv-release-#{release_name}.tar public/assets"
  sh "tar -rf tmp/package/stif-boiv-release-#{release_name}.tar public/packs"
  sh "tar -rf tmp/package/stif-boiv-release-#{release_name}.tar public/javascripts"

  %w{deploy-helper.sh README sidekiq-stif-boiv.service stif-boiv.conf stif-boiv-setup.sh template-stif-boiv.sql}.each do |f|
    cp "install/#{f}", "tmp/package/#{f}"
  end

  cp "config/environments/production.rb", "tmp/package/production.rb"

  sh "tar -czf stif-boiv-#{release_name}.tar.gz -C tmp/package ."
  sh "rm -rf tmp/package vendor/cache"
end

desc "generate all-in-1 tar.gz package for docker"
task :pkg4docker do
  release_name = Time.now.strftime('%Y%m%d%H%M%S')

  rm_rf "tmp/package"
  mkdir_p "tmp/package"

  sh "git archive --format=tar --output=tmp/package/stif-boiv-release-#{release_name}.tar HEAD"

  sh "bundle package --all"
#  sh "RAILS_DB_ADAPTER=nulldb bundle exec rake assets:clobber RAILS_ENV=production"
#  sh "RAILS_DB_ADAPTER=nulldb bundle exec rake assets:precompile RAILS_ENV=production"
  sh "bundle exec rake assets:clobber RAILS_ENV=production"
  sh "bundle exec rake assets:precompile RAILS_ENV=production"
  sh "bundle exec rake i18n:js:export RAILS_ENV=production"
  sh "tar -rf tmp/package/stif-boiv-release-#{release_name}.tar vendor/cache"
  sh "tar -rf tmp/package/stif-boiv-release-#{release_name}.tar public/assets"
  sh "tar -rf tmp/package/stif-boiv-release-#{release_name}.tar public/packs"
  sh "tar -rf tmp/package/stif-boiv-release-#{release_name}.tar public/javascripts"

  sh "gzip -c tmp/package/stif-boiv-release-#{release_name}.tar > tmp/stif-boiv-release.tar.gz"

  sh "rm -rf tmp/package vendor/cache"
end