Dockerfile set-up to build statically linked NGINX from source with modules.
The following features are added on top of the official set-up in https://hub.docker.com/_/nginx:
- The
nginxbinary is fully statically linked and is based offmusl - Non-root user
nginxis added, and thenginxbase directory is in/opt/nginxinstead of/etc/nginx. - All the generated files from running
nginxshould reside within/opt/nginxsubdirectories, and the permissions of the subdirectories are generally accessible to the non-root usernginxby default. teraCLI is optionally installed. Simply add Docker build argTERA_VERSION=v0.1.1to enable this. This enables templating injection of*.conf.tmplconfig files into*.confat runtime. The following locations are searched to apply the interpolation:/opt/nginx/conf/nginx.conf.tmpl>/opt/nginx/conf/nginx.conf/opt/nginx/conf/conf.tmpl.d/*.conf.tmpl>/opt/nginx/conf/conf.d/*.conf/opt/nginx/conf/conf.d/*.conf.tmpl>/opt/nginx/conf/conf.d/*.conf
docker build . -t guangie88/test-nginx-custom
docker run --rm -it -p 8080:8080 guangie88/test-nginx-customdocker build . \
--build-arg MODULES="--with-http_ssl_module" \
-t guangie88/test-nginx-custom
docker run --rm -it -p 8080:8080 guangie88/test-nginx-customdocker build . \
--build-arg TERA_VERSION=v0.1.1 \
--build-arg MODULES="--with-http_ssl_module" \
-t guangie88/test-nginx-custom
docker run --rm -it -p 8080:8080 guangie88/test-nginx-custom