aboutsummaryrefslogtreecommitdiff
path: root/awstats
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2020-01-17 23:38:19 +0000
committerMike Crute <mike@crute.us>2020-01-17 23:38:19 +0000
commit1dc023ddac12cb5c9f0bbac3ee14139a14c011f4 (patch)
treeac2c2422e8cddd1bcb9c63f0ab48d3e49fecf853 /awstats
parent2ae08e02c4fd12e561b9d292f371a87e81a9c472 (diff)
downloaddockerfiles-1dc023ddac12cb5c9f0bbac3ee14139a14c011f4.tar.bz2
dockerfiles-1dc023ddac12cb5c9f0bbac3ee14139a14c011f4.tar.xz
dockerfiles-1dc023ddac12cb5c9f0bbac3ee14139a14c011f4.zip
Add awstats
Diffstat (limited to 'awstats')
-rw-r--r--awstats/Dockerfile62
-rw-r--r--awstats/Makefile11
-rwxr-xr-xawstats/build.sh45
3 files changed, 118 insertions, 0 deletions
diff --git a/awstats/Dockerfile b/awstats/Dockerfile
new file mode 100644
index 0000000..32a0abd
--- /dev/null
+++ b/awstats/Dockerfile
@@ -0,0 +1,62 @@
1FROM alpine:edge
2LABEL maintainer="Mike Crute <mike@crute.us>"
3
4RUN set -euxo pipefail; \
5 # Install build dependencies
6 apk add --virtual .build-deps \
7 build-base \
8 git \
9 perl-app-cpanminus \
10 perl-dev \
11 wget \
12 ; \
13 apk add \
14 curl \
15 ; \
16 \
17 # Install awstats
18 git clone https://github.com/eldy/awstats.git /opt/awstats; \
19 cpanm -n Net::IP Net::DNS; \
20 mkdir /etc/awstats; \
21 \
22 # Install MaxMind GeoIP2 library
23 apk add perl-net-ssleay; \
24 cpanm -n \
25 Data::Validate::IP \
26 HTTP::Headers \
27 HTTP::Request \
28 HTTP::Response \
29 HTTP::Status \
30 JSON::MaybeXS \
31 List::SomeUtils \
32 LWP::Protocol::https \
33 LWP::UserAgent \
34 MaxMind::DB::Metadata \
35 MaxMind::DB::Reader \
36 Moo \
37 Moo::Role \
38 namespace::clean \
39 Params::Validate \
40 Path::Class \
41 Sub::Quote \
42 Test::Fatal \
43 Test::Number::Delta \
44 Throwable::Error \
45 Try::Tiny URI \
46 ; \
47 \
48 git clone https://github.com/maxmind/GeoIP2-perl.git /tmp/GeoIP2-perl; \
49 cd /tmp/GeoIP2-perl; \
50 perl Makefile.PL; \
51 make all install; \
52 mkdir /geoip; \
53 rm -rf /tmp/GeoIP2-perl; \
54 \
55 # Cleanup
56 apk del .build-deps; \
57 rm -rf /root/.cpanm/ /var/cache/apk/*;
58
59ADD main /serve
60ADD build.sh /build
61
62CMD [ "/serve" ]
diff --git a/awstats/Makefile b/awstats/Makefile
new file mode 100644
index 0000000..52b3117
--- /dev/null
+++ b/awstats/Makefile
@@ -0,0 +1,11 @@
1IMAGE=docker.crute.me/awstats:latest
2
3all:
4 docker pull alpine:edge
5 docker build -t $(IMAGE) .
6
7all-no-cache:
8 docker build --no-cache -t $(IMAGE) .
9
10publish:
11 docker push $(IMAGE)
diff --git a/awstats/build.sh b/awstats/build.sh
new file mode 100755
index 0000000..816ae3b
--- /dev/null
+++ b/awstats/build.sh
@@ -0,0 +1,45 @@
1#!/bin/sh
2
3set -euo pipefail
4
5# Validate environment variables
6[ -z "$SITE_DOMAIN" ] && { echo "SITE_DOMAIN env variable required"; exit 1; }
7[ -z "$SITE_ALIASES" ] && { echo "SITE_DOMAIN env variable required"; exit 1; }
8[ -z "$GEOIP_LICENSE_KEY" ] && { echo "GEOIP_LICENSE_KEY env variable required"; exit 1; }
9
10# Create the config template
11cat > /etc/awstats/awstats.${SITE_DOMAIN}.conf <<EOF
12LogFile="/input/${SITE_DOMAIN}.log"
13DirData="/output"
14LogFormat = "%virtualname %host - %other %time1 %methodurl %code %bytesd %refererquot %uaquot"
15SiteDomain="${SITE_DOMAIN}"
16HostAliases="${SITE_DOMAIN} ${SITE_ALIASES}"
17#ShowScreenSizeStats=1
18DefaultFile="index.html default.html"
19AllowFullYearView=3
20
21LoadPlugin="ipv6"
22# Should be enabled for build only
23LoadPlugin="geoip2 /geoip/GeoLite2-Country.mmdb"
24LoadPlugin="geoip2_city /geoip/GeoLite2-City.mmdb"
25
26#ExtraSectionName1="Redirected Hit"
27#ExtraSectionCodeFilter1="302"
28#ExtraSectionCondition1="URL,\/offsite"
29#ExtraSectionFirstColumnTitle1="Url"
30#ExtraSectionFirstColumnValues1="QUERY_STRING,url=([^&]+)"
31#ExtraSectionStatTypes1=HL
32#MaxNbOfExtra1=500
33#MinHitExtra1=1
34#ExtraSectionAddSumRow1=1
35EOF
36
37# Download and setup GeoIP Databases
38curl -s "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&suffix=tar.gz&license_key=${GEOIP_LICENSE_KEY}" | tar -xz -C /tmp
39curl -s "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&suffix=tar.gz&license_key=${GEOIP_LICENSE_KEY}" | tar -xz -C /tmp
40curl -s "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-Country&suffix=tar.gz&license_key=${GEOIP_LICENSE_KEY}" | tar -xz -C /tmp
41
42find /tmp -name '*.mmdb' -exec cp '{}' /geoip/ \;
43rm -rf /tmp/GeoLite2*
44
45/opt/awstats/wwwroot/cgi-bin/awstats.pl -config=${SITE_DOMAIN} -update -dir=/output