Coder Social home page Coder Social logo

yisiqi / docker-nginx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from levonet/docker-nginx

0.0 0.0 0.0 284 KB

NGINX docker build with CPU optimization and load balancer modules

Home Page: https://hub.docker.com/r/levonet/nginx

License: MIT License

JavaScript 52.64% Makefile 0.92% Dockerfile 46.44%

docker-nginx's Introduction

Supported tags and respective Dockerfile links

NGINX build with load balancer modules

Docker Pulls

Fastest and smaller Nginx built for x86-64 CPU architecture. Nginx binaries are compiled to leverage SSE 4.2 instruction set.

The difference from the official Nginx docker image:

How to use this image

Hosting some simple static content

docker run --name some-nginx -d -v /some/content:/usr/share/nginx/html:ro levonet/nginx

Exposing ports

docker run --name some-nginx -d -p 80:80 -e 443 -p 443:443 levonet/nginx

Complex configuration

docker run --name some-nginx -d -v /host/path/virtualhosts.d:/etc/nginx/sites-enabled:ro levonet/nginx

For example porting Ubuntu nginx to docker:

docker run --name some-nginx -d -p 80:80 -e 443 -p 443:443 \
    -v /etc/nginx/conf.d:/etc/nginx/conf.d \
    -v /etc/nginx/sites-available:/etc/nginx/sites-available \
    -v /etc/nginx/sites-enabled:/etc/nginx/sites-enabled \
    -v /var/log/nginx:/var/log/nginx \
    levonet/nginx

Modules

List dynamic modules in container:

docker run -t --rm levonet/nginx ls /usr/lib/nginx/modules

Example of loading a module in nginx.conf:

load_module modules/ngx_http_js_module.so;

njs scripts development

docker run -it --rm levonet/nginx njs
>> var a = {b: []};
undefined
>> console.log(a);
{b:[]}
undefined
>> JSON.stringify(a);
'{"b":[]}'
>>

Test & Examles

Sample configurations and module tests are located in a folder named test.

To run tests, go to the folder test and run command make.

To start a specific example, go to an example folder and run docker-compose up.

Image Variants

levonet/nginx:<version>-alpine

This image is based on the popular Alpine Linux project, available in the alpine official image. Alpine Linux is much smaller than most distribution base images (~5MB), and thus leads to much slimmer images in general.

This variant is highly recommended when final image size being as small as possible is desired. The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements. However, most software doesn't have an issue with this, so this variant is usually a very safe choice. See this Hacker News comment thread for more discussion of the issues that might arise and some pro/con comparisons of using Alpine-based images.

To minimize image size, it's uncommon for additional related tools (such as git or bash) to be included in Alpine-based images. Using this image as a base, add the things you need in your own Dockerfile (see the alpine image description for examples of how to install packages if you are unfamiliar).

License

View license information for the software contained in this image or license information for the Nginx Dockerfile.

As with all Docker images, these likely also contain other software which may be under other licenses (such as Bash, etc from the base distribution, along with any direct or indirect dependencies of the primary software being contained).

As for any pre-built image usage, it is the image user's responsibility to ensure that any use of this image complies with any relevant licenses for all software contained within.

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.