Docker Compose

Deploying RestBI with Docker Compose

Docker Compose simplifies managing multi-container applications by defining services, networks, and volumes in a single YAML file. Here’s how you can deploy RestBI using Docker Compose.

1. Create a docker-compose.yml File

Create a docker-compose.yml file in your project directory with the following content:

version: '3.8'

services:
  restbi:
    image: restbi/restbi-server:latest
    ports:
      - "3000:3000"
    environment:
      DB_HOST: db
      DB_PORT: 5432
      DB_USER: youruser
      DB_PASSWORD: yourpassword
      DB_NAME: chinook
      CORS_WHITELIST: http://example.com,http://anotherdomain.com
    volumes:
      - ./custom-functions:/app/custom-functions
    restart: always

  db:
    image: postgres:13
    environment:
      POSTGRES_USER: youruser
      POSTGRES_PASSWORD: yourpassword
      POSTGRES_DB: chinook
    volumes:
      - db_data:/var/lib/postgresql/data
    restart: always

volumes:
  db_data:

2. Start the Services

Run the following command to start the RestBI and database services:

docker-compose up -d

This command will:

  • Start the RestBI server on port 3000.

  • Set up the PostgreSQL database service.

  • Mount the custom-functions directory for any custom logic you want to include.

Summary

  • PostgreSQL Database Service (db): This service will run a PostgreSQL database instance and create a database named chinook with the specified user credentials.

  • RestBI Service (restbi): This service will connect to the db service using the credentials provided. It will be exposed on port 3000 and will allow requests from whitelisted domains specified in CORS_WHITELIST.

By linking the RestBI service directly to the PostgreSQL service in the Docker Compose configuration, you create a self-contained environment where both services can communicate seamlessly, making it easier to manage and deploy the entire stack.

Last updated