This document explains how to deploy and test the application locally using Docker, Playwright, and k6.
To run the application locally, you need to have the following installed on your machine:
- Docker & Docker Compose
- Make sure you have Docker (v20+) and Docker Compose (v2+) installed on your machine.
- Node.js and npm
- Required if you plan to install packages or run scripts locally (e.g., if you want to run Playwright tests outside of Docker or manage build tasks).
- k6 (for performance testing) -
- Install k6 if you plan to run load/performance tests from your local machine.
- Unzip or clone the project folder to a local directory.
- Navigate to the project directory in your terminal.
The application has separate configurations for development and production.
- Development mode is recommended if you want to modify code, run end-to-end tests, or develop locally
- Production mode provides a more optimized configuration if you just want to see the app in an environment closer to how it would look in production.
-
Start the application with:
docker compose up
-
Wait for all services (database, Redis, APIs, UI) to finish initialization.
-
The application should be available at http://localhost:7800.
Note: In development mode, code changes in certain services (like the UI or API) will be automatically reflected in the running application.
-
First-time database migration (if you haven’t run migrations before):
docker compose -f docker-compose.prod.yml --profile migrate up --build -d
This runs Flyway or other migration services to prepare the production database.
-
Subsequent runs (or if the database is already migrated):
docker compose -f docker-compose.prod.yml up --build -d
-
Once all containers are up, the application should be available at http://localhost:7800.
Note: The -d
flag runs the containers in detached mode. If you want to see the logs, you can remove this flag.
Note: The --build
flag ensures that the latest code changes are reflected in the running containers. You can omit this flag if you don’t want to rebuild the images.
I use Playwright for end-to-end tests. In development mode:
docker compose up e2e-playwright
This command spins up all required services (if not already running) and then runs the Playwright tests in the e2e-playwright
container.
- Results will appear in the terminal once the tests complete.
Note: If you prefer running Playwright locally (outside Docker), ensure you have Node.js and Playwright installed, then run npm install
in the e2e-playwright directory and run the tests with npm test
.
I use k6 for load and performance tests. Ensure you have k6 installed on your machine, then run any of the scripts in the k6/
folder. For example:
k6 run test-qa-ui-http.js
- Tests the HTTP endpoints exposed by the UI (like fetching the homepage, course page, etc.).
k6 run test-qa-api-scenarios.js
- Exercises various API scenarios (courses, users, questions, answers) to check performance under specific arrival rates and concurrency.
The test results appear directly in your terminal. You can reference PERFORMANCE_TEST_RESULTS.md for a sample of the reported metrics and a summary of performance findings.
- In development mode:
Ctrl + C
in your terminal wheredocker compose up
is running, ordocker compose down
in a separate terminal. - In production mode:
docker compose -f docker-compose.prod.yml down
- If you encounter port conflicts, ensure
7800
(Nginx) or other container ports aren’t in use. - For debugging E2E tests, you can run
docker logs e2e-playwright
(adjust container name if different) or open an interactive shell to see additional details.