Skip to content

raw-labs/das-client-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 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.


Publish to GitHub Container Registry (GHCR)

This repo includes a GitHub Actions workflow that builds and publishes the Docker image to GHCR when you push a tag (for example, v0.1.0). The image will be available as:

docker pull ghcr.io/raw-labs/das-client-postgresql:<TAG>

One-time setup

  • Ensure the repository has Actions workflow permissions with write access:
    • Settings → Actions → General → Workflow permissions → "Read and write permissions".
  • After the first publish, optionally set package visibility to Public in the GHCR package settings if you want anonymous pulls.

Release and publish via tag

  1. Create and push a tag from your local machine:

    git tag v0.1.0
    git push origin v0.1.0

    Or create a Release in GitHub with a tag like v0.1.0.

  2. The workflow will build and push:

    • ghcr.io/raw-labs/das-client-postgresql:0.1.0
    • ghcr.io/raw-labs/das-client-postgresql:latest (on tag builds)
  3. Pull the image:

    docker pull ghcr.io/raw-labs/das-client-postgresql:0.1.0

Manual publish (no CI)

If you prefer to push manually:

  1. Create a GitHub token with package write permissions (classic PAT with write:packages or a fine‑grained token with package:write for this repo).

  2. Log in to GHCR:

    echo "$GITHUB_TOKEN" | docker login ghcr.io -u <YOUR_GH_USERNAME> --password-stdin
  3. Build and push:

    export IMAGE=ghcr.io/raw-labs/das-client-postgresql:0.1.0
    docker build -t "$IMAGE" .
    docker push "$IMAGE"

Notes:

  • The CI workflow currently builds for linux/amd64. Enable multi‑arch by adding platforms: linux/amd64,linux/arm64 in .github/workflows/docker-publish.yml if needed.
  • To change the registry path (e.g., nested like ghcr.io/raw-labs/das-sqlite/das-sqlite-server), update the images: value in .github/workflows/docker-publish.yml and retag accordingly.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 2

  •  
  •