In this workshop we're going to look at how to use express with a postgres database.
- Startup PostGres Database as Container
- Create Docker Image with current Repo
docker-challenge-postgres
- Run Image for
docker-challenge-postgres
as a container - Make API call to Create, Retrieve all books etc.
- Fork this repository
docker-challenge-postgres
- Clone the forked repository onto your local machines
- In the root directory, type
npm install
, which installs dependencies for the project - Pull docker Image for PostGres
docker pull postgres
. - Run
docker init
. - Run and Connect to your PostGres Container. Using a docker compose file.
** Remember to setup the volume in docker compose file for the PostGres Service.**
- Open a port to enable your connection to the PostGres container.
- Run the following database scripts
- create-books.sql
- insert-books.sql
- Update a file
.env
in the root directory of your project with you PostGres Container details. - Type
npm start
, which starts a development server that will reload whenever you make any changes to source files. - Build docker image for current repo
docker-challenge-postgres
- Run Docker image for
docker-challenge-postgres
part of the docker-composedocker-compose up
Create a PR to point to current repo with you changes and docker files. Dockerfile, Docker-compose etc.
- In the PR upload a screenshot of your docker desktop where containers are running.
- In the PR upload a screenshot of your response when retrieving a list of books. From the container.