Docs for connecting to external database server during setup/installation
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:
that should work?
I'll test it myself tonight
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?
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:
-
Add a
DATABASE_URLto your.env(got this from the code), like this:postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/peppermint?schema=peppermint(=> added?schema=peppermintto tell peppermint to not use the default schemapublic. -
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;