allinurl / goaccess

GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
https://goaccess.io
MIT License
18.37k stars 1.11k forks source link

GeoIP problem with Dockerized goaccess #1090

Closed josefkorbel closed 6 years ago

josefkorbel commented 6 years ago

Hello again,

Goaccess is awesome, I'm just struggling now with adding geoIP support to my dashboard, since Im running goaccess in Docker, installing any packages on my local machine does not have any effect, but installing libgeoip-dev in docker container is somehow not possible.

My Dockerfile

# Builds a goaccess image from the current working directory:
FROM alpine:latest

COPY . /goaccess
WORKDIR /goaccess

ARG build_deps="build-base ncurses-dev autoconf automake git gettext-dev"
ARG runtime_deps="tini ncurses libintl gettext openssl-dev gzip"

RUN apk update && \
    apk add -u $runtime_deps $build_deps && \
    autoreconf -fiv && \
    ./configure --enable-utf8 --enable-debug --enable-geoip=legacy --with-openssl && \
    make && \
    make install && \
    apk del $build_deps && \
    rm -rf /var/cache/apk/* /tmp/goaccess/* /goaccess

VOLUME /srv/data
VOLUME /srv/logs
VOLUME /srv/report
VOLUME /srv/keys
EXPOSE 7890

ENTRYPOINT ["/sbin/tini", "--"]
CMD sh -c 'zcat access.log.*.gz | goaccess -f /srv/logs/access.log --config-file=/srv/data/goaccess.conf'

My docker build output:

checking for GeoIP_new in -lGeoIP... no
configure: error:
    *** Missing development files for the GeoIP library

The command '/bin/sh -c apk update &&     apk add -u $runtime_deps $build_deps &&     autoreconf -fiv &&     ./configure --enable-utf8 --enable-debug --enable-geoip=legacy --with-openssl &&     make &&     make install &&     apk del $build_deps &&     rm -rf /var/cache/apk/* /tmp/goaccess/* /goaccess' returned a non-zero code: 1

So i tried to add RUN apk add --no-cache libgeoip-dev without any effect, this tells me this.

ERROR: unsatisfiable constraints:
  libgeoip-dev (missing):
    required by: world[libgeoip-dev]

Okay that looks like it is missing repository, so I've added coresponding repositories to Dockerfile (This is for mmdb, i know, i cannot find the right repository for geoIP yet, that might be the whole problem)

RUN echo "http://ppa.launchpad.net/certbot/certbot/ubuntuxenial/main" >> /etc/apk/repositories
RUN echo "http://ppa.launchpad.net/maxmind/ppa/ubuntuxenial/main" >> /etc/apk/repositories
RUN apk update
RUN apk add --no-cache libgeoip-dev

Still without luck, output this time:

Step 8/17 : RUN apk update
 ---> Running in 23dbd7aed66f
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
fetch http://ppa.launchpad.net/certbot/certbot/ubuntuxenial/main/x86_64/APKINDEX.tar.gz
fetch http://ppa.launchpad.net/maxmind/ppa/ubuntuxenial/main/x86_64/APKINDEX.tar.gz
ERROR: http://ppa.launchpad.net/certbot/certbot/ubuntuxenial/main: No such file or directory
WARNING: Ignoring APKINDEX.895d41e7.tar.gz: No such file or directory
ERROR: http://ppa.launchpad.net/maxmind/ppa/ubuntuxenial/main: No such file or directory
WARNING: Ignoring APKINDEX.5666c361.tar.gz: No such file or directory
v3.7.0-151-gf417903f18 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-150-g3ea1ba4100 [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
2 errors; 9050 distinct packages available

This may also be docker related issue but Im just wondering if anyone came across something similiar.

Thanks, JK

allinurl commented 6 years ago

I believe libgeoip-dev it's used for the legacy GeoIP db. The docker file is using --enable-geoip=mmdb, so you try updating the Dockerfile and use --enable-geoip=legacy or install libmaxminddb-devel.

Let me know if that solves the issue. Thanks.

josefkorbel commented 6 years ago

Unfortunately i cannot install neither libgeoip-dev or libmaxminddb-devel from the basic alpina image.

fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.7/community/x86_64/APKINDEX.tar.gz
v3.7.0-151-gf417903f18 [http://dl-cdn.alpinelinux.org/alpine/v3.7/main]
v3.7.0-152-g07f94e9656 [http://dl-cdn.alpinelinux.org/alpine/v3.7/community]
OK: 9050 distinct packages available
ERROR: unsatisfiable constraints:
  libmaxminddb-devel (missing):
    required by: world[libmaxminddb-devel]
josefkorbel commented 6 years ago

Fix would be to use complete linux image, but I dont want the image to be unnecessarily big.

allinurl commented 6 years ago

Have you tried libmaxminddb instead of libmaxminddb-devel? It seems like that's the package name under Alpine.

josefkorbel commented 6 years ago

Hello Gerardo! Thanks for your reply, I've tried that just now, without any luck unfortunately.

configure: error: *** Missing development files for libmaxminddb library.

josefkorbel commented 6 years ago

But it looks like it was being installed.

(45/52) Installing libmaxminddb (1.3.1-r0)

allinurl commented 6 years ago

Please try this, it should work:

# docker stop goaccess
# docker rm goaccess

then make sure the following lines in your Dockerfile look like:

# vim Dockerfile
ARG build_deps="build-base ncurses-dev autoconf automake git gettext-dev geoip-dev"
ARG runtime_deps="tini ncurses libintl gettext openssl-dev geoip"
RUN apk update && \
         apk add -u $runtime_deps $build_deps && \
         autoreconf -fiv && \
        ./configure --enable-utf8 --with-openssl --enable-geoip=legacy --enable-debug && \
...
# docker build . -t allinurl/goaccess
# cd /srv/goaccess/data/
# wget -N http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
# gunzip GeoLiteCity.dat.gz
# vim goaccess.conf
> geoip-database /srv/data/GeoLiteCity.dat
# docker run --restart=always -d -p 7890:7890 -v "/srv/goaccess/data:/srv/data" -v "/srv/goaccess/html:/srv/report" -v "/var/log/nginx:/srv/logs" --name=goaccess allinurl/goaccess
josefkorbel commented 6 years ago

That works ! Thank you very much Gerardo.

allinurl commented 6 years ago

Closing this. Feel free to reopen it if needed.