Building the Docker Image for an API Gateway Instance
About this task
The API Gateway Docker image provides an API Gateway installation. Depending on the existing installation, the API Gateway Docker image provides a standard API Gateway or an advanced API Gateway instance. When running the image, the API Gateway is started. The API Gateway image is created on top of an Integration Server image.
To build a Docker image for an API Gateway instance
Procedure
Example
A sample shell script for creating an API Gateway Docker image looks as follows:
echo "is createDockerfile ======================================================="
./is_container.sh createDockerfile
status=$?
if [ $status -ne 0 ]
then
echo "Failed! status: $status"
exit $status
fi
echo "is build =================================================================="
./is_container.sh build
status=$?
if [ $status -ne 0 ]
then
echo "Failed! status: $status"
exit $status
fi
echo "apigw createDockerfile =================================================="
./apigw_container.sh createDockerfile
status=$?
if [ $status -ne 0 ]
then
echo "Failed! status: $status"
exit $status
fi
echo "apigw build ============================================================="
./apigw_container.sh build
status=$?
if [ $status -ne 0 ]
then
echo "Failed! status: $status"
exit $status
fi
docker images
. The following sample result shows the
base image
centos:7, the
Integration Server
image
is:micro, and the
API Gateway
image
is:apigw.
REPOSITORY TAG IMAGEID CREATED SIZE
is apigw af29373fc98a 15 hours ago 1.3GB
is micro 06e7c0de4807 15 hours ago 1.1GB
centos 7 36540f359ca3 12 days ago 193MB
The Docker images resulting from Docker files created using the createDockerFile command feature the following:
- Docker logging.
API Gateway Docker containers log to stdout and stderr. The API Gateway logs can be fetched with Docker logs.
- Docker health check.
API Gateway Docker containers perform health checks. You can use wget request against the API Gateway REST API to check the health status of API Gateway.
The following wget request shows a curl invocation sending a request against the HTTP port. If API Gateway exposes an HTTPS port, only the wget is created accordingly. The option --no-check-certificate is used to avoid any failure due to certificate problems.
HEALTHCHECK CMD curl --no-check-certificate http://localhost:5555/rest/apigateway/health
The wget checks the API Gateway availability by sending requests to the API Gateway REST health resource. If the wget is successful, API Gateway is considered healthy.
- Graceful shutdown.
Docker stop issues a SIGTERM to the running API Gateway.