Docker & Docker Compose

Last Updated: 2021-02-08

Example Docker Compose

As an example of how to orchestrate a more complex deployment, the following example docker-compose file is provided. This will create our needed networks (frontend and backend), our needed storage servers (Postgres and Redis), 2 types of grouparoo instances (web and backend).

This example requires a docker swarm cluster (or local instance). You can create one on your local machine with docker swarm init.

# docker-compose.yml
version: "3.1"
services:
  redis:
    image: redis
    restart: always
    networks:
      - grouparoo_backend

  db:
    image: postgres
    restart: always
    environment:
      POSTGRES_PASSWORD: password
      POSTGRES_DB: grouparoo_docker
    networks:
      - grouparoo_backend

  grouparoo-web:
    build: ./
    ports:
      - 3000:3000
    environment:
      PORT: 3000
      REDIS_URL: redis://redis:6379/0
      DATABASE_URL: postgresql://postgres:password@db:5432/grouparoo_docker
      WEB_SERVER: "true"
      WORKERS: 0
    depends_on:
      - db
      - redis
    networks:
      - grouparoo_frontend
      - grouparoo_backend

  grouparoo-worker:
    build: ./
    environment:
      REDIS_URL: redis://redis:6379/0
      DATABASE_URL: postgresql://postgres:password@db:5432/grouparoo_docker
      WEB_SERVER: "false"
      WORKERS: 10
    depends_on:
      - db
      - redis
    networks:
      - grouparoo_frontend
      - grouparoo_backend

networks:
  grouparoo_frontend:
    driver: overlay
  grouparoo_backend:
    driver: overlay

Notes

Remember, all environment variables can be changed from their defaults, including database information, PORT, etc.

Docker will regularly restart/rebuild your images. You may at times see "stuck" background task in the resque dashboard. Grouparoo will automatically rescue these jobs and retry them after an hour.

All the environment variables have defaults, but you are expected to customize them. You likely will want to create multiple runtime clusters, some workers and some web servers. This way you can scale each runtime mode separately as needed.

The example docker-compose.yml has no data persistence - ⚠️ DO NOT USE IN PRODUCTION!

The example docker-compose.yml has no load balancing between grouparoo-web instances - ⚠️ DO NOT USE IN PRODUCTION!

You can scale the number of web and worker processes independently. Depending on your workload, you may need more of one type of process than another.