Docker

Last Updated: 2020-08-01

Grouparoo is easy to deploy with Docker and Docker Compose. An example project can be found at https://github.com/grouparoo/app-example-docker.

Step 1: Create a new git repository and Grouparoo Project

Create a new git repository on your local machine. Note the following:

  • Do not include an environment file, .env. Your environment variables will be managed by Docker
  • Include a package.json file which contains your dependencies
  • Include a .dockerignore file which excludes node_modules and any local config you might have (ie: .env)

Step 2: Build your Dockerfile

Include a Dockerfile which is similar the to the below. We are building a single Dockerfile which can be used in multiple modes. For example, the image can be run as a background task worker (WEB_SERVER=false, WORKERS=10) or web server (WEB_SERVER=true, WORKERS=0). These settings are controlled by environment variables. The default environment variables set here are expected to be overridden by your runtime environment (Swarm, Kubernetes, etc).

# Dockerfile
FROM node:14

WORKDIR /grouparoo

ENV NODE_ENV=production
ENV PORT=3000
ENV WEB_URL=https://grouparoo.company.com:$PORT
ENV WEB_SERVER="true"
ENV SERVER_TOKEN="change-me"
ENV WORKERS=1
ENV REDIS_URL="redis://redis:6379/0"
ENV DATABASE_URL="postgresql://postgres:password@db:5432/grouparoo_docker"
ENV S3_ACCESS_KEY=""
ENV S3_SECRET_ACCESS_KEY=""
ENV S3_REGION=""
ENV S3_BUCKET=""

COPY . .
RUN npm install
RUN npm run prepare
RUN npm prune

WORKDIR /grouparoo/node_modules/@grouparoo/core
CMD ["./bin/start"]

EXPOSE $PORT/tcp

Step 3: Build your docker image

Run:

docker build .

Step 4: Run Your Image

Push and run your docker image!