Code Monkey home page Code Monkey logo

docker-ngx_mruby's Introduction

Simple Dockerfile for ngx_mruby

This is very simple Dockerfile and related files for ngx_mruby.

Connecting to https://hub.docker.com/r/matsumotory/docker-ngx_mruby/.

matsumotory/ngx-mruby image on Docker Hub

matsumotory/ngx-mruby image on Docker Hub is an official ngx_mruby docker image. This image supports ONBUILD for below commands.

ONBUILD ADD docker/hook /usr/local/nginx/hook
ONBUILD ADD docker/conf /usr/local/nginx/conf
ONBUILD ADD docker/conf/nginx.conf /usr/local/nginx/conf/nginx.conf

So, you can create docker/ directory which include the nginx config files (docker/conf/) and ngx_mruby hook scripts (docker/hook/) into the same directory as Dockerfile before building Dockerfile.

nginx version and modules on matsumotory/ngx-mruby image

We built nginx with ngx_mruby linked with commonly-used some nginx modules.

$ sudo docker run -p 80:80 matsumotory/ngx-mruby /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.7.10
built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
TLS SNI support enabled
configure arguments: --add-module=/usr/local/src/ngx_mruby --add-module=/usr/local/src/ngx_mruby/dependence/ngx_devel_kit --with-http_stub_status_module --with-http_ssl_module --prefix=/usr/local/nginx --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module

Simple Example

prepare nginx config and ngx_mruby hook files

  • current_dir/Dockerfile
FROM matsumotory/ngx_mruby:master
MAINTAINER matsumotory
  • current_dir/docker/conf/nginx.conf
user daemon;
daemon off;
master_process off;
worker_processes 1;
error_log stderr;

events {
    worker_connections 1024;
}

http {
    server {
        listen 80;

        location /mruby-hello {
            mruby_content_handler_code 'Nginx.echo "server ip: #{Nginx::Connection.new.local_ip}: hello ngx_mruby world."';
        }

        location /mruby-test {
            mruby_content_handler /usr/local/nginx/hook/test.rb;
        }

        location / {
            resolver 8.8.8.8;
            mruby_set_code $backend '["blog.matsumoto-r.jp", "hb.matsumoto-r.jp"][rand(2)]';
            proxy_pass http://$backend;
        }
    }
}
  • current_dir/docker/hook/test.rb
Nginx.echo "This is test for ngx_mruby"

build and run

cd current_dir/
sudo docker build -t local/docker-ngx_mruby .
sudo docker run -p 80:80 -t local/docker-ngx_mruby

access to ngx_mruby

$ curl http://127.0.0.1/mruby-hello
server ip: 172.17.0.200: hello ngx_mruby world.
$ curl http://127.0.0.1/mruby-test
This is test for ngx_mruby

enjoy!!!

License

under the MIT License:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.