Skip to content
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

Minor tweaks to lab 1 #18

Merged
merged 2 commits into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions labs/1-Create-Catalog-API/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ A database has already been defined to store the product catalog for eShop, alon

In order to successfully run the the `Catalog.Data.Manager` application and see the database be created, a PostgreSQL database server is required. The project is pre-configured to connect to a local server using *trust* authentication in its `appsettings.Development.json` file. Docker is a simple way to run instances of databases for development.

We're going to run 2 docker containers, the PostgreSQL container and [pgAdmin](https://www.pgadmin.org/). This will make it easy to inspect the database using a visual tool:
davidfowl marked this conversation as resolved.
Show resolved Hide resolved

### Docker CLI

postgres

```
docker run --name postgres-dev -e POSTGRES_HOST_AUTH_METHOD=trust -p 5432:5432 -d postgres
```

pgAdmin

```
docker run --name pgadmin-dev -e PGADMIN_CONFIG_MASTER_PASSWORD_REQUIRED=False -e PGADMIN_CONFIG_SERVER_MODE=False -e [email protected] -e PGADMIN_DEFAULT_PASSWORD=admin -p 0:80 -d dpage/pgadmin4
```

### Docker Desktop

1. Using Docker, create a container to host the PostgreSQL server with the following details:
- Name: `postgres-dev`
- Image: `postgres:latest`
Expand All @@ -23,7 +41,7 @@ In order to successfully run the the `Catalog.Data.Manager` application and see
- `POSTGRES_HOST_AUTH_METHOD` : `trust`

![Creating a container for PostgreSQL in Docker Desktop](./img/docker-postgres-dev.png)
1. Create another container to host an instance of [pgAdmin](https://www.pgadmin.org/). This will make it easy to inspect the database using a visual tool:
1. Create another container to host an instance of [pgAdmin](https://www.pgadmin.org/):
- Name: `pgadmin-dev`
- Image: `dpage/pgadmin4:latest`
- Ports: `0` (random)
Expand All @@ -43,7 +61,21 @@ In order to successfully run the the `Catalog.Data.Manager` application and see
![Logs and health-check endpoint of the Catalog.Data.Manager project showing the database initialization status](./img/catalog.data.manager-logs-and-health.png)

1. Stop the application and try launching it again and seeing the output of the `/health` endpoint return `Degraded` while the database initialization is still in progress.
1. Open the pgAdmin UI in another browser tab (find the host port assigned to the container's endpoint on port 80 in the Docker UI) and add the local PostgreSQL server instance by right-clicking on the **Servers** node in the tree-view and selecting **Register > Server** (use `localhost` in the **Connection** tab).
1. Find the port assigned to the pgAdmin container.

**Docker CLI**

```
docker ps
```

![Image of the docker CLI showing the port for pgAdmin](./img/find-docker-endpoint.png)

**Docker Desktop**

![Image of docker desktop UI showing the port for pgAdmin](./img/find-docker-endpoint-ui.png)

1. Open the pgAdmin UI in another browser tab and add the local PostgreSQL server instance by right-clicking on the **Servers** node in the tree-view and selecting **Register > Server** (use `host.docker.internal` in the **Connection** tab).
1. Expand the tree-view nodes under the server node you registered to see the that the tables representing the Entity Framework Core model have been created.

![pgAdmin UI showing the created tables](./img/pgadmin-postgres-dev.png)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading