docs
Local Development
docker-compose up

Running the Node.js App in Docker

💡 If PostgreSQL is already running locally, you may need to free up port 5432 before proceeding.

  1. Check for any processes running on port 5432:
sudo lsof -i :5432

This command lists all processes using port 5432 along with their process IDs (PID).

  1. Terminate the process using port 5432: If any processes are listed, stop them by running:
sudo kill -9 <pid>

Replace pid with the actual process ID from the previous command's output.

To get our Node.js app up and running in a Docker container, simply run the following command in the root directory:

npm run docker:compose

Docker will begin building the two images defined in the docker-compose.yml file:

  1. backend-dev for the backend
  2. postgres-db for the database.

Create Permission Set

After the images are successfully built:

  • It will start reading the Dockerfile.dev
  • Install dependencies
  • Prisma will automatically run any necessary database migrations
  • The database will be seeded with initial data to get things started

When everything is set, you’ll see the following message, indicating that your server is up and running:

Create Permission Set

Next, let's take a look at our Docker desktop app:

  1. On the containers tab, it's running two containers for our backend and also Postgres.

Create Permission Set

  1. On the Images tab, it created two images defined in our docker-compose.yml:

Create Permission Set

Great! Now let's access our localhost:4000 (opens in a new tab) from the browser. You should be able to see our welcome message:

Welcome to AWSLaunchGOAT!!!

If you access the /users route at localhost:4000/v1/users, you will see seeded data.

Create Permission Set