diff --git a/examples/run-tembo-locally/Dockerfile b/examples/run-tembo-locally/Dockerfile new file mode 100644 index 000000000..103912dd5 --- /dev/null +++ b/examples/run-tembo-locally/Dockerfile @@ -0,0 +1,14 @@ +FROM quay.io/tembo/tembo-pg-cnpg:latest + +USER root +RUN chown -R postgres:postgres $PGDATA && \ + chmod -R 0700 $PGDATA +ENV PGDATA /var/lib/postgresql/data2 +RUN mkdir -p $PGDATA +RUN chown -R postgres:postgres $PGDATA && \ + chmod -R 0700 $PGDATA +USER postgres +RUN pg_ctl init +# Set permissive authentication +RUN echo "host all all 0.0.0.0/0 trust" >> ${PGDATA}/pg_hba.conf +COPY postgresql.conf ${PGDATA}/postgresql.conf diff --git a/examples/run-tembo-locally/README.md b/examples/run-tembo-locally/README.md new file mode 100644 index 000000000..6a245c089 --- /dev/null +++ b/examples/run-tembo-locally/README.md @@ -0,0 +1,43 @@ +# Running Tembo locally + +This guide is for running a PostgreSQL container locally that supports installing extensions with Trunk. This guide uses Docker Compose to start the same image used in Tembo Cloud on your local machine, and provides guidance on how to manually install and enable extensions. We are also working on a Tembo CLI that will replace this workflow. + +## Starting PostgreSQL and connect + +- Checkout this directory using git, or duplicate the files in a local directory +- Start a PostgreSQL container locally like this +``` +docker-compose up --build -d +``` +- The above command will fail if you already have something running on port 5432 +- Now, you can connect to your database with this command: +``` +psql postgres://postgres:postgres@localhost:5432 +``` + +## Install extensions with Trunk + +- Shell into postgres container +``` +docker exec -it local-tembo /bin/bash +``` + +- Trunk install something +``` +trunk install pgmq +``` + +## Enabling extensions + +- Connect to postgres, this works from inside or outside the container. +``` +psql postgres://postgres:postgres@localhost:5432 +``` +- Enable an extension +``` +CREATE EXTENSION pgmq CASCADE; +``` +- List enabled extensions +``` +\dx +``` diff --git a/examples/run-tembo-locally/docker-compose.yaml b/examples/run-tembo-locally/docker-compose.yaml new file mode 100644 index 000000000..2f8c3bd83 --- /dev/null +++ b/examples/run-tembo-locally/docker-compose.yaml @@ -0,0 +1,8 @@ +version: '3' + +services: + local-tembo: + container_name: local-tembo + build: . + ports: + - "5432:5432" diff --git a/examples/run-tembo-locally/postgresql.conf b/examples/run-tembo-locally/postgresql.conf new file mode 100644 index 000000000..128ef1aa8 --- /dev/null +++ b/examples/run-tembo-locally/postgresql.conf @@ -0,0 +1 @@ +listen_addresses = '*'