Created
October 25, 2023 23:46
-
-
Save jerryaldrichiii/280e5ae22c6cbc71f2b0cb59d71417bb to your computer and use it in GitHub Desktop.
Postgres + pgadmin + docker compose
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [email protected] | |
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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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