Run an Image With an Immutable Configuration
This section describes how to add a basic route to your local IG configuration folder, copy it into a new Docker image, and run that Docker image.
Unlike the previous example, the Docker image is immutable. If you change your configuration locally, the Docker image is not changed.
Use this procedure to manage configuration within the Docker image. For example, use it when you want to deploy the same configuration multiple times.
Add the following route to your local IG configuration as
$HOME/.openig/config/routes/hello.json
:{ "name": "hello", "handler": { "type": "StaticResponseHandler", "config": { "status": 200, "reason": "OK", "headers": { "Content-Type": [ "text/plain" ] }, "entity": "Hello world!" } }, "condition": "${matches(request.uri.path, '^/hello')}" }
The configuration contains a static response handler to return a "Hello world!" statement when the URI of a request finishes with
/hello
.Add the following file to your local IG configuration as
$HOME/.openig/Dockerfile
, where$HOME/.openig
is the instance directory:FROM ig-image COPY config/routes/hello.json "$IG_INSTANCE_DIR"/config/routes/hello.json
The Dockerfile copies
hello.json
into the Docker image. The$IG_INSTANCE_DIR
environment variable is defined in the IG base image.Build the Docker image:
$
docker build . -t ig-custom
Sending build context to Docker daemon Step 1/2 : FROM ig-image Step 2/2 : COPY config/routes/hello.json "$IG_INSTANCE_DIR"/config/routes/hello.json Successfully tagged ig-custom:latest
Make sure that the Docker image is available:
$
docker image list
REPOSITORY TAG IMAGE ID ig-custom image_tag 51b...3b7 gcr.io/forgerock-io/ig image_tag 404...a2b
Run the Docker image on port
8080
:$
docker run -p 8080:8080 ig-custom
Go to http://localhost:8080/hello. The "Hello world!" statement is displayed.