achambers/ember-cli-deploy-original

Example: Server-side configuration using nginx-openresty/lua instead of ruby

Opened this issue · 3 comments

Just got everything working. Instead of using Ruby, I just used nginx_openresty+lua+redis. Here is an example in case anyone finds this helpful:

upstream config:

upstream backend {
        server 127.0.0.1:6379;
        keepalive 1024;
}

nginx server locations:

        location /redis {
                internal;
                set_unescape_uri $key $arg_key;
                redis2_query get $key;
                redis2_pass backend;
        }

        location / {
                default_type text/html;
                content_by_lua '
                        local indexKey = "index:" .. (ngx.var.arg_version or "current")
                        local replies = ngx.location.capture("/redis?key=" .. indexKey)
                        local parser = require("redis.parser")
                        local res,type = parser.parse_reply(replies.body)
                        ngx.say(res)';
        }

After setting this up, you can use the 'version' query param to specify a specific version of your site by hash:
yoursite.com/ uses index:current
yoursite.com/?version=1234567890 uses index:1234567890

This, of course, assumes that you already deployed and activated your assets correctly.

Thanks @EmergentBehavior. Just so you know, I have an express server, in another repo, to serve the index.html. It uses the Heroku Deploy button to make it super simple to spin up your own instance, complete with a redis instance addon.

https://github.com/achambers/fuzzy-wookie

This way you don't need to write your own.

Would it make sense to do something similar with your nginx config?

Possibly -- perhaps I could create a Docker container?

Haven't done much with Docker myself, but if you think that might work.