diff --git a/Dockerfile b/Dockerfile index 4b147f5..37bad1d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,20 @@ WORKDIR /entrypoint RUN ["go", "build", "."] +FROM debian:bullseye-slim as etc-locale-gen + +RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y locales; apt-get clean; rm -vrf /var/lib/apt/lists/*"] + +COPY icingaweb2 /usr/share/icingaweb2 +COPY icinga-L10n /usr/share/icinga-L10n +COPY uncomment-locales.pl / + +RUN ["/uncomment-locales.pl", "/etc/locale.gen"] + + FROM debian:bullseye-slim -RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y apache2 ca-certificates libapache2-mod-php7.4 libldap-common locales-all php-{imagick,redis} php7.4-{bcmath,bz2,common,curl,dba,enchant,gd,gmp,imap,interbase,intl,json,ldap,mbstring,mysql,odbc,opcache,pgsql,pspell,readline,snmp,soap,sqlite3,sybase,tidy,xml,xmlrpc,xsl,zip}; apt-get clean; rm -vrf /var/lib/apt/lists/*"] +RUN ["bash", "-exo", "pipefail", "-c", "export DEBIAN_FRONTEND=noninteractive; apt-get update; apt-get install --no-install-{recommends,suggests} -y apache2 ca-certificates libapache2-mod-php7.4 libldap-common locales php-{imagick,redis} php7.4-{bcmath,bz2,common,curl,dba,enchant,gd,gmp,imap,interbase,intl,json,ldap,mbstring,mysql,odbc,opcache,pgsql,pspell,readline,snmp,soap,sqlite3,sybase,tidy,xml,xmlrpc,xsl,zip}; apt-get clean; rm -vrf /var/lib/apt/lists/*"] COPY --from=entrypoint /entrypoint/entrypoint /entrypoint COPY entrypoint/db-init /entrypoint-db-init @@ -38,6 +49,9 @@ COPY icinga-php /usr/share/icinga-php COPY icinga-L10n /usr/share/icinga-L10n COPY php.ini /etc/php/7.4/cli/conf.d/99-docker.ini +COPY --from=etc-locale-gen /etc/locale.gen /etc/ +RUN ["locale-gen", "-j", "4"] + RUN ["ln", "-vs", "/usr/share/icingaweb2/packages/files/apache/icingaweb2.conf", "/etc/apache2/conf-enabled/"] RUN ["ln", "-vs", "/usr/share/icingaweb2/bin/icingacli", "/usr/local/bin/"] diff --git a/build.bash b/build.bash index c61bbfa..3588a48 100755 --- a/build.bash +++ b/build.bash @@ -33,6 +33,6 @@ cd /iw2cp /bldctx/composer.bash patch -d icingaweb2 -p0 < /bldctx/icingaweb2.patch -cp -r /entrypoint /bldctx/php.ini . +cp -r /entrypoint /bldctx/{php.ini,uncomment-locales.pl} . docker build -f /bldctx/Dockerfile -t icinga/icingaweb2 . EOF diff --git a/uncomment-locales.pl b/uncomment-locales.pl new file mode 100755 index 0000000..77347af --- /dev/null +++ b/uncomment-locales.pl @@ -0,0 +1,26 @@ +#!/usr/bin/perl -i + +my %uniqLocs = (); + +for my $subDir ('icinga-L10n', 'icingaweb2/modules/*/application') { + for my $lcDir (glob "/usr/share/$subDir/locale/*_*") { + if ($lcDir =~ /(\w+)$/) { + $uniqLocs{$1} = 1 + } + } +} + +my @locs = keys %uniqLocs; + +while (<>) { + if (/\bUTF-8\b/) { + for my $loc (@locs) { + if (/\b$loc\b/) { + s/^# *//; + last + } + } + } +} continue { + print or die $! +}