postgresql-addon

postgresql-addon

PostgreSql addon

Name Last Update
test Loading commit data...
Dockerfile Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
logo.png Loading commit data...
pg_hba.conf Loading commit data...
pg_ident.conf Loading commit data...
postgresql.conf Loading commit data...
service.sh Loading commit data...
start.sh Loading commit data...

This is the PostgreSQL addon that provider PostgreSQL database to Cloudron apps.

Building

docker build -t girish/postgresql .

Running

Pass postgresql variables in a separate file:

echo "POSTGRESQL_ROOT_PASSWORD=secret" > /tmp/postgresql_vars.sh

You can run the container as follows:

docker run -tiP --name=postgresql -v /tmp/pgdata:/var/lib/postgresql -v /tmp/postgresql_vars.sh:/etc/postgresql/postgresql_vars.sh girish/postgresql

Connecting

You can get the container IP using:

docker inspect --format="{{ .NetworkSettings.IPAddress }}" postgresql

You can then connect using:

PGPASSWORD=secret psql -h localhost -p <port> -U root --dbname=postgres

Alternately connect as (this is how apps will connect):

PGPASSWORD=secret psql -h <container_ip> -U root -W --dbname=dbcockroach

You can also exec into the container and connect without a password

Commands

The /addons/postgresql/service.sh implements service commands like adding/removing users.

Listing users

docker exec -t -i postgresql /addons/postgresql/service.sh list-users

Listing databases

docker exec -t -i postgresql /addons/postgresql/service.sh list-databases

Adding user

docker exec -t -i postgresql /addons/postgresql/service.sh add appid
    the command above will output something like POSTGRESQL_URL=postgres://usercockroach:X8FqEgca@172.18.0.19/dbcockroach

    Connect now using:
        PGPASSWORD=:X8FqEgca psql -h localhost -p 49154 -U usercockroach --dbname=dbcockroach
    Alternately connect using:
        PGPASSWORD=:X8FqEgca psql -h <container_ip> -U usercockroach --dbname=dbcockroach

Removing user

docker exec -t -i postgresql /addons/postgresql/service.sh remove appid

Backing up an app

docker exec -t -i postgresql /addons/postgresql/service.sh backup appid | grep -v ^+ > dump.sql

Restoring an app

docker exec -i postgresql /addons/postgresql/service.sh restore appid < dump.sql