Files
geoip2-nginx/dockerfile
T
pi-ux-ce 815d63d0b5
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 56s
adding dockerfile and other files
2026-03-12 17:40:43 +00:00

44 lines
1.4 KiB
Docker

# Stage 1: Build the module
FROM nginx:1.26.3 AS builder
# Install build tools and MaxMind library
RUN apt-get update && \
apt-get install -y build-essential libmaxminddb-dev libpcre3-dev zlib1g-dev libssl-dev wget git && \
rm -rf /var/lib/apt/lists/*
#https://nginx.org/download/nginx-1.26.3.tar.gz
# Download NGINX source matching the container version
RUN wget http://nginx.org/download/nginx-1.26.3.tar.gz && \
tar zxf nginx-1.26.3.tar.gz
# Clone the specific GeoIP2 module project
RUN git clone https://github.com/leev/ngx_http_geoip2_module.git
# Compile the module as a dynamic module
RUN cd nginx-${NGINX_VERSION} && \
./configure --with-compat --add-dynamic-module=../ngx_http_geoip2_module && \
make modules
# Stage 2: Final Image
FROM nginx:1.26.3
# Install only the runtime library
RUN apt-get update && apt-get install -y libmaxminddb0 && rm -rf /var/lib/apt/lists/*
# Copy the compiled .so file from the builder
COPY --from=builder /nginx-1.26.3/objs/ngx_http_geoip2_module.so /usr/lib/nginx/modules/
# Copy your GeoIP database and NGINX config
# Ensure these files are in the same folder as this Dockerfile
# Copy your GeoLite2 database into the container
COPY ./data/dbip-country-lite-2026-01.mmdb /etc/nginx/geoip/GeoLite2-Country.mmdb
COPY ./data/dbip-country-lite-2026-01.mmdb /data/dbip-country-lite-2026-01.mmdb
# Copy your custom nginx config
COPY ./nginx/nginx.conf /etc/nginx/nginx.conf
EXPOSE 80