Last active
January 19, 2020 09:41
-
-
Save yuokada/15ba7e400035d72edf76b162e969e9aa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # load_module modules/ngx_http_js_module.so; | |
| js_include hello_world.js; | |
| server { | |
| # see: http://nginx.org/en/docs/http/server_names.html | |
| server_name _; | |
| location = /favicon.ico { access_log off; log_not_found off; } | |
| location /lua_hello { | |
| default_type text/html; | |
| content_by_lua ' | |
| ngx.say("<p>Hello Lua!</p>") | |
| '; | |
| } | |
| location /js_hello { | |
| js_content hello; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| FROM openresty/openresty:1.15.8.2-alpine-fat AS builder | |
| # Our NCHAN version | |
| ENV NGINX_VERSION 1.15.8 | |
| ENV NJS_VERSION 0.3.7 | |
| # For latest build deps, see https://github.com/nginxinc/docker-nginx/blob/master/mainline/alpine/Dockerfile | |
| RUN apk add --no-cache --virtual .build-deps \ | |
| gcc \ | |
| libc-dev \ | |
| make \ | |
| openssl-dev \ | |
| pcre-dev \ | |
| zlib-dev \ | |
| linux-headers \ | |
| curl \ | |
| gnupg \ | |
| libxslt-dev \ | |
| gd-dev \ | |
| geoip-dev \ | |
| readline readline-dev libedit-dev | |
| # Download sources | |
| RUN wget "http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz" -O nginx.tar.gz && \ | |
| wget "https://github.com/nginx/njs/archive/${NJS_VERSION}.tar.gz" -O njs.tar.gz | |
| # Reuse same cli arguments as the nginx:alpine image used to build | |
| RUN CONFARGS=$(nginx -V 2>&1 | sed -n -e 's/^.*arguments: //p') \ | |
| tar -zxC /usr/local -f nginx.tar.gz && \ | |
| tar -xzvf "njs.tar.gz" -C /usr/local/nginx-${NGINX_VERSION} && \ | |
| NJSDIR="/usr/local/nginx-${NGINX_VERSION}/njs-${NJS_VERSION}/nginx" && \ | |
| cd /usr/local/nginx-${NGINX_VERSION} && \ | |
| ./configure --with-compat $CONFARGS --add-dynamic-module=$NJSDIR && \ | |
| make modules && make install && \ | |
| cd "/usr/local/nginx-${NGINX_VERSION}/njs-${NJS_VERSION}" && \ | |
| ./configure && make njs && \ | |
| cp build/njs /usr/local/bin/njs | |
| FROM openresty/openresty:1.15.8.2-6-alpine | |
| # Extract the dynamic module NCHAN from the builder image | |
| COPY --from=builder /usr/local/nginx/modules/ngx_http_js_module.so /usr/local/openresty/nginx/modules/ngx_http_js_module.so | |
| COPY --from=builder /usr/local/bin/njs /usr/local/bin/njs | |
| RUN apk add --no-cache --virtual .build-deps pcre-dev | |
| COPY nginx.conf /usr/local/openresty/nginx/conf/nginx.conf | |
| COPY default.conf /etc/nginx/conf.d/default.conf | |
| EXPOSE 80 | |
| STOPSIGNAL SIGTERM | |
| CMD ["nginx", "-g", "daemon off;"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function hello(r) { | |
| r.return(200, "Hello njs!\n"); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # nginx.conf -- docker-openresty | |
| # | |
| # This file is installed to: | |
| # `/usr/local/openresty/nginx/conf/nginx.conf` | |
| # and is the file loaded by nginx at startup, | |
| # unless the user specifies otherwise. | |
| # | |
| # It tracks the upstream OpenResty's `nginx.conf`, but removes the `server` | |
| # section and adds this directive: | |
| # `include /etc/nginx/conf.d/*.conf;` | |
| # | |
| # The `docker-openresty` file `nginx.vh.default.conf` is copied to | |
| # `/etc/nginx/conf.d/default.conf`. It contains the `server section | |
| # of the upstream `nginx.conf`. | |
| # | |
| # See https://github.com/openresty/docker-openresty/blob/master/README.md#nginx-config-files | |
| # | |
| #user nobody; | |
| worker_processes 1; | |
| #error_log logs/error.log; | |
| #error_log logs/error.log notice; | |
| #error_log logs/error.log info; | |
| #pid logs/nginx.pid; | |
| load_module modules/ngx_http_js_module.so; | |
| events { | |
| worker_connections 1024; | |
| } | |
| http { | |
| include mime.types; | |
| default_type application/octet-stream; | |
| #log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
| # '$status $body_bytes_sent "$http_referer" ' | |
| # '"$http_user_agent" "$http_x_forwarded_for"'; | |
| #access_log logs/access.log main; | |
| # See Move default writable paths to a dedicated directory (#119) | |
| # https://github.com/openresty/docker-openresty/issues/119 | |
| client_body_temp_path /var/run/openresty/nginx-client-body; | |
| proxy_temp_path /var/run/openresty/nginx-proxy; | |
| fastcgi_temp_path /var/run/openresty/nginx-fastcgi; | |
| uwsgi_temp_path /var/run/openresty/nginx-uwsgi; | |
| scgi_temp_path /var/run/openresty/nginx-scgi; | |
| sendfile on; | |
| #tcp_nopush on; | |
| #keepalive_timeout 0; | |
| keepalive_timeout 65; | |
| #gzip on; | |
| include /etc/nginx/conf.d/*.conf; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment