diff --git a/Dockerfile b/Dockerfile index 42de21f..34a2fbf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,8 @@ ARG OPENSSL_CHECKSUM="fc20130f8b7cbd2fb918b2f14e2f429e109c31ddd0fb38fc5d71d9ffed ARG NGINX_VERSION="1.15.8" ARG NGINX_CHECKSUM="a8bdafbca87eb99813ae4fcac1ad0875bf725ce19eb265d28268c309b2b40787" ARG NGINX_CONFIG="\ + --with-cc-opt='-static' \ + --with-ld-opt='-static' \ --sbin-path=/nginx \ --conf-path=/etc/nginx/nginx.conf \ --pid-path=/tmp/nginx.pid \ @@ -57,11 +59,15 @@ RUN apt update && \ make -FROM gcr.io/distroless/base +FROM scratch +COPY rootfs / + +COPY --from=build /lib/x86_64-linux-gnu/ld-2.24.so /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 \ + /lib/x86_64-linux-gnu/libc-2.24.so /lib/x86_64-linux-gnu/libc.so.6 \ + /lib/x86_64-linux-gnu/libnss_files-2.24.so /lib/x86_64-linux-gnu/libnss_files.so.2 \ + /lib/x86_64-linux-gnu/ COPY --from=build /tmp/nginx/objs/nginx /nginx COPY --from=build /tmp/nginx/html /etc/nginx/html -COPY conf /etc/nginx - ENTRYPOINT ["/nginx", "-g", "daemon off;"] diff --git a/README.md b/README.md index c434fa8..6109b70 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ Available at [`ricardbejarano/nginx`](https://hub.docker.com/r/ricardbejarano/ng ## Features -* Super tiny (only `13MB`) +* Super tiny (only `18MB`) * Built from source, including libraries -* Based on the official `gcr.io/distroless/base` image +* Based on `scratch`, see [Filesystem](#Filesystem) for an exhaustive list of the image's contents * Included [TLS1.3](https://tools.ietf.org/html/rfc8446) protocol support (with [OpenSSL](https://www.openssl.org/)) * Included [brotli](https://github.com/google/brotli) compression support (with [ngx_brotli](https://github.com/google/ngx_brotli)) @@ -18,9 +18,36 @@ Available at [`ricardbejarano/nginx`](https://hub.docker.com/r/ricardbejarano/ng Mount your **configuration** on the container's `/etc/nginx` folder. -Mount your **content** on the container's `/etc/nginx/html` folder. +Mount your **web content** on the container's `/etc/nginx/html` folder. +## Filesystem + +The image's contents are: + +``` +/ +├── etc/ +│ ├── group/ +│ ├── nginx/ +│ │ ├── html/ +│ │ │ ├── 50x.html +│ │ │ └── index.html +│ │ ├── mime.types +│ │ └── nginx.conf +│ └── passwd/ +├── lib/ +│ └── x86_64-linux-gnu/ +│ ├── ld-2.24.so +│ ├── ld-linux-x86-64.so.2 → ld-2.24.so +│ ├── libc-2.24.so +│ ├── libc.so.6 → libc-2.24.so +│ ├── libnss_files-2.24.so +│ └── libnss_files.so.2 → libnss_files-2.24.so +├── nginx +└── tmp/ +``` + ## License See [LICENSE](https://github.com/ricardbejarano/nginx/blob/master/LICENSE). diff --git a/rootfs/etc/group b/rootfs/etc/group new file mode 100644 index 0000000..1dbf901 --- /dev/null +++ b/rootfs/etc/group @@ -0,0 +1 @@ +root:x:0: diff --git a/conf/mime.types b/rootfs/etc/nginx/mime.types similarity index 100% rename from conf/mime.types rename to rootfs/etc/nginx/mime.types diff --git a/conf/nginx.conf b/rootfs/etc/nginx/nginx.conf similarity index 100% rename from conf/nginx.conf rename to rootfs/etc/nginx/nginx.conf diff --git a/rootfs/etc/passwd b/rootfs/etc/passwd new file mode 100644 index 0000000..f8a6805 --- /dev/null +++ b/rootfs/etc/passwd @@ -0,0 +1 @@ +root:x:0:0:root:/:/nginx