Frontend: https://chipper-rugelach-1ca688.netlify.app
Backend: https://afbb-api.onrender.com
Database: MongoDB Atlas
Rewrite Netbeans e-commerce tutorial into microservices
Docker compose in this tutorial will create a swarm of containers at localhost to demonstrate the microservices:
afbb-mongo
: container serves database and contents, created using MongoDB imageafbb-gradle
: container serves web APIs, created using Gradle imageafbb-gui
: container serves frontent GUIs, created using NodeJS image
afbb-db
: data and contents
- database seeds & schemas
- media contents
afbb-gradle
: web services and APIs
afbb-gui
: user interfaces
admin
: data management siteshop
: data-driven front site
Prerequisites: Docker, VSCode and Git (either install on OS or another type-2 hypervisor)
If using Linux OS, see prerequisites
handy scripts for installation
Develop microservices with VSCode and type-2 hypervisor:
- Shared development environment with VSCode devcontainer
- Connect multiple VSCode devcontainers with Docker Compose
Bring up all containers:
- First time startup:
docker compose up -d
(create/recreate containers, which will download/reinstall vscode extensions for each container; hence, take a while) - Next times:
docker compose start
All containers orderly created and share the same network created by docker-compose
Ctrl+Shift+N
>Ctrl+Shift+P
> "Dev Containers: Open Folder in Container..." > select path to anafbb-gradle
folder- Wait for container window loading completed, all extensions should be installed (the extension IDs are defined in
.devcontainer.json
) - Select "Spring Boot Dashboard" and Run/Debug service
- At local host, use browser or any HTTP client tool to test APIs, i.e.:
http://localhost:8080/categories
Run with CLI command: SPRING_PROFILES_ACTIVE=local MONGODB_URI=mongodb://localhost:27017/afbb-db CORS_ALLOWED_ORIGINS=http://localhost:3000 ./gradlew bootRun
Run with VSCode:
- At root of workspace folder, find or create
.vscode/launch.json
- See VSCode how to add environment variables to
launch.json
instructions here
Ctrl+Shift+N
>Ctrl+Shift+P
> "Dev Containers: Open Folder in Container..." > select path to aafbb-gui
folder- Wait for container window loading completed, all extensions should be installed (the extension IDs are defined in
.devcontainer.json
) - Go to terminal of the container window:
npm run dev
- Open browser (recommend Chrome) on the host, i.e.:
http://localhost:3000
Run in production mode: npm run build && npm run preview
-
Webpack dev server is significantly slow if using Docker Desktop for Windows
-
Because delay in file processing between Windows host and Linux container guest
-
Workaround:
- Attempt to cache mounted volumes doesn't improve much (see Stackoverflow topic)
- Set up workspace in VirtualBox VM with Linux distro (i.e.: Ubuntu MATE); then install Prerequisites
-
-
Unable to start
mongo:latest
container in VirtualBox VM- MongoDB 5 requires a Sandy Bridge or newer CPU Stackoverflow topic
- Workaround: Avoid MongoDB 5
-
Whenever start containers, internet connection lost
- Caused by ConnMan as explained in Docker forum topic
- Workaround: solution discussed in Stackoverflow topic
-
VSCode create auto forwarded ports every Spring Boot startup
- Open the Settings (Ctrl+, or Cmd+, on macOS).
- Search for
remote.autoForwardPorts
. - Uncheck the option
Remote › Ports: Auto Forward Ports.