Created
November 2, 2017 01:23
-
-
Save nemunaire/c6d32f6882d329cd3ed599844aca9355 to your computer and use it in GitHub Desktop.
A Dockerfile to build a statically linked nginx (for educational purpose)
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 alpine as build | |
RUN apk add --no-cache gcc make musl-dev | |
RUN wget -O /tmp/nginx.tar.gz http://nginx.org/download/nginx-1.13.6.tar.gz && \ | |
mkdir /tmp/nginx && \ | |
tar xf /tmp/nginx.tar.gz -C /tmp/nginx --strip-components=1 && \ | |
cd /tmp/nginx && \ | |
./configure --prefix=/ --with-cc=/usr/bin/cc --with-cc-opt="-static -static-libgcc" --with-ld-opt="-static" --with-ipv6 --with-poll_module --without-http_rewrite_module --without-http_gzip_module && \ | |
make -j5 | |
FROM scratch | |
COPY --from=build /tmp/nginx/objs/nginx / | |
COPY nginx.conf / | |
VOLUME /logs | |
EXPOSE 80 | |
CMD ["/nginx", "-c", "/nginx.conf", "-g", "daemon off;"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment