From 2773b848b13553ba26987afd10ee078df2e230b5 Mon Sep 17 00:00:00 2001 From: Steven Alexander Date: Tue, 5 May 2015 11:18:30 +0100 Subject: [PATCH] modified to install and run OpenResty --- Dockerfile | 25 ++++++++++++++++--------- README.md | 18 ++++++++++++------ conf/.gitignore | 6 ++++++ conf/example.lua | 2 ++ conf/logs/.gitignore | 2 ++ conf/nginx.conf | 24 ++++++++++++++++++++++++ 6 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 conf/.gitignore create mode 100644 conf/example.lua create mode 100644 conf/logs/.gitignore create mode 100644 conf/nginx.conf diff --git a/Dockerfile b/Dockerfile index 85c0b819..823deb42 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,22 +1,29 @@ FROM debian:jessie -MAINTAINER NGINX Docker Maintainers "docker-maint@nginx.com" +MAINTAINER NGINX Steven Alexander "steven.william.alexander@googlemail.com" -RUN apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 -RUN echo "deb http://nginx.org/packages/mainline/debian/ jessie nginx" >> /etc/apt/sources.list - -ENV NGINX_VERSION 1.9.0-1~jessie +ENV OPENRESTY_VERSION 1.7.10.1 +# OpenResty deps RUN apt-get update && \ - apt-get install -y ca-certificates nginx=${NGINX_VERSION} && \ - rm -rf /var/lib/apt/lists/* + apt-get -y install libreadline-dev libncurses5-dev libpcre3-dev libssl-dev perl build-essential curl + +# Install OpenResty with minimum modules for Lua scripting +RUN curl -O http://openresty.org/download/ngx_openresty-${OPENRESTY_VERSION}.tar.gz && \ + tar xzvf ngx_openresty-${OPENRESTY_VERSION}.tar.gz && \ + cd ngx_openresty-${OPENRESTY_VERSION}/ && \ + ./configure --with-luajit --with-http_gzip_static_module --with-http_ssl_module --with-pcre-jit && \ + make && \ + make install && \ + rm -rf /ngx_openresty* # forward request and error logs to docker log collector +RUN mkdir /var/log/nginx && touch /var/log/nginx/access.log && touch /var/log/nginx/error.log RUN ln -sf /dev/stdout /var/log/nginx/access.log RUN ln -sf /dev/stderr /var/log/nginx/error.log -VOLUME ["/var/cache/nginx"] +VOLUME ["/opt/nginx/conf"] EXPOSE 80 443 -CMD ["nginx", "-g", "daemon off;"] +CMD ["/usr/local/openresty/nginx/sbin/nginx", "-p", "/opt/nginx/conf", "-c", "nginx.conf"] diff --git a/README.md b/README.md index f0d253c2..12d3b56e 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ -# About this Repo +# Docker OpenResty -This is the Git repo of the official Docker image for [nginx](https://registry.hub.docker.com/_/nginx/). See the -Hub page for the full readme on how to use the Docker image and for information -regarding contributing and issues. +Example Dockerfile for building an [nginx](http://wiki.nginx.org/Main) image with [OpenResty](http://openresty.org). Based off the original [docker/nginx](https://github.com/dockerfile/nginx) image. -The full readme is generated over in [docker-library/docs](https://github.com/docker-library/docs), -specificially in [docker-library/docs/nginx](https://github.com/docker-library/docs/tree/master/nginx). +## Run +``` +# build image +docker build -t stevena/openresty:v1 . + +# run container +docker run -t -i -p 80:8080 -v=`pwd`/conf:/opt/nginx/conf -w=/opt/nginx/conf stevena/openresty:v1 + +# curl your boot2docker VM IP and you will see "Hello World by Lua!" +``` diff --git a/conf/.gitignore b/conf/.gitignore new file mode 100644 index 00000000..b50273d6 --- /dev/null +++ b/conf/.gitignore @@ -0,0 +1,6 @@ +*.* +logs/* +!.gitignore +!example.lua +!nginx.conf +!logs/.gitignore diff --git a/conf/example.lua b/conf/example.lua new file mode 100644 index 00000000..a16974e1 --- /dev/null +++ b/conf/example.lua @@ -0,0 +1,2 @@ +ngx.say('Hello World by Lua!') +ngx.exit(200) diff --git a/conf/logs/.gitignore b/conf/logs/.gitignore new file mode 100644 index 00000000..67c04e47 --- /dev/null +++ b/conf/logs/.gitignore @@ -0,0 +1,2 @@ +*.* +!.gitignore diff --git a/conf/nginx.conf b/conf/nginx.conf new file mode 100644 index 00000000..6a73aa9d --- /dev/null +++ b/conf/nginx.conf @@ -0,0 +1,24 @@ +worker_processes 1; +error_log stderr notice; +daemon off; +events { + worker_connections 1024; +} + +http { + variables_hash_max_size 1024; + access_log off; + include /usr/local/openresty/nginx/conf/mime.types; + + charset utf-8; + + server { + listen 8080; + lua_code_cache off; + + location / { + default_type text/html; + content_by_lua_file "example.lua"; + } + } +}