This repo is a demo project that demonstrates all of Docker's services in a single project. Specifically, it includes the following:
- A containerized development environment (in a few varieties of setup)
- Integration testing with Testcontainers
- Building in GitHub Actions with Docker Build Cloud
This project is also setup to be used for various demos. Learn more about the demo setups by using the README in the ./demo directory.
This sample app provides an API that utilizes the following setup:
- Data is stored in a PostgreSQL database
- Product images are stored in a AWS S3 bucket
- Inventory data comes from an external inventory service
- Updates to products are published to a Kafka cluster
During development, containers provide the following services:
- PostgreSQL and Kafka runs directly in a container
- LocalStack is used to run S3 locally
- WireMock is used to mock the external inventory service
- pgAdmin and kafbat are added to visualize the PostgreSQL database and Kafka cluster
This project is currently configured to run all dependent services in containers and the app natively on the machine (using Node installed on the machine).
To start the app, follow these steps:
-
Start all of the application dependencies
docker compose up
-
Install the app dependencies and start the main app with the following command:
yarn install yarn dev
The project contains configuration for VS Code to enable quick debgging. Once the app is running, you can start a debug session by using the Debug task in the "Run and Debug" panel. This currently only works when the app is running natively on the machine.
This project contains a few unit tests and integration tests to demonstrate Testcontainer usage. To run them, follow these steps (assuming you're using VS Code):
-
Download and install the Jest extension.
-
Open the "Testing" tab in the left-hand navigation (looks like a flask).
-
Press play for the test you'd like to run.
The *.integration.spec.js tests will use Testcontainers to launch Kafka, Postgres, and LocalStack.
Or you can run the tests using the command line:
# Run all tests
$ yarn test
# Run only unit tests
$ yarn unit-test
# Run only the integration tests
$ yarn integration-test
Once the development environment is up and running, the following URLs can be leveraged:
- http://localhost:5050 - pgAdmin to visualize the database. Login using the password
postgres
(configured in the Compose file) - http://localhost:8080 - kafbat to visualize the Kafka cluster
In the dev/scripts
directory, there are a few scripts that can be used to interact with the REST API of the application.