# This dockerfile is for development purpose. Please do not distribute this file or
# distribute the image from this file for commercial purpose.

FROM ubuntu:14.04
RUN apt-get update && \
    apt-get upgrade -y && \
    apt-get install -y  software-properties-common && \
    add-apt-repository ppa:webupd8team/java -y && \
    apt-get update && \
    echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \
    apt-get install -y oracle-java8-installer && \
    apt-get clean
RUN apt-get install -y vim
RUN apt-get install -y curl
COPY . /appdynamics/machineagent/

# Eventually we would like to be able to install socat and bind the tcp socket on certain port
# to the unix socket. However, this is currently not working, and we have to enable it manually.
# Start container with the following command:
# sudo docker run -v /var/run/docker.sock:/var/run/docker.sock -it [IMAGE_NAME] "bin/bash"
# Image "ninayang01/machineagentubuntu:latest" is available on docker hub as a starting point if needed,
# and the machine agent is in the /appdynamics/dockermachineagent directory.
#
# After starting with container interactively,
# 1. Update /appdynamics/machineagent/conf/controller-info.xml
# 2. Run the following commands:
#    a. apt-get install -y socat
#    b. socat TCP-LISTEN:2375,reuseaddr,fork UNIX-CLIENT:/var/run/docker.sock &
#    c. cd /appdynamics/machineagent/
#    d. java -Dappdynamics.docker.enabled=true -jar machineagent.jar
