itsmechlark / features

A collection of Dev Container Features.
MIT License
5 stars 12 forks source link

fix(postgresql): Support IPv6 #20

Closed admsev closed 4 months ago

admsev commented 4 months ago

At Github Codespaces, psql was failing.

Steps to reproduce

  1. Create a Codespace using the example .devcontainer.json (see below), try running psql.

Expected behavior: psql connects to the local Postgres Actual behavior:

psql: error: connection to server at "localhost" (::1), port 5432 failed: FATAL:  no pg_hba.conf entry for host "::1", user "postgres", database "postgres", SSL encryption
connection to server at "localhost" (::1), port 5432 failed: FATAL:  no pg_hba.conf entry for host "::1", user "postgres", database "postgres", no encryption

.devcontainer.json:

{
  "image": "mcr.microsoft.com/devcontainers/ruby:3",
  "hostRequirements": {
    "cpus": 2
  },
  "waitFor": "onCreateCommand",
  "updateContentCommand": "bundle install",
  "postCreateCommand": "",
  "postAttachCommand": {
    "server": "rails server"
  },
  "customizations": {
    "codespaces": {
      "openFiles": [
        "TODO.md"
      ]
    },
    "vscode": {
      "extensions": [
        "Shopify.ruby-lsp",
        "GitHub.copilot",
        "GitHub.copilot-chat",
        "akamud.vscode-theme-onedark"
      ]
    }
  },
  "portsAttributes": {
    "3000": {
      "label": "Application",
      "onAutoForward": "openPreview"
    }
  },
  "forwardPorts": [
    3000
  ],
  "features": {
    "ghcr.io/itsmechlark/features/postgresql:1.4": {
      "version": "16"
    }
  }
}

After the fix

psql connects successfully.

admsev commented 4 months ago

Hey @itsmechlark can you please take a look at this PR? Many thanks!

itsmechlark commented 4 months ago

Hey @itsmechlark can you please take a look at this PR? Many thanks!

Thank you, @admsev, for contributing. I will merge this once CI passed.