FROM ubuntu:16.04
MAINTAINER <NAME>
LABEL version="1.0"

ENV DEBUG=$DEBUG
ENV GRAYLOG_LOGGING=$GRAYLOG_LOGGING
ENV GRAYLOG_HOST=$GRAYLOG_HOST
ENV GRAYLOG_PORT=$GRAYLOG_PORT
ENV SCHEDULER_MINUTES=$SCHEDULER_MINUTES
ENV REDMINE_BASE_URL=$REDMINE_BASE_URL
ENV REDMINE_USER=$REDMINE_USER
ENV REDMINE_PASSWORD=$<PASSWORD>
ENV INFLUXDB_DB_NAME=$INFLUXDB_DB_NAME
ENV INFLUXDB_USER=$INFLUXDB_USER
ENV INFLUXDB_PWD=$<PASSWORD>
ENV INFLUXDB_IP=$INFLUXDB_IP
ENV INFLUXDB_PORT=$INFLUXDB_PORT
ENV OSM_IP=$OSM_IP
ENV OSM_USER=$OSM_USER
ENV OSM_PWD=$<PASSWORD>
ENV OSM_KAFKA_PORT=$OSM_KAFKA_PORT
ENV POLICY_VM_CPU_UPPER_THRESHOLD=$POLICY_VM_CPU_UPPER_THRESHOLD
ENV POLICY_VM_CPU_LOWER_THRESHOLD=$POLICY_VM_CPU_LOWER_THRESHOLD
ENV POLICY_VM_MEMORY_UPPER_THRESHOLD=$POLICY_VM_MEMORY_UPPER_THRESHOLD
ENV POLICY_VM_MEMORY_LOWER_THRESHOLD=$POLICY_VM_MEMORY_LOWER_THRESHOLD
ENV POLICY_VM_DISK_UPPER_THRESHOLD=$POLICY_VM_DISK_UPPER_THRESHOLD
ENV POLICY_VM_DISK_LOWER_THRESHOLD=$POLICY_VM_DISK_LOWER_THRESHOLD
ENV POLICY_CONTAINER_MEMORY_UPPER_THRESHOLD=$POLICY_CONTAINER_MEMORY_UPPER_THRESHOLD
ENV POLICY_CONTAINER_MEMORY_LOWER_THRESHOLD=$POLICY_CONTAINER_MEMORY_LOWER_THRESHOLD
ENV EMAIL_NOTIFICATION_ENABLED=$EMAIL_NOTIFICATION_ENABLED
ENV NOTIFICATION_EMAIL_HOST=$NOTIFICATION_EMAIL_HOST
ENV NOTIFICATION_EMAIL_HOST_USER=$NOTIFICATION_EMAIL_HOST_USER
ENV NOTIFICATION_EMAIL_HOST_PASSWORD=$NOTIFICATION_EMAIL_HOST_PASSWORD
ENV NOTIFICATION_EMAIL_PORT=$NOTIFICATION_EMAIL_PORT

RUN pwd
RUN apt-get clean
RUN apt-get update

# Install required packages
RUN apt-get -y install build-essential apt-utils acl cron libxml2-dev python3-pip vim supervisor htop wget
RUN apt-get -y install python3-dev python3-lxml python3-cffi

# Copy source code
RUN mkdir /opt/svp-resource-recommendations
COPY svp-resource-recommendations /opt/svp-resource-recommendations
RUN ls -la /opt/svp-resource-recommendations
ADD svp-resource-recommendations/deployment/recommendations.conf /etc/supervisor/conf.d/recommendations.conf

RUN pip3 install -r /opt/svp-resource-recommendations/requirements.txt

# Configure Supervisor
RUN rm -rf /etc/supervisor/supervisord.conf && \
 cp /opt/svp-resource-recommendations/deployment/supervisor/supervisord.conf /etc/supervisor/supervisord.conf

EXPOSE 3333

# Run script
CMD bash /opt/svp-resource-recommendations/deployment/run.sh
