nginx-with-fancy-index/Dockerfile
Liam f7fd878df8
All checks were successful
Publish Docker Image / docker (push) Successful in 1m12s
stuffings
2023-10-26 12:10:13 +01:00

45 lines
1.2 KiB
Docker

# Stage 1: Build Nginx from source
FROM alpine:latest AS build
# Install build tools and dependencies
RUN apk update && apk upgrade
RUN apk add build-base wget pcre-dev zlib-dev git openssl-dev
# Download Nginx source code
WORKDIR /tmp
RUN wget http://nginx.org/download/nginx-1.25.3.tar.gz
RUN tar -zxvf nginx-*.tar.gz
RUN git clone https://github.com/aperezdc/ngx-fancyindex.git ngx-fancyindex
# Build Nginx from source
RUN cd nginx-* && ./configure --prefix=/usr/local/nginx \
--sbin-path=/usr/local/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_ssl_module \
--add-module=../ngx-fancyindex \
&& make \
&& make install
# Stage 2: Create a minimal runtime image
FROM alpine:latest
# Install runtime dependencies
RUN apk update && apk upgrade
RUN apk add pcre pcre-dev
# Copy Nginx binary and configuration from the build stage
COPY --from=build /usr/local/sbin/nginx /usr/local/sbin/nginx
COPY --from=build /etc/nginx /etc/nginx
# Copy custom Nginx configuration
COPY ./nginx.conf /etc/nginx/nginx.conf
# Expose the default HTTP port
EXPOSE 80
# Start Nginx when the container runs
CMD ["/usr/local/sbin/nginx", "-g", "daemon off;"]