Skip to content

Instantly share code, notes, and snippets.

@nemunaire
Created November 2, 2017 01:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemunaire/c6d32f6882d329cd3ed599844aca9355 to your computer and use it in GitHub Desktop.
Save nemunaire/c6d32f6882d329cd3ed599844aca9355 to your computer and use it in GitHub Desktop.
A Dockerfile to build a statically linked nginx (for educational purpose)
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