Skip to content

Instantly share code, notes, and snippets.

@Ugbot
Last active May 24, 2023 15:30
Show Gist options
  • Save Ugbot/f86143ac002cc3ca3deacb6d73c9fd4c to your computer and use it in GitHub Desktop.
Save Ugbot/f86143ac002cc3ca3deacb6d73c9fd4c to your computer and use it in GitHub Desktop.
NOCODB with the aiven

Title: Running NocoDB in Docker with Aiven PostgreSQL over SSL

Introduction

In this guide, we will demonstrate how to run NocoDB in a Docker container using an Aiven PostgreSQL database with SSL/TLS. We will use the Aiven CLI to set up and manage the PostgreSQL service, but we will also mention how to retrieve the database credentials and SSL certificate using the Aiven web console.

Prerequisites

  • Docker and Docker Compose installed on your local machine
  • Aiven CLI installed on your local machine
  • An Aiven account with sufficient credits

Step 1: Install and set up the Aiven CLI

Install the Aiven CLI using the package manager for your system. For example, on macOS, you can use Homebrew:

brew install aiven-client

After the installation is complete, authenticate with your Aiven account:

avn user login <your_email>

Replace <your_email> with the email address you used to sign up for Aiven.

Step 2: Create Aiven PostgreSQL service

Create a new project to contain your PostgreSQL service:

avn project create <project_name> -d "NocoDB Project"

Replace <project_name> with a desired name for your project.

Create a new PostgreSQL service:

avn service create <postgresql_service_name> --project <project_name> -t pg --plan startup-4 -c pg_version=13

Replace <postgresql_service_name> with a desired name for your PostgreSQL service.

Wait for the service to enter the RUNNING state. You can check the status by running:

avn service list --project <project_name>

Step 3: Retrieve service credentials and CA certificate

Once the service is running, retrieve the connection information:

avn service get <postgresql_service_name> --project <project_name> --json > postgresql_service_info.json

Alternatively, you can get the database credentials and the CA certificate from the Aiven web console. Navigate to your PostgreSQL service in the Aiven Console, then click on the "Service URI" tab. You will find the necessary information there, including hostname, port, username, password, and database name.

You can download the CA certificate from the "Overview" page of your PostgreSQL service on the Aiven web console. Save it as ca.pem in the same directory as your docker-compose.yml file.

Step 4: Create docker-compose.yml file

Create a new directory for your NocoDB setup, and in that directory, create a docker-compose.yml file. Replace the placeholders with the actual values from your PostgreSQL service JSON file or the Aiven web console.

version: '3.8'

services:
  nocodb:
    image: nocodb/nocodb:latest
    restart: always
    ports:
      - "8080:8080"
    volumes:
      - ./ca.pem:/ca.pem
    environment:
      NOCO_DB_HOST: "<your_aiven_postgresql_host>"
      NOCO_DB_PORT: "<your_aiven_postgresql_port>"
      NOCO_DB_USERNAME: "<your_aiven_postgresql_user>"
      NOCO_DB_PASSWORD: "<your_aiven_postgresql_password>"
      NOCO_DB_DATABASE: "<your_aiven_postgresql_database>"
      NOCO_DB_TYPE: "postgres"
      PGSSLMODE: "require"
      PGSSLROOTCERT: "/ca.pem"

Step 5: Run NocoDB container

Navigate to the directory containing the docker-compose.yml file and run the following command:

docker-compose up -d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment