From 14cfaffbbdd50d2b1f6b041c2a74636a151a92c3 Mon Sep 17 00:00:00 2001
From: Informatica Cloud Lab <iclab@iclab.localdomain>
Date: Tue, 15 Aug 2017 09:36:57 -0700
Subject: [PATCH] update final working dockerfile and README.md

---
 Dockerfile                            | 61 +++++++++++++++------------
 README.md                             | 25 +++++------
 post-build-files/.gitkeep             |  0
 post-build-files/entrypoint.sh        | 20 ---------
 post-build-files/installer.properties |  3 --
 post-build-files/register-agent.sh    | 25 -----------
 post-build-files/run_install.sh       |  4 --
 7 files changed, 47 insertions(+), 91 deletions(-)
 delete mode 100644 post-build-files/.gitkeep
 delete mode 100755 post-build-files/entrypoint.sh
 delete mode 100755 post-build-files/installer.properties
 delete mode 100755 post-build-files/register-agent.sh
 delete mode 100755 post-build-files/run_install.sh

diff --git a/Dockerfile b/Dockerfile
index 33ba7be..99f2c89 100755
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,37 +1,44 @@
-FROM debian:8.1
-#first time you need to provide host name, name, and agent required creds
-##example run command: docker run -d -h <hostname> --name <agent_name> <image_name:image_tag> <agent_username> <agent_password>
-##ie., docker run -d -h jw2 --name jw2 test:3 jweber@000qio.org jetssuck
-##ie., docker run -d -h jw1 --name jw1 test:3 jweber@informatica.com bp3luser
-#subsequent runs can be done via docker start <container_id>
+FROM ubuntu:16.04
+# Read the README.md for more details on the image configuration
 
 MAINTAINER Jaroslav Brazda <jaroslav.brazda@gmail.com>
 
-# Upgrading system for wget and unzip tools
-RUN apt-get update && \
-	apt-get -y install wget && \
-	apt-get -y install unzip
+#you can override the target installation directory
+ARG INSTALL_DIR=/informatica/agent
+# Defines whre to download agent from (this might be different for your org)
+ARG AGENT_URL=https://app2.informaticacloud.com/saas/download/linux64/installer/agent64_install.bin
+# we need to run docker image under a different user than root because the Secure agent process engine can't be run under root account
 
-COPY ./post-build-files /informatica/agent/
 
-#setup
-RUN mkdir "/informatica/agent/installer" && \ 
-	wget --no-check-certificate "https://app2.informaticacloud.com/saas/download/linux64/installer/agent64_install.bin" -O /informatica/agent/installer/agent64_install.bin && \
-	chmod +x /informatica/agent/entrypoint.sh && \
-    chmod +x /informatica/agent/register-agent.sh && \
-	chmod +x /informatica/agent/installer/agent64_install.bin
+# install system tools
+RUN apt-get update && \
+	apt-get -y install curl \
+	less \
+	locales \
+	locales-all \
+	sudo \
+	unzip
+
+# Set the locale
+RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
+    locale-gen
+ENV LANG en_US.UTF-8  
+ENV LANGUAGE en_US:en  
+ENV LC_ALL en_US.UTF-8    
+
+RUN useradd --create-home -ms /bin/bash -U agent
+USER agent
+
+#download and prepare Installer
+RUN curl -o /tmp/agent64_install.bin $AGENT_URL && \
+	chmod +x /tmp/agent64_install.bin
 
 #install	
-RUN chmod +x /informatica/agent/run_install.sh &&\
-    /informatica/agent/run_install.sh &&\
-    rm /informatica/agent/infaagent/main/tools/unzip/unzip &&\
-    ln -s /usr/bin/unzip /informatica/agent/infaagent/main/tools/unzip/unzip
-
-#post install	
-RUN update-alternatives --install /usr/bin/java java /informatica/agent/infaagent/jre/bin/java 100 
-	#unzip -o /informatica/work/agent_jars.zip -d /informatica/agent/infaagent
+RUN ( /tmp/agent64_install.bin -i silent || true )
 
 #cleanup	
-RUN rm /informatica/agent/installer/agent64_install.bin
+RUN rm -rf /tmp/agent64_install.bin
+
+WORKDIR /home/agent/infaagent/apps/agentcore
 
-ENTRYPOINT ["/informatica/agent/entrypoint.sh", "/informatica/agent/infaagent"]
+CMD [ "./agent_start.sh" ]
\ No newline at end of file
diff --git a/README.md b/README.md
index 9de4531..06d784e 100755
--- a/README.md
+++ b/README.md
@@ -1,20 +1,21 @@
 # Run Informatica Agent in Docker Container
 
 ## Description
-This package contains example docker file and supporting scripts to run Informatica CLoud Secure Agent on DOcker Container
+This package contains example docker file and supporting scripts to run Informatica CLoud Secure Agent on a Docker Container
 
 ## Use
 
-1. Make sure you have docker installed
-2. Clone this repo  `git clone`
-3. Update the `Dockerfile`  if necessary (Location of the SA agent installer maight be different ofr your Informatica CLoud  org)
-4. run `run -d -h <hostname> --name <agent_name> <image_name:image_tag> <agent_username> <agent_password>`
-    example ""
+1. Make sure you have docker installed gor to (https://docs.docker.com/engine/installation/)
+2. Clone this repo  `git clone `
+3. Update the `Dockerfile`  if necessary (Location of the SA agent installer maight be different ofr your Informatica CLoud org) You can override the default location by specifying `--build-arg <varname>=<value>` in nextr step
+4. Run `docker build -t ic-secure-agent:1.0 .`
+5. run `run -d -h <hostname> --name <agent_name> <image_name:image_tag>`
+    +  `docker run -d -h agent1 --name agent1 ic-secure-agent:1.0`
+6. We need to configure the agent to connect it to your Informatica Cloud Org When you running agent for the first time, run followinng command in the host machine to connect to running agent
+    `docker exec -it ic-agent1 bash`
+7. Then run following command to configure agent `./consoleAgentManager.sh configure '<sername>' '<password>'`
+8. you can monitor agent running by calling `docker exec -it ic-agent1 less agentCore.log`
+
+
 
 
-This docker file is based on Jeremy Weber's original used internally at Informatica
-first time you need to provide host name, name, and agent required creds
-example run command: `docker run -d -h <hostname> --name <agent_name> <image_name:image_tag> <agent_username> <agent_password>`
--  `docker run -d -h agent1 --name agent1 test:3 jbrazda@informatica.org bp3luser`
--  `docker run -d -h agent2 --name agent2 test:3 jweber@informatica.com bp3luser`
-subsequent runs can be done via docker start <container_id>
diff --git a/post-build-files/.gitkeep b/post-build-files/.gitkeep
deleted file mode 100644
index e69de29..0000000
diff --git a/post-build-files/entrypoint.sh b/post-build-files/entrypoint.sh
deleted file mode 100755
index b4f53ac..0000000
--- a/post-build-files/entrypoint.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-AGENT_HOME=$1
-USERNAME=$2
-PASSWORD=$3
-
-_term() { 
-  printf "%s\n" "Caught SIGTERM signal, stopping agent!" 
-  $AGENT_HOME/main/agentcore/consoleAgentManager.sh shutdown
-}
-
-trap _term SIGINT SIGTERM
-
-if [ "$USERNAME" == "--help" ]
-then
-    echo 'docker run -d IMAGE[:TAG] <ics-username> <ics-password>'
-else
-	nohup /informatica/agent/register-agent.sh $AGENT_HOME $USERNAME $PASSWORD > /informatica/agent/register.nohup &
-	$AGENT_HOME/agent_start.sh & wait $!
-fi
\ No newline at end of file
diff --git a/post-build-files/installer.properties b/post-build-files/installer.properties
deleted file mode 100755
index cfdd005..0000000
--- a/post-build-files/installer.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-#Choose Install Folder
-#---------------------
-USER_INSTALL_DIR=/informatica/agent/infaagent
\ No newline at end of file
diff --git a/post-build-files/register-agent.sh b/post-build-files/register-agent.sh
deleted file mode 100755
index 626d0aa..0000000
--- a/post-build-files/register-agent.sh
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/bash
-
-AGENT_HOME=$1
-USERNAME=$2
-PASSWORD=$3
-COUNTER=1
-
-echo 'Waiting for agent core to start'
-sleep 10
-CONFIGURED=`$AGENT_HOME/main/agentcore/consoleAgentManager.sh isConfigured`
-
-while [[ -z $CONFIGURED &&  $COUNTER -lt 31 ]]
-do
-    sleep 1
-    CONFIGURED=`$AGENT_HOME/main/agentcore/consoleAgentManager.sh isConfigured`
-    COUNTER=$[$COUNTER +1]
-done
-
-if [ -z $CONFIGURED ]
-then
-   echo 'Agent core not started!'
-elif [ "$CONFIGURED" != "true" ]
-then
-   $AGENT_HOME/main/agentcore/consoleAgentManager.sh configure $USERNAME $PASSWORD
-fi
\ No newline at end of file
diff --git a/post-build-files/run_install.sh b/post-build-files/run_install.sh
deleted file mode 100755
index 7c68d7c..0000000
--- a/post-build-files/run_install.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-export LAX_DEBUG=true
-/informatica/agent/installer/agent64_install.bin -i silent -f /informatica/agent/installer.properties
-echo Test Completed
-echo $?
-- 
GitLab