-[1. Prepare Org for Agent installation](#1-prepare-org-for-agent-installation)
-[1.1 Create User](#11-create-user)
-[2. Build a Docker Image](#2-build-a-docker-image)
-[3. Create and run a Container using your Docker Image](#3-create-and-run-a-container-using-your-docker-image)
-[. Connect and Initialize Agent](#-connect-and-initialize-agent)
<!-- /MarkdownTOC -->
# IICS Secure Agent Docker Image
## Description
This package contains example docker file and supporting scripts to run Informatica CLoud Secure Agent on a Docker Container.
Note that this is not an official or supported method how to run Informatica Secure Agent. It is useful though to leearning how to setup secure agent, create agent clusters or test integrations
Full containerization of Secure agent is non trivial as it requires custom configuration of agent if deem to use this method as your runtime
## 1. Prepare Org for Agent installation
### 1.1 Create User
1. Create IICS Native user account which will be used to connect secure agent and assign user to Admin Group
Follow naming convention that includes company domain and environment such as `sa_login@acme.com.dev`
2. Login to informatica Cloud to activate the user and retrive the Secure Agent Token on the Administration/Runtime Environments page

## 2. Build a Docker Image
1. Make sure you have docker installed, go to (https://docs.docker.com/engine/installation/)
4. Update the [Dockerfile](Dockerfile) if necessary (Location of the SA agent installer might be different for your Informatica CLoud org) You can override the default location by specifying `--build-arg <name>=<value>` in next step
5. Run command to build a docker Image
```shell
docker build -t ic-secure-agent:1.0 .
```
This project was forked from [jbrazda/ic-sagent-docker|https://github.com/jbrazda/ic-sagent-docker] with the intention of containerizing the IICS Secure Agent to run in Amazon Web Services. As of early January 2019, there is no official Docker image for IICS Secure Agent.
The Agent installation location will be dependend on specific Informatica Pod where your org is provisioned
To override the download file location use AGENT_URL argument. typical format for download url is
## 3. Create and run a Container using your Docker Image
* Docker
* An IICS user account and password for your organization that has appropriate rights to create and manage secure agents. This user will be used to login to the Informatica APIs to register the agent.
* Your Informatica POD and REGION, which can be inferred from https://${POD}.${REGION}.informaticacloud.com/. Defaults are set to POD=usw3 and REGION=dm-us, but can be overriden with Docker environment variables.
Execute following command `run -d -h <hostname> --name <agent_name> <image_name:image_tag>`
## The image
```shell
docker run -d-h agent1 --name ic-agent1 ic-secure-agent:1.0
```
The image is based on Ubuntu 18.04. It downloads and installs necessary dependencies, and then downloads the installer file from the correct Informatica URL based on your POD and REGION.
If you want to make certain ports available on your host like ability to call Secure agent processes or access oProcess engine Database from your host machine map the available exposed ports using th -p option of the docker run command
Stop the container using a `docker stop <container_name` i.e. docker stop
1. Clone this repository
2.`docker build . -t secure-agent` Optionally pass --build-arg parameters for POD and REGION if the defaults are not correct. POD and REGION are also set as environment variables, because containers will use these values for communicating with the Informatica API.
### . Connect and Initialize Agent
## Containers
We need to configure the agent to connect it to your Informatica Cloud Org When you running agent for the first time, run following command in the host machine to connect to running agent
The container executes a bash script called run_agent.sh upon start. It needs INFORMATICA_USER and INFORMATICA_PASSWORD environment variables set during runtime in order to communicate with the Informatica API to check and register the Secure Agent.
```shell
docker exec-it ic-agent1 bash
```
### Environment variables
Then run following command to configure agent Prefer using the new method of using username/token instead of password
### Volumes
Using Token
* Log files - tomcat log files are in the WORKDIR/logs directory. agentcore.log and infaagent.log are in the WORKDIR directory
* Infaagent.ini - in WORKDIR/conf/infaagent.ini. Contains the registration information for the secure agent
* data - Not sure what this does right now and whether this needs to be mounted as a volume.