{"id":31465627,"url":"https://github.com/quanghuybest2k2/postgres","last_synced_at":"2026-04-28T12:02:25.114Z","repository":{"id":312712573,"uuid":"1047051209","full_name":"quanghuybest2k2/postgres","owner":"quanghuybest2k2","description":"postgres db","archived":false,"fork":false,"pushed_at":"2025-09-14T06:00:18.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-01T17:58:53.983Z","etag":null,"topics":["docker","docker-compose","pgadmin4","postgresql"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quanghuybest2k2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-29T16:55:15.000Z","updated_at":"2025-09-14T06:00:21.000Z","dependencies_parsed_at":"2025-09-01T15:27:24.104Z","dependency_job_id":"2a24fb5b-f9bf-4504-9feb-2d01790959d1","html_url":"https://github.com/quanghuybest2k2/postgres","commit_stats":null,"previous_names":["quanghuybest2k2/postgres"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/quanghuybest2k2/postgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quanghuybest2k2%2Fpostgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quanghuybest2k2%2Fpostgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quanghuybest2k2%2Fpostgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quanghuybest2k2%2Fpostgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quanghuybest2k2","download_url":"https://codeload.github.com/quanghuybest2k2/postgres/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quanghuybest2k2%2Fpostgres/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32379629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T11:25:28.583Z","status":"ssl_error","status_checked_at":"2026-04-28T11:25:05.435Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-compose","pgadmin4","postgresql"],"created_at":"2025-10-01T17:57:52.487Z","updated_at":"2026-04-28T12:02:25.108Z","avatar_url":"https://github.com/quanghuybest2k2.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Best Practice - PostgreSQL + pgAdmin with Docker Compose\n\nThis project provides a **PostgreSQL database** and **pgAdmin 4** UI running with Docker Compose.  \nIt includes a helper script (`setup.sh`) that retries up to 3 times if starting the containers fails (e.g., due to network issues).\n\n---\n\n## 📦 Requirements\n\n- [Docker](https://docs.docker.com/get-docker/) installed and running\n- [Docker Compose](https://docs.docker.com/compose/) v2 or later\n\n---\n\n## ⚙️ Setup\n\n1. Make the script executable:\n   ```bash\n   chmod +x setup.sh\n   ```\n2. Run the script:\n\n   ```bash\n   ./setup.sh\n   ```\n\n   - The script will check if Docker is installed.\n   - It will run `docker compose up -d --build`.\n   - If something fails (e.g., network issue when pulling images), it retries up to **3 times**.\n\n---\n\n## 🌐 Accessing Services\n\n### PostgreSQL\n\n- **Host:** `postgres`\n- **Port:** `5432` (from `.env`)\n- **User:** `postgres` (from `.env`)\n- **Password:** `huy` (from `.env`)\n- **Database:** `best_practice` (from `.env`)\n\nShow all table:\n\n```bash\ndocker exec -it postgres psql -U postgres -d best_practice -c \"\\dt\"\n```\n\n### pgAdmin 4\n\n- Open in browser: [http://localhost:8080](http://localhost:8080)\n- **Email:** `admin@admin.com` (from `.env`)\n- **Password:** `admin` (from `.env`)\n\nOnce logged in, you can add a new server connection:\n\n- **Host name/address:** `postgres` (Docker service name, same network)\n- **Port:** `5432`\n- **Username:** `postgres`\n- **Password:** `huy`\n\nTest query:\n\n```sql\nSELECT u.name, p.name AS product, oi.quantity, pay.amount, pay.method\nFROM order_items oi\nJOIN orders o ON oi.order_id = o.id\nJOIN users u ON o.user_id = u.id\nJOIN products p ON oi.product_id = p.id\nJOIN payments pay ON pay.order_id = o.id;\n```\n\n---\n\n## 🛑 Stopping Services\n\nTo stop and remove containers (while keeping data volume):\n\n```bash\ndocker compose down\n```\n\nTo remove everything including the volume:\n\n```bash\ndocker compose down -v\n```\n\n---\n\n## 📝 Notes\n\n- Data is persisted in a Docker volume (`postgres_data`).\n\n---\n\n## Test with api\n\n- Open in browser: [http://localhost:3000](http://localhost:3000)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquanghuybest2k2%2Fpostgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquanghuybest2k2%2Fpostgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquanghuybest2k2%2Fpostgres/lists"}