peppermint icon indicating copy to clipboard operation
peppermint copied to clipboard

Docs for connecting to external database server during setup/installation

Open AlisterBaroi opened this issue 1 year ago • 4 comments

What if, let's say, I want to deploy peppermint, but without setting up the database from the docker compose file.

I want to just assign the environment variables of the database to the peppermint service, so that I can connect to a separate database hosted at a cloud provider (let's say).

Benefits:

  • Peppermint can be setup using just a Dockerfile,
  • Option to not manually setup database for the peppermint, just connect to an already-existing DB hosted somewhere instead,

The docker compose with the single service would look like this (can also be converted to a single Dockerfile):

version: "3.1"

services:
  peppermint:
    container_name: peppermint
    image: pepperlabs/peppermint:latest
    ports:
      - 3000:3000
      - 5003:5003
    restart: always
    healthcheck:
      test: ["CMD", "sh", "-c", "wget --spider $$API_URL"]
      interval: 30s
      timeout: 10s
      retries: 3
    environment:
      DB_USERNAME: "name-of-empty-external-DB"
      DB_PASSWORD: "pass-of-empty-external-DB"
      DB_HOST: "ip-of-empty-external-DB"
      SECRET: 'peppermint4life'

volumes:
 pgdata:

AlisterBaroi avatar Aug 10 '24 18:08 AlisterBaroi

that should work?

potts99 avatar Oct 21 '24 12:10 potts99

I'll test it myself tonight

potts99 avatar Oct 21 '24 12:10 potts99

Did someone make this work? I have the connection to a cloud provider postgres instance, but I am getting

Error: ERROR: permission denied for schema public
   0: sql_schema_connector::sql_migration_persistence::initialize
           with namespaces=None
             at schema-engine/connectors/sql-schema-connector/src/sql_migration_persistence.rs:14
   1: schema_core::state::ApplyMigrations
             at schema-engine/core/src/state.rs:201

Can we make the schema configurable?

raweber42 avatar Nov 06 '25 20:11 raweber42

Ok, found the solution. My case was special: I had to use a different schema than "public", because this was being used by another application already. My steps:

  1. Add a DATABASE_URL to your .env (got this from the code), like this: postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/peppermint?schema=peppermint (=> added ?schema=peppermint to tell peppermint to not use the default schema public.

  2. Obviously, you need to create the schema and add the neccessary permissions on your db host. Here are the commands I ran to make it work:

CREATE SCHEMA peppermint;

ALTER SCHEMA peppermint OWNER TO peppermint;

GRANT CONNECT ON DATABASE peppermint TO peppermint;

GRANT ALL PRIVILEGES ON DATABASE peppermint TO peppermint;

# For existing table (might not be necessary)
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA peppermint TO peppermint;

# For newly created tables
ALTER DEFAULT PRIVILEGES IN SCHEMA peppermint GRANT ALL ON TABLES TO peppermint;

raweber42 avatar Nov 06 '25 22:11 raweber42