Skip to content

Commit

Permalink
Add example code for running locally
Browse files Browse the repository at this point in the history
  • Loading branch information
sjmiller609 committed Aug 14, 2023
1 parent 8300f37 commit 2368627
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/run-tembo-locally/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions examples/run-tembo-locally/README.md
Original file line number Diff line number Diff line change
@@ -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
```
8 changes: 8 additions & 0 deletions examples/run-tembo-locally/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: '3'

services:
local-tembo:
container_name: local-tembo
build: .
ports:
- "5432:5432"
1 change: 1 addition & 0 deletions examples/run-tembo-locally/postgresql.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
listen_addresses = '*'

0 comments on commit 2368627

Please sign in to comment.