Skip to content

Commit da8562a

Browse files
committed
Add switch for starting pgAdmin in run-docker-postgres
1 parent 2be3358 commit da8562a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

run-docker-postgres.ps1

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
#Requires -Version 7.0
22

3-
# This script starts a docker container with postgres database, used for running tests.
3+
# This script starts a PostgreSQL database in a docker container, which is required for running tests locally.
4+
# When the -UI switch is passed, pgAdmin (a web-based PostgreSQL management tool) is started in a second container, which lets you query the database.
5+
# To connect to pgAdmin, open http://localhost:5050 and login with user "[email protected]", password "postgres". Use hostname "db" when registering the server.
46

5-
docker container stop jsonapi-dotnet-core-testing
7+
param(
8+
[switch] $UI=$False
9+
)
610

7-
docker run --rm --name jsonapi-dotnet-core-testing `
8-
-e POSTGRES_DB=JsonApiDotNetCoreExample `
9-
-e POSTGRES_USER=postgres `
10-
-e POSTGRES_PASSWORD=postgres `
11-
-p 5432:5432 `
12-
postgres:15
11+
docker container stop jsonapi-postgresql-db
12+
docker container stop jsonapi-postgresql-management
13+
14+
docker run --pull always --rm --detach --name jsonapi-postgresql-db -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres:latest
15+
16+
if ($UI) {
17+
docker run --pull always --rm --detach --name jsonapi-postgresql-management --link jsonapi-postgresql-db:db -e PGADMIN_DEFAULT_EMAIL=admin@admin.com -e PGADMIN_DEFAULT_PASSWORD=postgres -p 5050:80 dpage/pgadmin4:latest
18+
}

0 commit comments

Comments
 (0)