#
# Mediacentric sample localized docker image
#

FROM mediacentric
MAINTAINER Bertin

#  update with appropriate values
ENV AMQ_PORT_5672_TCP_ADDR '<CORE_HOST>'
ENV AMQ_PORT_5672_TCP_PORT '5672'

RUN useradd -m -s/bin/bash mediacentric
RUN echo "mediacentric:bertin!2010$" | chpasswd
RUN mkdir -p /opt/bertin/mediacentric/modules/ircstandalone
RUN mkdir /opt/bertin/mediacentric/conf
#
# config lang+timezone : replace <LOCALE> and <TIMEZONE> by actual values
#  example :
#   RUN sed -i '/de_AT.UTF-8/s/^#//' /etc/locale.gen
#   RUN locale-gen && update-locale LANG=de_AT.UTF-8
#   RUN echo Europe/Vienna | tee /etc/timezone
#
#
#RUN sed -i '/<LOCALE>/s/^#//' /etc/locale.gen
#RUN locale-gen && update-locale LANG=<LOCALE>
#RUN echo <TIMEZONE> | tee /etc/timezone
#RUN dpkg-reconfigure --frontend noninteractive tzdata
#
# config keyboard : replace <LANG> by actual value  (2-letters iso639-1 code)
#  example:
#   RUN sed -i '/XKBLAYOUT=/s/=.*$/="de"/' /etc/default/keyboard
#
RUN sed -i '/XKBLAYOUT=/s/=.*$/="<LANG>"/' /etc/default/keyboard
RUN sed -i '/XKBVARIANT=/s/=.*$/="nodeadkeys"/' /etc/default/keyboard

#
#  install mediacentric app
#   files mediacentric.properties and jpa.properties must have been previously updated with appropriate values for current site

COPY mediacentric/mediacentric.properties /opt/bertin/mediacentric/conf/
COPY mediacentric/jpa.properties /opt/bertin/mediacentric/conf/

# Upload of the ircstandalone application
# An archive must be present in the context folder ex: ircstandalone.tar.gz
#COPY /opt/bertin/mediacentric/modules/ircstandalone /opt/bertin/mediacentric/modules/ircstandalone
COPY ircstandalone.tar.gz /opt/bertin/mediacentric/modules/ircstandalone
RUN tar -zxf /opt/bertin/mediacentric/modules/ircstandalone/ircstandalone.tar.gz -C /opt/bertin/mediacentric/modules/ircstandalone/
RUN chown -R mediacentric: /opt/bertin/mediacentric
#
#
#  configure  openvpn
#   all VPN config files (client.conf, vpn keys, vpn login info) must be put in vpn subdir
#   adjust this section to match your VPN configuration
#
#RUN sed -i  's/#AUTOSTART="all"/AUTOSTART="all"/' /etc/default/openvpn
#COPY vpn/client.conf /etc/openvpn/
#RUN mkdir /etc/openvpn/keys
#COPY vpn/keys/ /etc/openvpn/keys/
# copy login config : defines the target output country
#COPY vpn/login.txt /etc/openvpn/login.txt
