diff options
| -rw-r--r-- | provider_base/services/webapp.json | 11 | ||||
| -rw-r--r-- | puppet/modules/site_apache/manifests/module/expires.pp | 4 | ||||
| -rw-r--r-- | puppet/modules/site_apache/templates/vhosts.d/leap_webapp.conf.erb | 8 | ||||
| -rw-r--r-- | puppet/modules/site_webapp/manifests/apache.pp | 1 | ||||
| -rw-r--r-- | puppet/modules/site_webapp/manifests/init.pp | 51 | 
5 files changed, 29 insertions, 46 deletions
| diff --git a/provider_base/services/webapp.json b/provider_base/services/webapp.json index 6f2beb8a..392375ff 100644 --- a/provider_base/services/webapp.json +++ b/provider_base/services/webapp.json @@ -4,17 +4,18 @@      "modules": ["user", "billing", "help"],      "couchdb_admin_user": "= global.services[:couchdb].couch.users[:admin]",      "couchdb_webapp_user": "= global.services[:couchdb].couch.users[:webapp]", -    "favicon": "= file_path 'branding/favicon.ico'", -    "tail_scss": "= file_path 'branding/tail.scss'", -    "head_scss": "= file_path 'branding/head.scss'", -    "img_dir": "= file_path 'branding/img'", +    "customization_dir": "= file_path 'webapp'",      "client_certificates": "= global.provider.ca.client_certificates",      "allow_limited_certs": "= global.provider.service.allow_limited_bandwidth",      "allow_unlimited_certs": "= global.provider.service.allow_unlimited_bandwidth",      "allow_anonymous_certs": "= global.provider.service.allow_anonymous",      "secret_token": "= secret :webapp_secret_token",      "api_version": 1, -    "secure": false +    "secure": false, +    "git": { +      "source": "https://leap.se/git/leap_web", +      "revision": "origin/master" +    }    },    "stunnel": {      "couch_client": "= stunnel_client(nodes_like_me[:services => :couchdb], global.services[:couchdb].couch.port)" diff --git a/puppet/modules/site_apache/manifests/module/expires.pp b/puppet/modules/site_apache/manifests/module/expires.pp new file mode 100644 index 00000000..f73a5607 --- /dev/null +++ b/puppet/modules/site_apache/manifests/module/expires.pp @@ -0,0 +1,4 @@ +class site_apache::module::expires ( $ensure = present ) +{ +  apache::module { 'expires': ensure => $ensure } +} diff --git a/puppet/modules/site_apache/templates/vhosts.d/leap_webapp.conf.erb b/puppet/modules/site_apache/templates/vhosts.d/leap_webapp.conf.erb index afc19782..a001552a 100644 --- a/puppet/modules/site_apache/templates/vhosts.d/leap_webapp.conf.erb +++ b/puppet/modules/site_apache/templates/vhosts.d/leap_webapp.conf.erb @@ -45,6 +45,14 @@    PassengerFriendlyErrorPages off    SetEnv TMPDIR /var/tmp +  # Allow rails assets to be cached for a very long time (since the URLs change whenever the content changes) +  <Location /assets/> +    Header unset ETag +    FileETag None +    ExpiresActive On +    ExpiresDefault "access plus 1 year" +  </Location> +   <% if (defined? @services) and (@services.include? 'monitor') -%>   <DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>      PassengerEnabled off diff --git a/puppet/modules/site_webapp/manifests/apache.pp b/puppet/modules/site_webapp/manifests/apache.pp index 6a199b9e..581922cb 100644 --- a/puppet/modules/site_webapp/manifests/apache.pp +++ b/puppet/modules/site_webapp/manifests/apache.pp @@ -21,6 +21,7 @@ class site_webapp::apache {    include site_apache::module::headers    include site_apache::module::rewrite    include site_apache::module::alias +  include site_apache::module::expires    class { 'passenger': use_munin => false } diff --git a/puppet/modules/site_webapp/manifests/init.pp b/puppet/modules/site_webapp/manifests/init.pp index 6c5bda4c..c090c6a0 100644 --- a/puppet/modules/site_webapp/manifests/init.pp +++ b/puppet/modules/site_webapp/manifests/init.pp @@ -40,9 +40,9 @@ class site_webapp {    vcsrepo { '/srv/leap/webapp':      ensure   => present,      force    => true, -    revision => 'origin/master', +    revision => $webapp['git']['revision'],      provider => git, -    source   => 'https://leap.se/git/leap_web', +    source   => $webapp['git']['source'],      owner    => 'leap-webapp',      group    => 'leap-webapp',      require  => [ User['leap-webapp'], Group['leap-webapp'] ], @@ -63,6 +63,10 @@ class site_webapp {      notify  => Service['apache'];    } +  # +  # NOTE: in order to support a webapp that is running on a subpath and not the root of the domain +  # assets:precompile needs to be run with RAILS_RELATIVE_URL_ROOT=/application-root +  #    exec { 'compile_assets':      cwd       => '/srv/leap/webapp',      command   => '/bin/bash -c "RAILS_ENV=production /usr/bin/bundle exec rake assets:precompile"', @@ -110,55 +114,20 @@ class site_webapp {    }    try::file { -    '/srv/leap/webapp/public/favicon.ico': -      ensure  => present, -      owner   => leap-webapp, -      group   => leap-webapp, -      mode    => '0644', -      require => Vcsrepo['/srv/leap/webapp'], -      source  => $webapp['favicon']; - -    '/srv/leap/webapp/app/assets/stylesheets/tail.scss': -      ensure  => present, -      owner   => leap-webapp, -      group   => leap-webapp, -      mode    => '0644', -      require => Vcsrepo['/srv/leap/webapp'], -      source  => $webapp['tail_scss'], -      before  => Exec['bundler_update']; - -    '/srv/leap/webapp/app/assets/stylesheets/head.scss': -      ensure  => present, -      owner   => leap-webapp, -      group   => leap-webapp, -      mode    => '0644', -      require => Vcsrepo['/srv/leap/webapp'], -      source  => $webapp['head_scss'], -      before  => Exec['bundler_update']; - -    '/srv/leap/webapp/public/img': +    '/srv/leap/webapp/config/customization':        ensure  => directory,        recurse => true,        purge   => true,        force   => true,        owner   => leap-webapp,        group   => leap-webapp, -      mode    => '0644', +      mode    => 'u=rwX,go=rX',        require => Vcsrepo['/srv/leap/webapp'], -      source  => $webapp['img_dir']; +      notify  => Exec['compile_assets'], +      source  => $webapp['customization_dir'];    }    git::changes { -    'app/assets/stylesheets/head.scss': -      cwd     => '/srv/leap/webapp', -      require => Vcsrepo['/srv/leap/webapp'], -      user    => 'leap-webapp'; - -    'app/assets/stylesheets/tail.scss': -      cwd     => '/srv/leap/webapp', -      require => Vcsrepo['/srv/leap/webapp'], -      user    => 'leap-webapp'; -      'public/favicon.ico':        cwd     => '/srv/leap/webapp',        require => Vcsrepo['/srv/leap/webapp'], | 
