This article explains how to run the Reaction Federated Gateway service locally for developing or testing. If you want to deploy the service to your Reaction installation, refer to the Deployment article instead.
Federated Gateway is just a single service in a larger e-commerce ecosystem that Reaction is creating. The easiest way to get up and running with the entire Reaction system is to use the Reaction Platform. We'll cover how to set it up with and without the Platform, but know the Platform is the preferred way to run the entire Reaction system locally.
You'll need at least the following.
- Git
- Docker
- Docker Compose
- A GitHub account with a configured SSH key
Before we cover how to set up and run the service, let's briefly touch on what the Apollo Federation is and its relationship to Federated Gateway. TODO: add details
TODO: add instructions on getting started with the Reaction Platform
Start by cloning the Federated Gateway repository.
git clone [email protected]:reactioncommerce/federated-gateway.git
Create any networks that you have not already created:
docker network create federation.reaction.localhost
All Reaction Commerce services use Docker and Docker Compose with a .env
file to store environment configuration. If running outside of the Reaction Platform, create an .env
file for a project by running bin/setup
in that project's root directory.
NEVER commit the .env
file to git.
Start our Federated Gateway service. We'll change into Federated Gateway's root directory, create a .env
and start its Docker containers using docker-compose
.
cd federated-gateway
bin/setup
docker-compose up
The initial download and build of these Docker artifacts can take a few minutes depending on your internet connection and host machine.
Services are to be specified in the services.js
config file.
This is an export of an array of objects of the form { name: String, url: String }
, where the url is a path to the graphql endpoint of the service being registered.
Start this service by building and running the Docker containers using the Docker Compose up
command.
docker-compose up
TODO: add URL where service will be running
TODO: add endpoint URL
- Start containers:
docker-compose up
- Stop containers:
docker-compose stop
- Rebuild containers:
docker-compose up --build
- Remove containers (deletes data!):
docker-compose down
- View container logs:
docker-compose logs -f
- Run linter:
docker-compose run --rm federated-gateway npm run lint
- Run test:
docker-compose run --rm federated-gateway npm test
- Run (same as
docker-compose up
):docker-compose run --rm --service-ports --use-aliases federated-gateway npm run start:debug
- Run in debug mode:
docker-compose run --rm --service-ports --use-aliases federated-gateway npm run start:debug
- Run in watch mode:
docker-compose run --rm --service-ports --use-aliases federated-gateway npm run watch
- Run in watch and debug mode:
docker-compose run --rm --service-ports --use-aliases federated-gateway npm run watch:debug