|
| 1 | +# Supported tags and respective `Dockerfile` links |
| 2 | + |
| 3 | +- [`1.13.35.2`, `stable`, `1.13.35`, `1.13`, `1.13.35.2-alpine3.8`, `1.13.35-alpine3.8`, `1.13-alpine3.8`, `stable-alpine3.8`, `1.13.35.2-alpine3.8-ngx1.14`, `1.13.35-alpine3.8-ngx1.14`, `1.13-alpine3.8-ngx1.14`, `stable-alpine3.8-ngx1.14`, `latest` (*alpine-3.8/nginx-stable/Dockerfile*)](https://github.com/apache/incubator-pagespeed-ngx/blob/master/docker/alpine-3.8/nginx-stable/Dockerfile) |
| 4 | +- [`1.13.35.2-edge`, `stable-edge`, `edge`, `1.13.35-edge`, `1.13-edge`, `1.13.35.2-edge-ngx1.14`, `1.13.35-edge-ngx1.14`, `1.13-edge-ngx1.14`, `stable-edge-ngx1.14` (*alpine-edge/nginx-stable/Dockerfile*)](https://github.com/apache/incubator-pagespeed-ngx/blob/master/docker/alpine-edge/nginx-stable/Dockerfile) |
| 5 | +- [`1.13.35.2-alpine3.8-ngx1.15`, `ngx1.15`, `1.13.35-alpine3.8-ngx1.15`, `1.13-alpine3.8-ngx1.15`, `stable-alpine3.8-ngx1.15` (*alpine-3.8/nginx-mainline/Dockerfile*)](https://github.com/apache/incubator-pagespeed-ngx/blob//master/docker/alpine-3.8/nginx-mainline/Dockerfile) |
| 6 | +- [`1.13.35.2-edge-ngx1.15`, `1.13.35-edge-ngx1.15`, `1.13-edge-ngx1.15`, `stable-edge-ngx1.15` (*alpine-edge/nginx-mainline/Dockerfile*)](https://github.com/apache/incubator-pagespeed-ngx/blob/master/docker/alpine-edge/nginx-mainline/Dockerfile) |
| 7 | + |
| 8 | +# Quick reference |
| 9 | + |
| 10 | +- **Where to get help**: |
| 11 | + [Read the wiki](https://github.com/apache/incubator-pagespeed-mod/wiki), [Ask a question on the mailing list](https://groups.google.com/group/ngx-pagespeed-discuss) |
| 12 | + |
| 13 | +- **Docker image repository**: |
| 14 | + [Dockerhub](https://hub.docker.com/r/pagespeed/nginx-pagespeed) |
| 15 | + |
| 16 | +- **Git Dockerfile repository**: |
| 17 | + [Github](https://github.com/apache/incubator-pagespeed-ngx/tree/master/docker) |
| 18 | + |
| 19 | +- **Where to file issues**: |
| 20 | + [https://github.com/We-Amp/ngx-pagespeed-alpine/issues](https://github.com/apache/incubator-pagespeed-ngx/issues) |
| 21 | + |
| 22 | +- **Docker images maintained by**: |
| 23 | + [Nico Berlee](mailto:[email protected]) |
| 24 | + |
| 25 | +- **Supported Docker versions**: |
| 26 | + [the latest release](https://github.com/docker/docker-ce/releases/latest) (down to 1.12 on a best-effort basis) |
| 27 | + |
| 28 | +# What is pagespeed? |
| 29 | + |
| 30 | +The PageSpeed Modules, [mod_pagespeed](https://github.com/apache/incubator-pagespeed-mod) and [ngx_pagespeed](https://github.com/apache/incubator-pagespeed-ngx), are open-source webserver modules that [optimize your site automatically](https://www.modpagespeed.com/doc/filters). |
| 31 | + |
| 32 | +ngx_pagespeed speeds up your site and reduces page load time by automatically |
| 33 | +applying web performance best practices to pages and associated assets (CSS, |
| 34 | +JavaScript, images) without requiring you to modify your existing content or |
| 35 | +workflow. Features include: |
| 36 | + |
| 37 | +- Image optimization: stripping meta-data, dynamic resizing, recompression |
| 38 | +- CSS & JavaScript minification, concatenation, inlining, and outlining |
| 39 | +- Small resource inlining |
| 40 | +- Deferring image and JavaScript loading |
| 41 | +- HTML rewriting |
| 42 | +- Cache lifetime extension |
| 43 | +- and [more](https://developers.google.com/speed/docs/mod_pagespeed/config_filters) |
| 44 | + |
| 45 | +To see ngx_pagespeed in action, with example pages for each of the |
| 46 | +optimizations, see our [demonstration site](http://ngxpagespeed.com). |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +# What is nginx? |
| 51 | + |
| 52 | +Nginx (pronounced "engine-x") is an open source reverse proxy server for HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer, HTTP cache, and a web server (origin server). The nginx project started with a strong focus on high concurrency, high performance and low memory usage. |
| 53 | +> [wikipedia.org/wiki/Nginx](https://en.wikipedia.org/wiki/Nginx) |
| 54 | +
|
| 55 | +# What is nginx-pagespeed? |
| 56 | + |
| 57 | +The nginx-pagespeed brings all the goods of nginx and pagespeed together in one single small alpine docker image. Nginx-pagespeed aims to be 100% compatible with the plain [nginx](https://hub.docker.com/_/nginx/) images. Meaning, nginx-pagespeed can be a safe drop-in replacement for any container running `nginx:alpine`. |
| 58 | + |
| 59 | +Nginx-pagespeed makes it easy to start optimizing your website by reducing page load time, without requiring you to modify existing content. |
| 60 | + |
| 61 | +# How to use this image |
| 62 | + |
| 63 | +## Hosting some simple static content |
| 64 | + |
| 65 | +```console |
| 66 | +$ docker run --name pagespeed-nginx -v /some/content:/usr/share/nginx/html:ro -d pagespeed/nginx-pagespeed |
| 67 | +``` |
| 68 | + |
| 69 | +Alternatively, a simple `Dockerfile` can be used to generate a new image that includes the necessary content (which is a much cleaner solution than the bind mount above): |
| 70 | + |
| 71 | +```dockerfile |
| 72 | +FROM pagespeed/nginx-pagespeed |
| 73 | +COPY static-html-directory /usr/share/nginx/html |
| 74 | +``` |
| 75 | + |
| 76 | +Place this file in the same directory as your directory of content ("static-html-directory"), run `docker build -t some-content-ngxpagespeed .`, then start your container: |
| 77 | + |
| 78 | +```console |
| 79 | +$ docker run --name my-nginx-pagespeed -d some-content-ngxpagespeed |
| 80 | +``` |
| 81 | + |
| 82 | +## Exposing external port |
| 83 | + |
| 84 | +```console |
| 85 | +$ docker run --name my-nginx-pagespeed -d -p 8080:80 some-content-ngxpagespeed |
| 86 | +``` |
| 87 | + |
| 88 | +Then you can hit `http://localhost:8080` or `http://host-ip:8080` in your browser. |
| 89 | + |
| 90 | +## Complex configuration |
| 91 | + |
| 92 | +```console |
| 93 | +$ docker run --name my-custom-nginx-pagespeed -v /host/path/nginx.conf:/etc/nginx/nginx.conf:ro -d pagespeed/nginx-pagespeed |
| 94 | +``` |
| 95 | + |
| 96 | +For information on the syntax of the nginx configuration files, see [the official documentation](http://nginx.org/en/docs/) (specifically the [Beginner's Guide](http://nginx.org/en/docs/beginners_guide.html#conf_structure)). For pagespeed specific nginx config syntax, see [Beginner's guide](https://www.modpagespeed.com/doc/configuration) or a complete overview of [all pagespeed filters](https://www.ngxpagespeed.com/). |
| 97 | +For a quick start on pagespeed specific configuration see [] |
| 98 | + |
| 99 | +If you wish to adapt the default configuration, use something like the following to copy it from a running nginx-pagespeed container: |
| 100 | + |
| 101 | +```console |
| 102 | +$ docker run --name tmp-ngxpagespeed-container -d pagespeed/nginx-pagespeed |
| 103 | +$ docker cp tmp-ngxpagespeed-container:/etc/nginx/nginx.conf /host/path/nginx.conf |
| 104 | +$ docker rm -f tmp-ngxpagespeed-container |
| 105 | +``` |
| 106 | + |
| 107 | +This can also be accomplished more cleanly using a simple `Dockerfile` (in `/host/path/`): |
| 108 | + |
| 109 | +```dockerfile |
| 110 | +FROM pagespeed/nginx-pagespeed |
| 111 | +COPY nginx.conf /etc/nginx/nginx.conf |
| 112 | +``` |
| 113 | + |
| 114 | +If you add a custom `CMD` in the Dockerfile, be sure to include `-g daemon off;` in the `CMD` in order for nginx to stay in the foreground, so that Docker can track the process properly (otherwise your container will stop immediately after starting)! |
| 115 | + |
| 116 | +Then build the image with `docker build -t custom-ngxpagespeed .` and run it as follows: |
| 117 | + |
| 118 | +```console |
| 119 | +$ docker run --name my-custom-ngxpagespeed-container -d custom-ngxpagespeed |
| 120 | +``` |
| 121 | + |
| 122 | +### Using environment variables in nginx configuration |
| 123 | + |
| 124 | +Out-of-the-box, nginx doesn't support environment variables inside most configuration blocks. But `envsubst` may be used as a workaround if you need to generate your nginx configuration dynamically before nginx starts. |
| 125 | + |
| 126 | +Here is an example using docker-compose.yml: |
| 127 | + |
| 128 | +```yaml |
| 129 | +web: |
| 130 | + image: pagespeed/nginx-pagespeed |
| 131 | + volumes: |
| 132 | + - ./mysite.template:/etc/nginx/conf.d/mysite.template |
| 133 | + ports: |
| 134 | + - "8080:80" |
| 135 | + environment: |
| 136 | + - NGINX_HOST=foobar.com |
| 137 | + - NGINX_PORT=80 |
| 138 | + command: /bin/bash -c "envsubst < /etc/nginx/conf.d/mysite.template > /etc/nginx/conf.d/default.conf && nginx -g 'daemon off;'" |
| 139 | +``` |
| 140 | +
|
| 141 | +The `mysite.template` file may then contain variable references like this: |
| 142 | + |
| 143 | +`listen ${NGINX_PORT}; |
| 144 | +` |
| 145 | + |
| 146 | +# Image Variants |
| 147 | + |
| 148 | +The `pagespeed/nginx-pagespeed` images come in many flavors, each designed for a specific use case. |
| 149 | + |
| 150 | +## `pagespeed/nginx-pagespeed:<version>` |
| 151 | + |
| 152 | +This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of. |
| 153 | + |
| 154 | +## `nginx:edge` |
| 155 | + |
| 156 | +This image has the most up-to-date system packages available in the [Alpine Linux project](http://alpinelinux.org). This means the latest LibreSSL and musl-libc, with the downside of having less tested system packages. |
| 157 | + |
| 158 | + |
| 159 | +## Using the Dockerfile |
| 160 | +### Use docker build command to build an image from dockerfile: |
| 161 | + docker build -t <image_tag> <dockerfile_path> . |
| 162 | + $ docker build -t ngxpagespeed-alpine38-ngxstable stable/3.8/nginx-stable |
| 163 | + Refer [this](https://docs.docker.com/engine/reference/commandline/build/) for additional options. |
| 164 | + |
| 165 | +### Run this container as an independent service: |
| 166 | + $ docker run -d -p 80:80 <image_tag> |
| 167 | + Refer [this](https://docs.docker.com/engine/reference/run/) for additional options. |
| 168 | + |
| 169 | +## Requirements for building: |
| 170 | +- > 3 GB of free diskspace |
| 171 | +- 2GB of memory |
| 172 | +- an x86_64 compatible processor |
| 173 | +- Docker CE > 17.3.2 |
| 174 | + |
| 175 | + |
| 176 | +# Disclaimer |
| 177 | +Apache PageSpeed is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. |
| 178 | + |
| 179 | +# License |
| 180 | +View [PageSpeed license information](https://github.com/apache/incubator-pagespeed-ngx/blob/master/LICENSE) |
| 181 | +View [Nginx license information](http://nginx.org/LICENSE) |
| 182 | + |
| 183 | +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). |
| 184 | + |
| 185 | +Some additional license information which was able to be auto-detected might be found in [the `repo-info` repository's `nginx/` directory](https://github.com/docker-library/repo-info/tree/master/repos/nginx). |
| 186 | + |
| 187 | +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. |
0 commit comments