An example project for deploying Grouparoo with Docker.
Goal: To create a scalable and flexible Grouparoo deployment that:
- Can be auto-scaled as needed
- Will be automatically deployed when the code changes
- Is a 12-factor app with all configuration stored in the Environment
This repository contains examples of 2 ways to deploy a Dockerized application: Docker Compose and Kubernetes via AWS EKS.
- Create a new Grouparoo project. Learn more @ https://www.grouparoo.com/docs/installation.
npm install -g grouparoo
grouparoo init .
-
Install the Grouparoo plugins you want, e.g.:
grouparoo install @grouparoo/postgres. Learn more @ https://www.grouparoo.com/docs/installation/plugins -
Create the
Dockerfileper the example in this project. Learn more @ https://www.grouparoo.com/docs/installation/docker and by viewing theDockerfilein this repository. -
(optional) Create the
docker-compose.yml
Assuming you have node.js installed (v12+):
git clone https://github.com/grouparoo/app-example-docker.gitcd app-example-dockernpm installcp .env.example .envnpm start
Grouparoo can be deployed with Docker Compose to orchestrate everything you need for a Grouparoo cluster. This includes:
- Redis and Postgres services for data storage.
- Separate services for both Grouparoo
webandworkerroles, so they can be scaled independently. - 2 internal networks (frontend and backend) to keep your data isolated.
Learn more by viewing the docker-compose.yml file included in this repository.
To try Docker Compose deployment (assuming you already have Docker installed and running):
- Clone and enter into this repository
docker-compose up. This will download the needed images and build the localDockerfile- Wait for the image to build and eventually visit
http://localhost:3000to see the Grouparoo UI.
Remember, all environment variables can be changed from their defaults, including database information, PORT, etc. All the environment variables have defaults, but you are expected to customize them.
docker-compose.yml in this repository has no data persistence and also no load balancing between grouparoo-web instances. Do not use in production.
This examples uses AWS EKS as our Kuberntes cluster.
-
Visit https://console.aws.amazon.com/eks/home and create a new cluster
- Make a new IAM role to manage your cluster. There's a builder to create a new EKS role. You'll need
AmazonEKSClusterPolicyandAmazonEKSServicePolicy. - Ensure that the cluster has public & private access enabled
- Wait for your cluster to be created (takes ~10 minutes)
- Make a new IAM role to manage your cluster. There's a builder to create a new EKS role. You'll need
-
Once your cluster is ready, we need to add compute nodes too it. Click the "add node group" button.
- Make a new IAM role to manage your node group. There's a builder to create a new EKS - Nodegroup role. Follow these instructions https://docs.aws.amazon.com/eks/latest/userguide/worker_node_IAM_role.html
- create and add a new SSH keypair.
- allow remote access from 'all'
-
Configure
kubectlon your computer to deploy to your new cluster\- https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html
- if you need the AWS CLI https://aws.amazon.com/cli/
- you'll run a command like
aws eks --region us-east-1 update-kubeconfig --name grouparoo-eks-cluster
Test that you can connect to your cluster and that there are nodes with kubectl get nodes --watch
Recommended: deploy the Kubernetes Web UI as well. https://docs.aws.amazon.com/eks/latest/userguide/dashboard-tutorial.html / https://github.com/kubernetes/dashboard
- kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-rc7/aio/deploy/recommended.yaml
- Visit https://console.aws.amazon.com/rds and create a new Aurora database with "PostgreSQL compatibility".
- I've chosen "serverless".
- Note the master name and password
- Be sure to add the newly created EKS security group to the cluster so that your docker images can connect (it looks something like
eks-cluster-sg-grouparoo-eks-cluster) - under 'additional options' create an initial database name
When the database is created, note the endpoint, something like grouparoo-db.cluster-c9ntdcugnmdl.us-east-1.rds.amazonaws.com. This is the database hostname.
The default Postgres username is postgres
- Visit https://console.aws.amazon.com/elasticache and create a new Redis cluster
- Choose node sizes that work for you, and ensure that there are replicas.
- Be sure to add the newly created EKS security group to the cluster so that your docker images can connect (it looks something like
eks-cluster-sg-grouparoo-eks-cluster)
When the redis cluster is created, note the endpoint, something like grouparoo-redis.es9zaf.ng.0001.use1.cache.amazonaws.com:6379. This is the redis hostname.
Example Podfiles are in the /kube directory in this repository. You can deploy these applications to your cluster with kubectl:
kubectl apply -f kube/grouparoo-worker.ymlkubectl apply -f kube/grouparoo-web.yml
grouparoo/app-example-docker Docker image. You will want to replace this with your own image which contains the plugins and secrets you require.
When you created the EKS cluster, AWS also created an Elastic Load Balancer for your cluster. Navigate to https://console.aws.amazon.com/ec2/v2/home?#LoadBalancers:sort=loadBalancerName to see it. There will be a DNS name, like xxx-yyy.us-east-1.elb.amazonaws.com which should be publicly accessible.
- This repository is built automatically to the
grouparoo/app-example-dockerimage on Docker Hub- You can run the
docker-compose.published.ymlincluded in this repository with:
- You can run the
curl https://raw.githubusercontent.com/grouparoo/app-example-docker/main/docker-compose.published.yml --output docker-compose.yml
docker-compose up
Visit https://github.com/grouparoo/app-examples to see other Grouparoo Example Projects.