API Gateway
Copyright (c) 2019. California Community Colleges Technology Center
Licensed under the MIT license.
A copy of this license may be found at https://opensource.org/licenses/mit-license.php
This module contains resources for the API Gateway stack. The API Gateway can be viewed as a layer providing a single entry point (or gateway) into the growing array of CCCTC services.
Documentation
The document index contains links to the technical documentation for the design and implementation of API Gateway endpoints/routes.
Running
The API Gateway is essentially comprised of three modules (sometimes referred to as the Conductor stack or stack): service-conductor, service-router, and service-workers. The high-level instructions below explain how to either build and run the module Docker image locally or run the image locally that was built and stored remotely. These instructions appear in more detail in each module's README.
Docker
From within each of the modules' local repo, you will follow README's steps for each service, starting each in this order:
- service-conductor
- service-router
- service-workers
Building Local Docker images
For the each module you can either:
- Run the remote Docker registry image (doesn't require a local build), OR
- Build and run the local Docker image (for when you make changes locally)
Configuration
Private registry credentials
By using the remote registry, you can run the "latest" Docker image and not need to build it locally. (The "latest" image is created when code is pushed to the develop branch it is automatically tagged as being the "latest.")
To pull images from the remote private registry, you must first add your user / pass to the registry following these instructions: https://cccnext.jira.com/wiki/spaces/DEVOPS/pages/129302935/Steps+to+deploy+Private+Docker+Registry+Authenticating+new+users
Docker network
To allow multiple services to communicate with each other, they must all join the same Docker network. You create the 'ccctc' network locally by running the command below:
docker network create ccctc
Docker Environment variables
The docker-compose.yml file uses the following environment variable:
Variable | Description |
---|---|
DOCKER_REGISTRY | URL to remote private registry or "" for local. |
Set the environment variables from a terminal as in:
export DOCKER_REGISTRY=registry.ccctechcenter.org:5000/
To switch from the remote Docker registry to the local Docker registry, you can unset the DOCKER_REGISTRY with:
unset DOCKER_REGISTRY
Running the API Gateway modules
From the service module root directory, start the container with:
docker-compose up
Note on running the local stack in 'mixed-mode'
The service-router and service-workers can be run in either an IDE or in Docker. The table below shows the run options supported by default.
Supported by Default? | Docker | IDE |
---|---|---|
Yes | service-workers and service-router | |
Yes | service-workers and service-router | |
Yes | service-router | service-workers |
No (local override config required) | service-workers | service-router |
Stopping the Running Service
With the above docker-compose command, you can CTRL-C to stop the processes. To ensure proper cleanup, follow that with:
docker-compose down