<commit_before>FROM ubuntu:16.04

MAINTAINER <NAME> (<EMAIL>) Universitat Politecnica de Valencia

RUN apt-get update && apt-get -y install npm less curl maven openjdk-8-jdk openjdk-8-jre python-requests 
RUN npm install fs-extra path yargs jsrender request cheerio html-validator node-minify babel-core html-minifier babel-preset-es2015
RUN ln -s /usr/bin/nodejs /usr/bin/node
#  Open http(s) ports for the tomcat server
EXPOSE 8443
EXPOSE 8080

ARG tomcat_group=tomcat
ARG tomcat_user=tomcat
ARG tomcat_root=/opt/tomcat
ARG app_base_path=/eubrabigsea
ARG app_path=${app_base_path}/rfp-web

# root variables
#ENV TOMCAT_USER ${tomcat_user}
#ENV TOMCAT_USER_PASSW default
ENV TOMCAT_ADMIN admin
ENV TOMCAT_ADMIN_PASSW password

# Create user and adjust permissions for tomcat
RUN echo ${tomcat_root}
RUN mkdir ${tomcat_root}
RUN groupadd ${tomcat_group}
RUN useradd -s /bin/false -g ${tomcat_group} -d ${tomcat_root} ${tomcat_user}
RUN chown -R ${tomcat_user}:${tomcat_group} ${tomcat_root}
#RUN echo ${TOMCAT_USER_PASSW} | passwd ${TOMCAT_USER} --stdin

# Install custom version of Tomcat (the one from the repo has bugs)
RUN curl -o /tmp/apache-tomcat-8.0.44.tar.gz http://apache.uvigo.es/tomcat/tomcat-8/v8.0.44/bin/apache-tomcat-8.0.44.tar.gz
RUN tar xzvf /tmp/apache-tomcat-8*tar.gz -C ${tomcat_root} --strip-components=1
COPY ./tomcat-users_template.xml ${tomcat_root}/conf/tomcat-users.xml

RUN chmod -R g+r ${tomcat_root}/conf
RUN chmod -R +x ${tomcat_root}/bin/
RUN chmod g+x ${tomcat_root}/conf
RUN chown -R ${tomcat_user} ${tomcat_root}/conf/ ${tomcat_root}/webapps/ ${tomcat_root}/work/ ${tomcat_root}/temp/ ${tomcat_root}/logs/

# Create the app folder and giver full permission to the tomcat user
RUN mkdir -p ${app_path}
COPY ./mesos-dns-discover.sh ${app_base_path}
RUN chmod +x ${app_base_path}/mesos-dns-discover.sh
ADD ./ ${app_path}/
#COPY ./regions.json ${app_base_path}
RUN chown -R ${tomcat_user} ${app_base_path}

# Once we have everything set, time to switch to a limited user
USER ${tomcat_user}

#  Different environment variables used to control the environment
ENV USER ${tomcat_user}
ENV APP_BASE_PATH ${app_base_path}
ENV APP_PATH ${app_path}
ENV TOMCAT_ROOT ${tomcat_root}
ENV PFX default
ENV PSQL_USER postgres
ENV PSQL_PASSW default
ENV PSQL_PORT 5432
ENV PSQL_HOST localhost
ENV MESOS_DNS_IP_PORT http://127.0.0.1:8123
ENV MESOS_DNS_RFP_DB_ID _rfp-db-rfp._tcp.marathon.mesos
ENV AUTH_SERVICE_URL https://eubrabigsea.dei.uc.pt/engine/api/verify_token
ENV AUTH_SERVICE_INVALID_TOKEN_RESP "invalid token"
ENV MESOS_DNS_AUTH_SERVICE_ID _rfp-db-rfp._tcp.marathon.mesos
#ENV REGIONS_PATH ${app_base_path}/regions.json
ENV CMD_KEEP_ALIVE tail -f /dev/null
ENV REGIONS_URL ftp://ftpgrycap.i3m.upv.es/public/eubrabigsea/data/regions.json
ENV REGIONS_LOCAL_PATH ${app_path}/regions.json

# Prepare and deploy app 
RUN rm -rf ${TOMCAT_ROOT}/webapps/ROOT.war ${TOMCAT_ROOT}/webapps/ROOT || true
#RUN cat ${APP_PATH}/pom.xml | sed "s|<tomcatUser>[^ ]*</tomcatUser>|<tomcatUser>${TOMCAT_USER}</tomcatUser>|" > ${APP_PATH}/pom.xml.tmp
#RUN cat ${APP_PATH}/pom.xml.tmp | sed "s|<tomcatUserPassw>[^ ]*</tomcatUserPassw>|<tomcatUserPassw>${TOMCAT_USER_PASSW}</tomcatUserPassw>|" > ${APP_PATH}/pom.xml
RUN cat ${APP_PATH}/pom.xml | sed "s|<outputDirectory>[^ ]*</outputDirectory>|<outputDirectory>${TOMCAT_ROOT}/webapps/</outputDirectory>|" > ${APP_PATH}/pom.xml.tmp &&\
	mv ${APP_PATH}/pom.xml.tmp ${APP_PATH}/pom.xml
RUN node ${APP_PATH}/src/main/webapp/build.js -p "${APP_PATH}/src/main/webapp/" -v "2.0beta" -w "/webservice"
RUN mvn -e -f ${APP_PATH}/pom.xml -P debug clean package
#RUN chown -R tomcat ${TOMCAT_ROOT}/webapps/ ${TOMCAT_ROOT}/work/ ${TOMCAT_ROOT}/temp/ ${TOMCAT_ROOT}/logs/

ENTRYPOINT python2 ${APP_PATH}/mesos-dns-discover.py --mesosdns "${MESOS_DNS_IP_PORT}" \
    --regions_template_url "${REGIONS_URL}" \
    --mesosdns_db "${MESOS_DNS_RFP_DB_ID}" \
    --vars /eubrabigsea/vars.rc \
    --regions_local_path "${REGIONS_LOCAL_PATH}" &&\
  export $(cat /eubrabigsea/vars.rc) &&\
  ${TOMCAT_ROOT}/bin/startup.sh &&\
  eval ${CMD_KEEP_ALIVE}
<commit_msg>added log4j logging changed to release<commit_after>FROM ubuntu:16.04

MAINTAINER <NAME> (<EMAIL>) Universitat Politecnica de Valencia

RUN apt-get update && apt-get -y install npm less curl maven openjdk-8-jdk openjdk-8-jre python-requests 
RUN npm install fs-extra path yargs jsrender request cheerio html-validator node-minify babel-core html-minifier babel-preset-es2015
RUN ln -s /usr/bin/nodejs /usr/bin/node
#  Open http(s) ports for the tomcat server
EXPOSE 8443
EXPOSE 8080

ARG tomcat_group=tomcat
ARG tomcat_user=tomcat
ARG tomcat_root=/opt/tomcat
ARG app_base_path=/eubrabigsea
ARG app_path=${app_base_path}/rfp-web

# root variables
#ENV TOMCAT_USER ${tomcat_user}
#ENV TOMCAT_USER_PASSW default
ENV TOMCAT_ADMIN admin
ENV TOMCAT_ADMIN_PASSW password

# Create user and adjust permissions for tomcat
RUN echo ${tomcat_root}
RUN mkdir ${tomcat_root}
RUN groupadd ${tomcat_group}
RUN useradd -s /bin/false -g ${tomcat_group} -d ${tomcat_root} ${tomcat_user}
RUN chown -R ${tomcat_user}:${tomcat_group} ${tomcat_root}
#RUN echo ${TOMCAT_USER_PASSW} | passwd ${TOMCAT_USER} --stdin

# Install custom version of Tomcat (the one from the repo has bugs)
RUN curl -o /tmp/apache-tomcat-8.0.44.tar.gz http://apache.uvigo.es/tomcat/tomcat-8/v8.0.44/bin/apache-tomcat-8.0.44.tar.gz
RUN tar xzvf /tmp/apache-tomcat-8*tar.gz -C ${tomcat_root} --strip-components=1
COPY ./tomcat-users_template.xml ${tomcat_root}/conf/tomcat-users.xml

RUN chmod -R g+r ${tomcat_root}/conf
RUN chmod -R +x ${tomcat_root}/bin/
RUN chmod g+x ${tomcat_root}/conf
RUN chown -R ${tomcat_user} ${tomcat_root}/conf/ ${tomcat_root}/webapps/ ${tomcat_root}/work/ ${tomcat_root}/temp/ ${tomcat_root}/logs/

# Create the app folder and giver full permission to the tomcat user
RUN mkdir -p ${app_path}
COPY ./mesos-dns-discover.sh ${app_base_path}
RUN chmod +x ${app_base_path}/mesos-dns-discover.sh
ADD ./ ${app_path}/
#COPY ./regions.json ${app_base_path}
RUN chown -R ${tomcat_user} ${app_base_path}

# Once we have everything set, time to switch to a limited user
USER ${tomcat_user}

#  Different environment variables used to control the environment
ENV USER ${tomcat_user}
ENV APP_BASE_PATH ${app_base_path}
ENV APP_PATH ${app_path}
ENV TOMCAT_ROOT ${tomcat_root}
ENV PFX default
ENV PSQL_USER postgres
ENV PSQL_PASSW default
ENV PSQL_PORT 5432
ENV PSQL_HOST localhost
ENV MESOS_DNS_IP_PORT http://127.0.0.1:8123
ENV MESOS_DNS_RFP_DB_ID _rfp-db-rfp._tcp.marathon.mesos
ENV AUTH_SERVICE_URL https://eubrabigsea.dei.uc.pt/engine/api/verify_token
ENV AUTH_SERVICE_INVALID_TOKEN_RESP "invalid token"
ENV MESOS_DNS_AUTH_SERVICE_ID _rfp-db-rfp._tcp.marathon.mesos
#ENV REGIONS_PATH ${app_base_path}/regions.json
ENV CMD_KEEP_ALIVE tail -f /dev/null
ENV REGIONS_URL ftp://ftpgrycap.i3m.upv.es/public/eubrabigsea/data/regions.json
ENV REGIONS_LOCAL_PATH ${app_path}/regions.json

# Prepare and deploy app 
RUN rm -rf ${TOMCAT_ROOT}/webapps/ROOT.war ${TOMCAT_ROOT}/webapps/ROOT || true
#RUN cat ${APP_PATH}/pom.xml | sed "s|<tomcatUser>[^ ]*</tomcatUser>|<tomcatUser>${TOMCAT_USER}</tomcatUser>|" > ${APP_PATH}/pom.xml.tmp
#RUN cat ${APP_PATH}/pom.xml.tmp | sed "s|<tomcatUserPassw>[^ ]*</tomcatUserPassw>|<tomcatUserPassw>${TOMCAT_USER_PASSW}</tomcatUserPassw>|" > ${APP_PATH}/pom.xml
RUN cat ${APP_PATH}/pom.xml | sed "s|<outputDirectory>[^ ]*</outputDirectory>|<outputDirectory>${TOMCAT_ROOT}/webapps/</outputDirectory>|" > ${APP_PATH}/pom.xml.tmp &&\
	mv ${APP_PATH}/pom.xml.tmp ${APP_PATH}/pom.xml
RUN node ${APP_PATH}/src/main/webapp/build.js -p "${APP_PATH}/src/main/webapp/" -v "2.0beta" -w "/webservice"
RUN mvn -e -f ${APP_PATH}/pom.xml -P release clean package
#RUN chown -R tomcat ${TOMCAT_ROOT}/webapps/ ${TOMCAT_ROOT}/work/ ${TOMCAT_ROOT}/temp/ ${TOMCAT_ROOT}/logs/

ENTRYPOINT python2 ${APP_PATH}/mesos-dns-discover.py --mesosdns "${MESOS_DNS_IP_PORT}" \
    --regions_template_url "${REGIONS_URL}" \
    --mesosdns_db "${MESOS_DNS_RFP_DB_ID}" \
    --vars /eubrabigsea/vars.rc \
    --regions_local_path "${REGIONS_LOCAL_PATH}" &&\
  export $(cat /eubrabigsea/vars.rc) &&\
  ${TOMCAT_ROOT}/bin/startup.sh &&\
  eval ${CMD_KEEP_ALIVE}

{'fraction_non_alphanumeric': 0.1410303251735477, 'fraction_numerical': 0.012544148094020217, 'mean_word_length': 5.1467065868263475, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 37, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 22}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5669610', 'n_tokens_mistral': 3332, 'n_tokens_neox': 3217, 'n_words': 711}