Skip to content

Commit

Permalink
added a docker with nginx for using muleview/scent
Browse files Browse the repository at this point in the history
  • Loading branch information
shmul committed Jul 17, 2015
1 parent ed5b14f commit 33de7aa
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 61 deletions.
56 changes: 56 additions & 0 deletions docker/Dockerfile-lua5.1-nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
FROM ubuntu:14.04

RUN apt-get update -y && apt-get install -y unzip curl make git


RUN apt-get install -y lua5.1 liblua5.1 liblua5.1-dev

# Install luarocks
RUN cd /tmp && \
curl -L -O http://luarocks.org/releases/luarocks-2.2.1.tar.gz && \
tar zxpf luarocks-2.2.1.tar.gz && \
rm luarocks-2.2.1.tar.gz && \
cd luarocks-2.2.1 && \
./configure --prefix=/usr && \
make bootstrap && \
cd /tmp && \
rm -r /tmp/luarocks-2.2.1

RUN cd /tmp && \
curl -L -O https://github.com/LMDB/lmdb/archive/LMDB_0.9.15.tar.gz && \
tar -xzf LMDB_0.9.15.tar.gz && \
rm LMDB_0.9.15.tar.gz && \
cd lmdb-LMDB_0.9.15/libraries/liblmdb && \
make all install && \
ldconfig && \
cd /tmp && \
rm -r /tmp/lmdb-LMDB_0.9.15

RUN luarocks install bit32
RUN luarocks install copas 1.1.6-1
RUN luarocks install lightningmdb
RUN luarocks install luaposix
RUN apt-get install -y nginx-extras
RUN apt-get install -y vim

ENV HOME /root
WORKDIR $HOME

COPY *.lua $HOME/
COPY lunit-0.5 $HOME/lunit-0.5
COPY tests $HOME/tests
COPY fdi $HOME/fdi/
COPY scent $HOME/scent
COPY muleview $HOME/muleview
COPY docker/nginx.mule.conf $HOME/

RUN ln -s /root/nginx.mule.conf /etc/nginx/sites-enabled/mule
RUN mkdir -p /root/queues/mule_incoming
RUN mkdir -p /root/queues/mule_processed
RUN mkdir -p /root/queues/mule_work
RUN chmod o+rw /root/queues/*
RUN chown www-data scent muleview
RUN chmod u+x scent muleview
RUN chmod o+x /root

RUN mkdir -p $HOME/tests/temp
60 changes: 60 additions & 0 deletions docker/nginx.mule.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
server {
listen 8080 default_server;
server_name _;

if ($request_method !~ ^(GET|HEAD|POST|PUT|DELETE)$) {
return 403;
}

set $mule_root "/root";


location = /mule/api/graph {
limit_except POST { deny all; }

client_body_temp_path "/root/queues/mule_work/";
client_body_in_file_only on;
client_body_buffer_size 128K;
client_max_body_size 1000M;
lua_need_request_body on;
content_by_lua '
ngx.req.read_body()
local body_file = ngx.req.get_body_file()
local base_name = string.match(body_file,"/([^/]*)$")
local content = io.open(body_file,"rb"):read("*all")

local function write_to_path(content,path)
local out = io.open(body_file..".tmp","wb")
out:write(content)
out:close()

os.rename(body_file..".tmp",string.format("%s/%s-%s.mule",path,ngx.var.remote_addr,base_name))
end
write_to_path(content,"/root/queues/mule_incoming")
ngx.exit(202)
';
}

location /mule/api/ {
gzip_proxied any;
add_header Access-Control-Allow-Origin *;
proxy_pass http://localhost:8981/;
}

rewrite ^/mule$ /mule/ permanent;

location /mule/ {
# change the path as necessary
index index.html;
alias "/root/muleview/build/production/";
expires 1d;
}
rewrite ^/scent$ /scent/ permanent;
location /scent/ {
# change the path as necessary
root /root;
index index.html;
expires 1m;
}

}
61 changes: 0 additions & 61 deletions mule.nginx.conf

This file was deleted.

58 changes: 58 additions & 0 deletions nginx.mule.conf.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
server {
listen 80 default_server;
server_name _;

if ($request_method !~ ^(GET|HEAD|POST|PUT|DELETE)$) {
return 403;
}


location = /mule/api/graph {
limit_except POST { deny all; }

client_body_temp_path '<mule_queues>/mule_work/';
client_body_in_file_only on;
client_body_buffer_size 128K;
client_max_body_size 1000M;
lua_need_request_body on;
content_by_lua '
ngx.req.read_body()
local body_file = ngx.req.get_body_file()
local base_name = string.match(body_file,"/([^/]*)$")
local content = io.open(body_file,"rb"):read("*all")

local function write_to_path(content,path)
local out = io.open(body_file..".tmp","wb")
out:write(content)
out:close()

os.rename(body_file..".tmp",string.format("%s/%s-%s.mule",path,ngx.var.remote_addr,base_name))
end
write_to_path(content,"<mule_queues>/mule_incoming")
ngx.exit(202)
';
}

location /mule/api/ {
gzip_proxied any;
add_header Access-Control-Allow-Origin *;
proxy_pass http://localhost:8981/;
}

rewrite ^/mule$ /mule/ permanent;

location /mule/ {
# change the path as necessary
index index.html;
alias '<mule_code>/muleview/build/production/';
expires 1d;
}
rewrite ^/scent$ /scent/ permanent;
location /scent/ {
# change the path as necessary
root <mule_code>;
index index.html;
expires 1m;
}

}

0 comments on commit 33de7aa

Please sign in to comment.