From 7cf13dcb90d456b838009ae91f1c99dec0f7f2ec Mon Sep 17 00:00:00 2001 From: Will Farrington Date: Wed, 6 Feb 2013 18:31:46 -0800 Subject: [PATCH] Ohai, some boxen::project love --- modules/projects/README.md | 30 +++++++++------ .../projects/templates/shared/nginx.conf.erb | 38 +++++++++++++++++++ 2 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 modules/projects/templates/shared/nginx.conf.erb diff --git a/modules/projects/README.md b/modules/projects/README.md index e564840..f6a5f38 100644 --- a/modules/projects/README.md +++ b/modules/projects/README.md @@ -4,18 +4,26 @@ Project manifests live in `modules/projects/manifests/$project.pp`. A simple project manifest example: ```puppet -class projects::boxen { - include qt # requires the qt module in Puppetfile +class projects::trollin { + include icu4c + include phantomjs - $dir = "${boxen::config::srcdir}/boxen" - - repository { $dir: - source => 'boxen/boxen' - } - - ruby::local { $dir: - version => 'system', - require => Repository[$dir] + boxen::project { 'trollin': + dotenv => true, + elasticsearch => true, + mysql => true, + nginx => true, + redis => true, + ruby => '1.9.3', + source => 'boxen/trollin' } } ``` + +With the above, as long as our app is configured to listen on a **socket** at +`"#{ENV['BOXEN_SOCKET_DIR']}"/trollin`, you'll now be able to run its local +server and visit http://trollin.dev/ to access the app in dev. + +For further documentation on how to use the `boxen::project` type, +take a look at the documentation in the +[source](https://github.com/boxen/puppet-boxen/blob/master/manifests/project.pp#L1-L46). diff --git a/modules/projects/templates/shared/nginx.conf.erb b/modules/projects/templates/shared/nginx.conf.erb new file mode 100644 index 0000000..2fdb37c --- /dev/null +++ b/modules/projects/templates/shared/nginx.conf.erb @@ -0,0 +1,38 @@ +upstream <%= name %>.dev { + server unix:<%= scope.lookupvar "boxen::config::socketdir" %>/<%= name %>; +} + +server { + access_log <%= scope.lookupvar "nginx::config::logdir" %>/<%= name %>.access.log main; + listen 80; + root <%= scope.lookupvar "boxen::config::srcdir" %>/<%= name %>/public; + server_name <%= name %>.dev; + + client_max_body_size 50M; + + error_page 500 502 503 504 /50x.html; + + if ($host ~* "www") { + rewrite ^(.*)$ http://<%= name %>.dev$1 permanent; + break; + } + + location = /50x.html { + root html; + } + + location / { + if (-f $request_filename/index.html) { + rewrite (.*) $1/index.html break; + } + + if (-f $request_filename.html) { + rewrite (.*) $1.html break; + } + + if (!-f $request_filename) { + proxy_pass http://<%= name %>.dev; + break; + } + } +}