Microgateway Docker Environment Variables
You can run a Microgateway docker container with environment variables. This has the advantage that a prepared Docker image can be executed with parameters.
The environment variables can be specified in an generic way based on the YAML configuration layout.
Example:
---
ports:
http: 7071
api_gateway:
url: “http://localhost:5555”
dir: "C:\\SoftwareAGapigw"
logging:
level: "ERROR"
---
The variables have the prefix mcgw and every path in the YAML file translates to the environment variables as mcgw_port_http, mcgw_api_gateway_url, mcgw_api_gateway_url,mcgw_logging_level, and so on.
To build and run the Docker image with environment settings, do the following:
1. Create a docker file with a configuration file.
./microgateway.sh createDockerFile --docker_file DockerFileEnv --docker_dir .
-c myconfig.yml
The myconfig.yml file looks as follows:
myconfig.yml:
ports:
http: 7077
api_gateway:
url: "myhost:port"
user: "myuser"
password : "mypwd"
policies:
user_auth: "internal"
2. Build Docker image.
docker build -t mg-env-image -f DockerFileEnv .
3. Build Docker image and display the logs.
docker run -d -p 7077:7077 --name mg-env-image-bad mg-env-image:latest
docker logs mg-env-image-bad
This displays that the accesses do not work since the API Gateway access properties are invalid and there is no deployed API.
4. Create environment setting file. Prepare a valid environment settings in a file. These are the effective API Gateway access as well as APIs to be pulled from the gateway (env.list):
mcgw_api_gateway_url=localhost:5555
mcgw_api_gateway_user=Administrator
mcgw_api_gateway_password=pwd
mcgw_downloads_apis=Employees,EmployeeService
5. Run docker image with environment settings.
docker run -d -p 7077:7077 --env-file env.list --name mg-env-image
mg-env-image:latest
docker logs mg-env-image
This displays that everything is fine.