Skip to content

Support embedded Postgres via config option#256

Draft
Copilot wants to merge 8 commits into
mainfrom
copilot/support-embedded-postgres
Draft

Support embedded Postgres via config option#256
Copilot wants to merge 8 commits into
mainfrom
copilot/support-embedded-postgres

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 6, 2026

Describe the pull request

Adds embedded PostgreSQL support for simplified deployment and testing. Enables running pgrokd without external database dependencies.

Link to the issue: n/a

Changes

Configuration (internal/conf/conf.go, pgrokd.example.yml):

  • Added enable_embedded bool to Database struct

Database initialization (internal/database/db.go):

  • Extended DB struct with embeddedServerHandle and embeddedWorkspace lifecycle fields
  • Added bootEmbeddedServer() - creates temp workspace, configures and starts embedded Postgres
  • Added resolveHostAndPort() - forces localhost when embedded mode enabled
  • Modified New() - conditionally starts embedded instance before gorm connection
  • Added Terminate() - stops embedded instance and cleans workspace

Lifecycle management (pgrokd/cli/main.go):

  • Added SIGINT/SIGTERM handling to call db.Terminate() for cleanup

Tests (internal/database/db_test.go):

  • Coverage for host resolution logic and config assembly

Consent

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledged the Contributing guide.
  • I have added test cases to cover the new code or have provided the test plan.

Test plan

Create pgrokd.yml with:

database:
  port: 5555
  user: "test"
  password: "test"
  database: "pgrokd"
  enable_embedded: true

Run pgrokd -config pgrokd.yml. Verify:

  • Postgres starts on specified port
  • Tables auto-migrate successfully
  • Servers start (SSH, web, proxy)
  • Clean shutdown with Ctrl+C removes temp directories
Original prompt

Support embedded Postgres via https://github.com/fergusstrange/embedded-postgres, support enabling it via a config option "database -> enabled_embedded = true/false".


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 7 commits February 6, 2026 02:05
Co-authored-by: unknwon <2946214+unknwon@users.noreply.github.com>
This commit fixes the style issues introduced in 56de3a7 according to the output
from Go fmt and Gofumpt.

Details: #256
Co-authored-by: unknwon <2946214+unknwon@users.noreply.github.com>
Co-authored-by: unknwon <2946214+unknwon@users.noreply.github.com>
Co-authored-by: unknwon <2946214+unknwon@users.noreply.github.com>
This commit fixes the style issues introduced in 32bb95d according to the output
from Go fmt and Gofumpt.

Details: #256
Co-authored-by: unknwon <2946214+unknwon@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for embedded Postgres configuration Support embedded Postgres via config option Feb 6, 2026
Copilot AI requested a review from unknwon February 6, 2026 02:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants