svrc / acme-fitness-store

Sample - how to deploy Spring Boot apps to Azure?

Home Page:https://docs.microsoft.com/en-us/azure/spring-cloud/overview

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ACME Fitness Store

ACME Fitness store is a fictional online retailer selling sporting goods. This repo contains the source code and deployment scripts for the ACME Fitness store application.

High Level Architecture

This application is composed of several services:

  • 4 Java Spring Boot applications:

    • A catalog service for fetching available products.
    • A payment service for processing and approving payments for users' orders
    • An identity service for referencing the authenticated user
    • An assist service for infusing AI into fitness store
  • 1 Python application:

    • A cart service for managing a users' items that have been selected for purchase
  • 1 ASP.NET Core applications:

    • An order service for placing orders to buy products that are in the users' carts
  • 1 NodeJS and static HTML Application

    • A frontend shopping application

The sample can be deployed to Azure Spring Apps Enterprise or Tanzu Application Platform.

Repo Organization

Directory Purpose
apps/ source code for the services

================================================================

Deploy on Tanzu Platform for Cloud Foundry (TPCF aka TAS) - incomplete

Assumption that the proper Cloud Foundry CLI has been installed.

Create Services

cf create-service p.redis on-demand-cache acme-redis 
cf create-service postgres on-demand-postgres-db acme-postgres
cf create-service postgres on-demand-postgres-db acme-assist-postgres
cf create-service postgres on-demand-postgres-db acme-order-postgres       
cf create-service p.config-server standard acme-config  -c  '{ "git": { "uri": "https://github.com/svrc/acme-fitness-store-config" }}'

# This assumes Tanzu Single Sign on for TAS/TPCF is installed and configured against UAA.  You can also use other identity providers if you change the plan and binding below.
cf create-service p-identity uaa acme-sso   
cf create-service p.service-registry standard acme-registry  
cf create-service p.gateway standard acme-gateway -c '{"sso": { "plan": "uaa", "scopes": ["openid", "profile", "email"] }, "host": "acme-fitness" ,"cors": { "allowed-origins": [ "*" ] }}'

# This assumes you have a Chat and Embedding model plan configured with GenAI for Tanzu Platform v0.6+
cf create-service genai <CHAT MODEL PLAN> acme-genai-chat
cf create-service genai <EMBED MODEL PLAN> acme-genai-embed

Identity Service

cd acme-identity
./gradlew assemble
cf push --no-start
cf bind-service acme-identity acme-registry

# Replace [YOUR APPS DOMAIN] with your TPCF's apps domain for the gateway
cf bind-service acme-identity acme-sso -c '{  "grant_types": ["authorization_code"],
    "scopes": ["openid"],
    "authorities": ["openid"],
    "redirect_uris": ["https://acme-fitness.[YOUR APPS DOMAIN]/"],
    "auto_approved_scopes": ["openid"],
    "identity_providers": ["uaa"],
    "show_on_home_page": false}'
 
cf bind-service acme-identity acme-gateway -c identity-routes.json
cf start acme-identity

Cart Service

cd ../acme-cart
cf push --no-start
cf bind-service acme-cart acme-gateway -c cart-routes.json
cf start acme-cart

Payment Service

cd ../acme-payment
./gradlew assemble
cf push --no-start
cf bind-service acme-payment acme-gateway -c pay-routes.json
cf start acme-payment

Catalog Service

cd ../acme-catalog
./gradlew clean assemble
cf push --no-start
cf bind-service acme-catalog acme-gateway -c catalog-service_rate-limit.json
cf start acme-catalog

Acme Assist

cd ../acme-assist
./gradlew clean assemble

# Use this with GenAI 0.6+
cf push --no-start 
cf add-network-policy acme-assist acme-catalog
cf bind-service acme-assist acme-gateway -c assist-routes.json
cf start acme-assist

Order Service

cd ../acme-order
dotnet publish -r linux-x64
cf push --no-start
cf add-network-policy acme-order acme-payment
cf bind-service acme-order acme-gateway -c order-routes.json
cf start acme-order

Shopping Service

cd ../acme-shopping
cf push --no-start
cf bind-service acme-shopping acme-gateway -c frontend-routes.json
cf start acme-shopping

=================================================

Note: ensure that the environment variable for TAS has SPRING_MVC_STATIC_PATH_PATTERN: /static/images/** set. Currently have an issue with the value taken from config server being overwritten.

Local Development setup

TAS Development Tricks

Connecting to Database

https://docs.cloudfoundry.org/devguide/deploy-apps/ssh-services.html

cf ssh -L 65432:{host-of-database-on-TAS}:5432 {application-name}

About

Sample - how to deploy Spring Boot apps to Azure?

https://docs.microsoft.com/en-us/azure/spring-cloud/overview

License:MIT License


Languages

Language:CSS 55.3%Language:HTML 22.8%Language:Java 7.5%Language:Shell 5.6%Language:C# 2.2%Language:Python 2.2%Language:JavaScript 1.7%Language:HCL 1.6%Language:Smalltalk 0.8%Language:Starlark 0.2%Language:Dockerfile 0.1%Language:Procfile 0.0%