Skip to content

Instantly share code, notes, and snippets.

@jerryaldrichiii
Created October 25, 2023 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jerryaldrichiii/280e5ae22c6cbc71f2b0cb59d71417bb to your computer and use it in GitHub Desktop.
Save jerryaldrichiii/280e5ae22c6cbc71f2b0cb59d71417bb to your computer and use it in GitHub Desktop.
Postgres + pgadmin + docker compose
version: "3"
services:
postgres:
image: postgres:15-alpine
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- postgres:/var/lib/postgresql/data
ports:
- 5432:5432
healthcheck:
test: pg_isready -q -U postgres
interval: 1s
timeout: 5s
retries: 30
migrate:
image: migrate/migrate:4
depends_on:
- postgres
volumes:
- ../migrations:/migrations
depends_on:
postgres:
condition: service_healthy
command:
- "-path"
- "/migrations"
- "-database"
- "postgres://postgres:postgres@postgres:5432/postgres?sslmode=disable"
- "up"
pgadmin:
image: dpage/pgadmin4:7
environment:
PGADMIN_DEFAULT_EMAIL: admin@localhost.com
PGADMIN_DEFAULT_PASSWORD: pgadmin
PGADMIN_LISTEN_PORT: 80
ports:
- 15432:80
volumes:
- pgadmin:/var/lib/pgadmin
- ./servers.json:/pgadmin4/servers.json
entrypoint: >
/bin/sh -c "
export STORAGE_DIR=/var/lib/pgadmin/storage/admin_localhost.com;
mkdir -p $$STORAGE_DIR;
echo 'postgres:5432:postgres:postgres:postgres' > $$STORAGE_DIR/pgpass;
chmod 600 $$STORAGE_DIR/pgpass;
/entrypoint.sh
"
depends_on:
migrate:
condition: service_completed_successfully
volumes:
postgres:
pgadmin:
{
"Servers": {
"slocap": {
"Name": "slocap",
"Group": "Servers",
"Port": 5432,
"Username": "postgres",
"Host": "postgres",
"SSLMode": "prefer",
"PassFile": "/pgpass",
"MaintenanceDB": "postgres"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment