Skip to content

feat(pgadmin): add new module for pgAdmin #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Conversation

AJ0070
Copy link

@AJ0070 AJ0070 commented Jul 12, 2025

Closes #36

Description

This pull request introduces a new Coder module for pgAdmin. This module allows users to easily add a pgAdmin web interface to their workspaces for managing PostgreSQL databases.

  • The pgAdmin module under the AJ0070 namespace.
  • A main.tf file to define the Coder app and script resources.
  • A run.sh script to handle the installation and launch of pgAdmin.
  • A README.md with usage instructions and prerequisites.
  • A basic test file main.test.ts to ensure the module loads correctly.

Type of Change

  • New module
  • Bug fix
  • Feature/enhancement
  • Documentation
  • Other

Module Information

Path: registry/AJ0070/modules/pgadmin
New version: v1.0.0
Breaking change: [ ] Yes [x] No

Testing & Validation

  • Tests pass (bun test)
  • Code formatted (bun run fmt)
  • Changes tested locally

/claim #36

@DevelopmentCats DevelopmentCats self-requested a review July 16, 2025 02:51
@DevelopmentCats
Copy link
Contributor

DevelopmentCats commented Jul 16, 2025

@AJ0070

I went to test this module. It was having issues with installation, and the app was not being proxied.

I forked the registry and made a branch to see if I can understand what is going wrong here.

The main things that I changed on my side to get this working, was I introduced a variable for the pgadmin config, introduced locals to do joins and formatting, and I utilized the venv for pgadmin.

I then added a step to write the configuration to a file so that pgadmin loads with the ideal settings for coder.

Here is the fork if you would like to take a look. https://github.com/DevelopmentCats/registry/tree/cat/AJ0070-pgadmin-fix/registry/AJ0070

@AJ0070
Copy link
Author

AJ0070 commented Jul 16, 2025

@AJ0070

I went to test this module. It was having issues with installation, and the app was not being proxied.

I forked the registry and made a branch to see if I can understand what is going wrong here.

The main things that I changed on my side to get this working, was I introduced a variable for the pgadmin config, and introduced locals to format the url and healthcheck.

I then added a step to write the configuration to a file so that pgadmin loads with the ideal settings for coder.

Here is the fork if you would like to take a look. https://github.com/DevelopmentCats/registry/tree/cat/AJ0070-pgadmin-fix/registry/AJ0070

Thanks for the details!
I'll look into this

@AJ0070
Copy link
Author

AJ0070 commented Jul 17, 2025

Thank you so much for taking the time to test the module and provide such detailed feedback. I really appreciate you forking the repository and creating a working example it was incredibly helpful for understanding the issues with installation and proxying.
Your solution is much more stable. With your permission, I would love to incorporate the changes from your cat/AJ0070-pgadmin-fix branch into my PR to get this merged.

Please let me know @DevelopmentCats if that's okay with you. Thanks again for your help!

@DevelopmentCats
Copy link
Contributor

Thank you so much for taking the time to test the module and provide such detailed feedback. I really appreciate you forking the repository and creating a working example it was incredibly helpful for understanding the issues with installation and proxying. Your solution is much more stable. With your permission, I would love to incorporate the changes from your cat/AJ0070-pgadmin-fix branch into my PR to get this merged.

Please let me know @DevelopmentCats if that's okay with you. Thanks again for your help!

No worries.

That's totally fine with me. I'm happy to provide in whatever way I can. Sorry I couldn't point out the exact issues right out of the gate. I had never really worked with pgadmin-web before now and it took me a minute to get it myself lol.

@AJ0070
Copy link
Author

AJ0070 commented Jul 17, 2025

Thanks for the confirmation!

@AJ0070
Copy link
Author

AJ0070 commented Jul 17, 2025

I've implemented the changes. Let me know if there's anything else you'd like adjusted.

@matifali
Copy link
Member

@AJ0070, please link a video demo of the module wokring in a Coder workspace. Thanks,

@AJ0070
Copy link
Author

AJ0070 commented Jul 17, 2025

@AJ0070, please link a video demo of the module wokring in a Coder workspace. Thanks,

I'll do that right after I fix the workflow failure.

@AJ0070
Copy link
Author

AJ0070 commented Jul 19, 2025

pg-admin-test.mp4

@AJ0070
Copy link
Author

AJ0070 commented Jul 19, 2025

@DevelopmentCats, could you please review the recent changes when you have a moment?

@bpmct
Copy link
Member

bpmct commented Jul 19, 2025

Hey @AJ0070. that video doesn't show pgadmin with coder. the agent doesn't start and there is no pgadmin button in the dashboard

@AJ0070
Copy link
Author

AJ0070 commented Jul 24, 2025

Now pgAdmin icon is visible:

image

but I am not sure why the connection is refusing:

2025-07-24 13:47:00.932 [debu]  apphealth: error checking app health  id=9830f5f2-bf28-4ef1-981a-090ccaf65dbb  slug=pgadmin  now_unhealthy=true  error="Get \"http://localhost:5050/\": dial tcp [::1]:5050: connect: connection refused"

@DevelopmentCats Did you encounter anything like this during your local testing? Let me know if you have any suggestions for resolving it.

@DevelopmentCats
Copy link
Contributor

Now pgAdmin icon is visible:

image but I am not sure why the connection is refusing:
2025-07-24 13:47:00.932 [debu]  apphealth: error checking app health  id=9830f5f2-bf28-4ef1-981a-090ccaf65dbb  slug=pgadmin  now_unhealthy=true  error="Get \"http://localhost:5050/\": dial tcp [::1]:5050: connect: connection refused"

@DevelopmentCats Did you encounter anything like this during your local testing? Let me know if you have any suggestions for resolving it.

Even in my version, it still took forever to build.

PGAdmin seems to be pretty heavy overall, and I doubt there is much to be done to speed the install up. In my testing though I was able to get pgadmin installed, and available over the coder app button.

@AJ0070
Copy link
Author

AJ0070 commented Jul 25, 2025

Now pgAdmin icon is visible:
image
but I am not sure why the connection is refusing:

2025-07-24 13:47:00.932 [debu]  apphealth: error checking app health  id=9830f5f2-bf28-4ef1-981a-090ccaf65dbb  slug=pgadmin  now_unhealthy=true  error="Get \"http://localhost:5050/\": dial tcp [::1]:5050: connect: connection refused"

@DevelopmentCats Did you encounter anything like this during your local testing? Let me know if you have any suggestions for resolving it.

Even in my version, it still took forever to build.

PGAdmin seems to be pretty heavy overall, and I doubt there is much to be done to speed the install up. In my testing though I was able to get pgadmin installed, and available over the coder app button.

Were you able to open it?

@DevelopmentCats
Copy link
Contributor

Now pgAdmin icon is visible:
image
but I am not sure why the connection is refusing:

2025-07-24 13:47:00.932 [debu]  apphealth: error checking app health  id=9830f5f2-bf28-4ef1-981a-090ccaf65dbb  slug=pgadmin  now_unhealthy=true  error="Get \"http://localhost:5050/\": dial tcp [::1]:5050: connect: connection refused"

@DevelopmentCats Did you encounter anything like this during your local testing? Let me know if you have any suggestions for resolving it.

Even in my version, it still took forever to build.
PGAdmin seems to be pretty heavy overall, and I doubt there is much to be done to speed the install up. In my testing though I was able to get pgadmin installed, and available over the coder app button.

Were you able to open it?

It was not loading up when I pulled and tested it last, but let me build and test again. Maybe I can provide you some valuable output

@AJ0070
Copy link
Author

AJ0070 commented Jul 25, 2025

It was not loading up when I pulled and tested it last, but let me build and test again. Maybe I can provide you some valuable output

Thanks so much for looking into this. Once you share your output, I’ll be able to figure out whether the issue is with my local setup or something in the code.

@AJ0070
Copy link
Author

AJ0070 commented Jul 27, 2025

@DevelopmentCats, have you had a chance to test this? Your feedback would be greatly appreciated.

@DevelopmentCats
Copy link
Contributor

@DevelopmentCats, have you had a chance to test this? Your feedback would be greatly appreciated.

Sorry about the delay on this.

I will build this in my template tonight and will provide you with the logs for the module so we can get this buttoned up

@AJ0070
Copy link
Author

AJ0070 commented Aug 7, 2025

@DevelopmentCats, just following up—any update?

@DevelopmentCats
Copy link
Contributor

@DevelopmentCats, just following up—any update?

Checking now, sorry for the delay

@DevelopmentCats
Copy link
Contributor

DevelopmentCats commented Aug 7, 2025

It seems to be loading fine for me when I just pulled it. @AJ0070

Can you upload the icon for this and pull the svg for pgadmin instead of postgres like its referencing right now. Make sure to also make a PR in coder/coder to upload the icon in site/static/icons so that it shows up properly in coder.

Also there is a typo in your avatar image please fix that.

Lastly I notice that you have changes in here for the filebrowser module. Please remove that. I will review this after you take care of those things

@AJ0070
Copy link
Author

AJ0070 commented Aug 7, 2025

@DevelopmentCats added logo on coder: coder/coder#19210

@AJ0070
Copy link
Author

AJ0070 commented Aug 7, 2025

It seems to be loading fine for me when I just pulled it. @AJ0070

Can you upload the icon for this and pull the svg for pgadmin instead of postgres like its referencing right now. Make sure to also make a PR in coder/coder to upload the icon in site/static/icons so that it shows up properly in coder.

Also there is a typo in your avatar image please fix that.

Lastly I notice that you have changes in here for the filebrowser module. Please remove that. I will review this after you take care of those things

@DevelopmentCats Ready for review

@DevelopmentCats
Copy link
Contributor

DevelopmentCats commented Aug 7, 2025

@DevelopmentCats added logo on coder: coder/coder#19210

I would use this logo instead. but the file name and upload looks good to me.

Please make sure you sign the CLA on coder/coder#19210

@AJ0070
Copy link
Author

AJ0070 commented Aug 7, 2025

I would use this logo instead. but the file name and upload looks good to me.

As @aslilac mentioned here do we have proper license to redistribute it?

@DevelopmentCats

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new Coder module for pgAdmin, allowing users to easily deploy a web-based PostgreSQL database management interface in their workspaces. The module provides automated installation, configuration, and startup of pgAdmin 4 with customizable settings.

Key changes:

  • New pgAdmin module under the AJ0070 namespace with complete implementation
  • Automated pgAdmin installation and configuration through shell scripts and Terraform
  • Configurable deployment options including subdomain support and custom configuration

Reviewed Changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
registry/AJ0070/modules/pgadmin/main.tf Terraform configuration defining Coder app and script resources with pgAdmin setup
registry/AJ0070/modules/pgadmin/run.sh Shell script handling pgAdmin installation, virtual environment setup, and service startup
registry/AJ0070/modules/pgadmin/main.test.ts Basic test file ensuring the module loads correctly with required variables
registry/AJ0070/modules/pgadmin/README.md Documentation with usage instructions and module metadata
registry/AJ0070/README.md Author profile information for the AJ0070 namespace

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

printf "Creating Python virtual environment for pgAdmin...\n"
if ! python3 -m venv "$PGADMIN_VENV_DIR"; then
echo "⚠️ Warning: Failed to create virtual environment"
exit 0
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message should be more descriptive and actionable. Consider including the specific error or suggesting potential solutions like checking Python installation or permissions.

Suggested change
exit 0
if ! python3 -m venv "$PGADMIN_VENV_DIR" 2>venv_error.log; then
echo "⚠️ Warning: Failed to create virtual environment at $PGADMIN_VENV_DIR"
echo "Error details:"
cat venv_error.log
echo "Possible causes:"
echo " - Python 3 is not installed or not found in PATH"
echo " - The 'venv' module is missing (try: python3 -m ensurepip --upgrade)"
echo " - Insufficient permissions to write to $PGADMIN_VENV_DIR"
echo " - Not enough disk space"
echo "Please check the above error and try again."
rm -f venv_error.log
exit 1

Copilot uses AI. Check for mistakes.


printf "Installing pgAdmin 4 in virtual environment...\n"
if ! "$PGADMIN_VENV_DIR/bin/pip" install pgadmin4; then
echo "⚠️ Warning: Failed to install pgAdmin4"
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message should be more descriptive and actionable. Consider including information about potential causes like network issues, Python version compatibility, or suggesting to check pip installation.

Suggested change
echo "⚠️ Warning: Failed to install pgAdmin4"
echo "⚠️ Warning: Failed to install pgAdmin4. This may be due to network issues, Python version incompatibility, or a missing pip installation in the virtual environment."
echo "💡 Please check your internet connection, ensure you are using a supported Python version, and verify that pip is installed in the virtual environment ('$PGADMIN_VENV_DIR/bin/pip')."

Copilot uses AI. Check for mistakes.

description = "A map of pgAdmin configuration settings."
default = {
DEFAULT_EMAIL = "admin@coder.com"
DEFAULT_PASSWORD = "coderPASSWORD"
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a hardcoded default password poses a security risk. Consider using a randomly generated password or requiring users to set their own password through a variable.

Copilot uses AI. Check for mistakes.

MASTER_PASSWORD_REQUIRED = false
LISTEN_ADDRESS = "127.0.0.1"
}
}
Copy link
Preview

Copilot AI Aug 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'any' type for the config variable is too permissive and provides no type safety. Consider defining a more specific object type with optional attributes to better validate the configuration structure.

Suggested change
}
variable "config" {
type = map(any)
description = "A map of pgAdmin configuration settings."
default = {
DEFAULT_EMAIL = "admin@coder.com"
DEFAULT_PASSWORD = "coderPASSWORD"
SERVER_MODE = false
MASTER_PASSWORD_REQUIRED = false
LISTEN_ADDRESS = "127.0.0.1"
}
}

Copilot uses AI. Check for mistakes.

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.

PG Admin module
4 participants