Skip to content

raw-labs/das-client-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Custom PostgreSQL Docker Image with DAS Extension

This repository contains a Docker image based on CloudNative PG PostgreSQL 15 with the DAS extension installed.


Table of Contents

  1. Features
  2. Build the Image
  3. Run the Container
  4. Connect to PostgreSQL
  5. Using the DAS Extension
  6. Contributing

Features

  • PostgreSQL 15 with DAS extension installed.
  • Passwords handled via environment variables at runtime (no credentials in build layers).

Build the Image

Clone this repository and from the project root run:

docker build -t my-postgres-das:latest .

This command:

  1. Pulls the base Postgres image (ghcr.io/cloudnative-pg/postgresql:15-bookworm).
  2. Installs required dependencies and compiles the DAS extension.

Run the Container

Important: By default, PostgreSQL listens on port 5432. You may already have a local Postgres running on 5432. To avoid conflicts, you can map a different port on your host machine to the container’s 5432 port—e.g., 65432.

Here’s an example run command:

docker run -it --rm \
  -e POSTGRES_PASSWORD="mysecret" \
  -e ADMIN_PASSWORD="anothersecret" \
  -e READONLY_PASSWORD="readonlysecret" \
  -p 65432:5432 \                                   # Host port 65432 -> Container port 5432
  --add-host=host.docker.internal:host-gateway \    # Allows services within Docker to reach external services
  --name my-postgres-das \
  my-postgres-das:latest

Explanation:

  • -e POSTGRES_PASSWORD: sets the Postgres superuser password at runtime.
  • -e ADMIN_PASSWORD: sets the password for a newly-created Postgres admin role
  • -e READONLY_PASSWORD: sets the password for a newly-created Postgres read-only role
  • -p 65432:5432: container’s port 5432 is exposed on your host at port 65432 so you can safely connect without conflicting with any local Postgres server running on 5432.

Connect to PostgreSQL

Once the container is running, you can connect to it with any PostgreSQL client (e.g., psql). If you don’t have psql installed locally:

  • macOS: brew install postgresql
  • Debian/Ubuntu: sudo apt-get install postgresql-client*
  • Windows: Install from the official PostgreSQL downloads.

Then connect:

psql -h 127.0.0.1 -p 65432 -U postgres
  • -h 127.0.0.1: connect to localhost on your machine.
  • -p 65432: use the mapped port (instead of the default 5432).
  • -U postgres: use the postgres superuser (or whatever user you set).

You will be prompted for the password (in this example, mysecret).

Using the DAS Extension

Please refer to https://github.com/raw-labs/das-server-python-mock for an example on how to run a DAS server and connect it to this PostgreSQL instance.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published