8000 GitHub - sunshine55/affablebean-spring-tutorial: Rewrite Netbeans E-commerce tutorial into microservices with different tech stacks
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

sunshine55/affablebean-spring-tutorial

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Affable Bean Tutorial

Deployment

Frontend: https://chipper-rugelach-1ca688.netlify.app

Backend: https://afbb-api.onrender.com

Database: MongoDB Atlas

Overview

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 image
  • afbb-gradle: container serves web APIs, created using Gradle image
  • afbb-gui: container serves frontent GUIs, created using NodeJS image

Directories Structure

afbb-db: data and contents

  • database seeds & schemas
  • media contents

afbb-gradle: web services and APIs

afbb-gui: user interfaces

  • admin: data management site
  • shop: data-driven front site

Prerequisites

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:

Create the Swarm

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

Bring up APIs

  1. Ctrl+Shift+N > Ctrl+Shift+P > "Dev Containers: Open Folder in Container..." > select path to an afbb-gradle folder
  2. Wait for container window loading completed, all extensions should be installed (the extension IDs are defined in .devcontainer.json)
  3. Select "Spring Boot Dashboard" and Run/Debug service
  4. 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:

  1. At root of workspace folder, find or create .vscode/launch.json
  2. See VSCode how to add environment variables to launch.json instructions here

Bring up GUIs

  1. Ctrl+Shift+N > Ctrl+Shift+P > "Dev Containers: Open Folder in Container..." > select path to a afbb-gui folder
  2. Wait for container window loading completed, all extensions should be installed (the extension IDs are defined in .devcontainer.json)
  3. Go to terminal of the container window: npm run dev
  4. Open browser (recommend Chrome) on the host, i.e.: http://localhost:3000

Run in production mode: npm run build && npm run preview

FAQs

  1. 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:

  2. Unable to start mongo:latest container in VirtualBox VM

    • MongoDB 5 requires a Sandy Bridge or newer CPU Stackoverflow topic
    • Workaround: Avoid MongoDB 5
  3. Whenever start containers, internet connection lost

  4. 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.

About

Rewrite Netbeans E-commerce tutorial into microservices with different tech stacks

Resources

Stars

Watchers

Forks

Packages

No packages published
0