FROM debian:latest

ENV DEBIAN_FRONTEND noninteractive

RUN apt update && apt -y install perl cpanminus libaspell-dev make libdbd-mysql-perl libdigest-perl-md5-perl libxml-simple-perl \
   libmodule-install-perl gcc libperl-dev default-libmysqlclient-dev libpng-dev build-essential libgd-dev mariadb-client imagemagick \
   libpng-dev libjpeg-dev libtiff-dev libapache2-mod-perl2 libapache2-mod-perl2-dev libapache2-request-perl libimage-magick-perl vim \
   apache2 apache2-utils 


RUN cpanm --notest --force \
   Algorithm::Permute \
   App::Cmd \
   Archive::Any \
   Archive::Tar \
   Archive::Zip \
   Business::OnlinePayment \
   Business::OnlinePayment::AuthorizeNet \
   Business::PayPal::API \
   Business::Tax::VAT::Validation \
   CHI \
   CSS::Minifier::XS \
   CSS::Packer \
   Cache::FastMmap \
   Capture::Tiny \
   Class::C3 \
   Class::InsideOut \
   Clone \
   Color::Calc \
   Compress::Zlib \
   Config::JSON \
   DBI \
   Data::ICal \
   DateTime \
   DateTime::Event::ICal \
   DateTime::Format::HTTP \
   DateTime::Format::Mail \
   DateTime::Format::Strptime \
   DBD::mysql@4.051 \
   Devel::StackTrace \
   Devel::StackTrace::WithLexicals \
   Digest::MD5 \
   Digest::SHA \
   Email::Valid \
   Exception::Class \
   Facebook::Graph \
   File::Path \
   Finance::Quote \
   GD \
   GD::Graph \
   Geo::Coder::Googlev3 \
   HTML::Form \
   HTML::Highlight \
   HTML::Packer \
   HTML::Parser \
   HTML::TagCloud \
   HTML::TagFilter \
   HTML::Template \
   HTML::Template::Expr \
   HTTP::BrowserDetect \
   HTTP::Exception \
   HTTP::Headers \
   HTTP::Request \
   IO::File::WithPath \
   IO::Interactive::Tiny \
   IO::Socket::SSL \
   IO::Zlib \
   Image::ExifTool \
   Imager \
   Imager::File::PNG \
   JSON \
   JSON::Any \
   JSON::PP \
   JavaScript::Minifier::XS \
   JavaScript::Packer \
   Kwargs \
   LWP \
   LWP::Protocol::https \
   List::MoreUtils \
   Locales \
   Log::Log4perl \
   MIME::Tools \
   Module::Find \
   Monkey::Patch \
   Moose \
   MooseX::NonMoose \
   MooseX::Storage \
   MooseX::Storage::Format::JSON \
   Net::CIDR::Lite \
   Net::DNS \
   Net::LDAP \
   Net::POP3 \
   Net::SMTP \
   Net::Twitter \
   Number::Format \
   POE \
   POE::Component::Client::HTTP \
   POE::Component::IKC::Server \
   POE::Component::IKC \
   Package::Stash \
   Params::Validate \
   Path::Class \
   PerlIO::eol \
   Plack \
   Plack::Middleware::Debug \
   Plack::Middleware::Status \
   Plack::Request \
   Plack::Response \
   Pod::Coverage \
   Readonly \
   Scope::Guard \
   Search::QueryParser \
   Storable \
   Template \
   Test::Class \
   Test::Deep \
   Test::Differences \
   Test::Exception \
   Test::Harness \
   Test::Log::Dispatch \
   Test::LongString \
   Test::MockObject \
   Test::MockTime \
   Test::More \
   Test::Tester \
   Test::WWW::Mechanize::PSGI \
   Text::Aspell \
   Text::Balanced \
   Text::CSV_XS \
   Tie::CPHash \
   Tie::IxHash \
   Time::HiRes \
   Try::Tiny \
   URI::Escape \
   UUID::Tiny \
   Weather::Com::Finder \
   XML::FeedPP \
   XML::FeedPP::MediaRSS \
   XML::Simple \
   common::sense \
   namespace::autoclean


#RUN cpanm --notest --force \
#   DBD::mysql@4.051


ADD lib                  /data/WebGUI/lib
ADD sbin                 /data/WebGUI/sbin
ADD share                /data/WebGUI/share
ADD www/extras           /data/WebGUI/www/extras
ADD www/maintenance.html /data/WebGUI/www/maintenance.html
ADD www/uploads          /data/WebGUI/uploads
ADD etc                  /data/WebGUI/etc

ADD distribution/webgui/entrypoint /entrypoint

ADD distribution/webgui/www.example.com.conf /etc/apache2/sites-available/000-default.conf
ADD distribution/webgui/webgui.conf /etc/apache2/mods-enabled/webgui.conf
ADD distribution/webgui/modperl.pl /etc/apache2/modperl.pl
RUN useradd --home=/data/WebGUI webgui; chown -R webgui: /data/WebGUI; chmod 755 /entrypoint; \
   # apt remove -y cpanminus make gcc libperl-dev ; rm -rf /root/.cpanm; \
   echo "ServerName localhost" >> /etc/apache2/apache2.conf; 

#USER webgui

WORKDIR /data/WebGUI

CMD [ "/entrypoint" ]
