This deployment guide's purpose is to provide a simple and easy guide on how to deploy the Reaction platform for evaluation purposes or small deployments. This guide is not meant to generate an enterprise production grade deployment. This deployment guide does not use Kubernetes, instead, Docker Compose is used to manage containers.
- Requirements
- Reaction Services Overview
- Architecture Diagram
- Getting Started
- Automated Server Configuration
- Video Tutorial
- Command Cheatsheet
- A Linux host with at least 2GB of RAM, this guide uses a DigitalOcean droplet
- A registered domain
- A DNS manager that supports Certification Authority Authorization (CCA) records, such as Digital Ocean
- Docker
- Docker Compose
- Git
- Node
- Yarn
- Some familiarity with Traefik
The Reaction GraphQL API service provides the interface to the Reaction core functionality.
The example storefront service provides the public facing storefront interface that customers will interact with.
The Reaction Admin service is a Meteor(currently being migrated off Meteor) application that provides the admin UI to manage products, orders etc.
The Reaction Hydra is a OAuth2 token server that is integrated with the Reaction development platform.
The Reaction Identity service is a Meteor application that provides authentication and authorization services.
Reaction services will be exposed to the public using Traefik, which is a cloud native router. Traefik will act as a reverse proxy that will route traffic to Docker containers. As stated above, you will need a registered domain to complete this step, as it will be necessary to manage DNS records for it.
This guide will use the following sub-domains, where example.com
will need to be substitute it with your domain:
subdomain | description |
---|---|
api.example.com | The Reaction GraphQL API |
storefront.example.com | The example storefront |
admin.example.com | The Reaction admin interface |
hydra.example.com | Hydra OAuth 2.0 server |
identity.example.com | The Reaction Identity service |
traefik.example.com | Traefik's admin UI |
Each of your domains will need an A
DNS record that resolves to your host's IP. It's recommend to use DigitalOcean's free DNS manager. Further, in order to obtain SSL certificates for your sub-domains, you will need a DNS manager that supports CAA records.
Further, you will need a DigitalOcean Auth token to generate CAA records for your sub-domains.
In order to expedite the installation of server dependencies, Ansible will be used to automate most of the server configuration.
In this guide a DigitalOcean node will be used to host the Reaction Platform. If you don't yet have an account, create one at digitalocean.com. Once you are signed into your account, create a new droplet using the Ubuntu 18.4 image with at least 2GB of RAM. Enable DigitalOcean's free firewall and add inbound rules for SSH, HTTP, HTTPS and add your droplet to the firewall.
After the droplet is created either select an existing SSH key to login or click on the "New SSH Key" under the authentication section and copy your public SSH key from your local computer.
Copy the newly created IP address and verify that you can login into the new server by executing:
ssh root@XXX.XXX.XXX.XXX
Ansible requires a control node, which is a computer that manages a remote host. This guide will assumes a Mac laptop/desktop as the control node.
Install Ansible using homebrew, this guide assumes some familiarity with Ansible, if you need an introduction to basic concepts click here.
brew install ansible
Also install python3 to avoid deprecation warnings,
brew install python3
On the control node(i.e. a developer's machine) create an inventory file in which python3
is specified as the interpreter. On your machine, create a new file at named hosts
at /etc/ansible
.
Create inventory file
touch /etc/ansible/hosts
Add the following content to the inventory file:
[servers]
reaction.server
[servers:vars]
ansible_python_interpreter=/usr/bin/python3
[web]
Edit your hosts file
sudo vim /etc/hosts
and add an entry for the DigitalOcean droplet,
XXX.XXX.XXX.XXX reaction.server
Verify that Ansible can communicate with your remote host by executing:
ansible all -m ping -u root
Your should see output similar to:
reaction.dev | SUCCESS => {
"changed": false,
"ping": "pong"
}
Before executing the Ansible playbook, it's necessary to set variables that are specific to your deployment. Find the
vars
section in the reaction.yml
playbook and update as necessary, below is a list of the variable
that need to be updated and a description of each.
Variable | Description |
---|---|
do_auth_token | The Authentication token for the Digital Ocean API |
An email address to receive SSl certificate notifications | |
domain | Your registered domain |
For the rest of the variables, the default values should be used, DO NOT change otherwise, the playbook might fail.
Now it's time to execute the reaction.yml
playbook, which automates most of the tedious server configuration tasks, execute the following command:
ansible-playbook playbooks/reaction.yml -l reaction.server
NOTE: the -l reaction.server
limits the execution of the playbook to the reaction.server
host.
At this point the Reaction GraphQL API, Example Storefront, Reaction Admin, Reaction Identity and Hydra should be accessible over the internet.
To create the primary shop login into the Reaction Admin at the following URL, first substitute the example.com
with your actual domain:
https://admin.example.com
Upon navigating to the Reaction Admin interface, you will be presented with a login form, it will be necessary to create a user first, so click on the "Register" link and fill out the form. Once logged in, proceed to create a shop in the admin interface.
Further, the GraphQL API
explorer will be available at https://api.example.com/graphql
.
The following bash aliases are automatically added to the remote server for convenience.
# Docker Compose
alias dc='docker-compose'
# Bring all services down
alias dcd='docker-compose down'
# Attach to all logs of all services
alias dcl='docker-compose logs -f'
# Run a comand inside a running container
alias dcr='docker-compose run --rm'
# "Restart" all services
alias dcre='docker-compose down && docker-compose up -d && docker-compose logs -f'
# Bring all services up in daemon mode
alias dcu='docker-compose up -d'
# Bring all containers up and attach to their logs
alias dcul='docker-compose up -d && docker-compose logs -f'
# Remove exited containers
alias dprune='docker ps -aq --no-trunc -f status=exited | xargs docker rm'
# Show all running containers, with horizontal paging
alias dps='docker ps -a | less -S'