Skip to main content
VirtualVenture
Back to Blog
DevOps & Automation10 min readApril 26, 2026

Deploying Java Microservices with React & Next.js: A Full-Stack Production Guide

How to architect, containerise, and deploy a full-stack application with Java Spring Boot microservices on the backend and React/Next.js on the frontend — from local development to production Kubernetes.

Modern enterprise applications increasingly follow a pattern of Java Spring Boot microservices on the backend with React or Next.js on the frontend. Getting this stack into production reliably requires careful thought about containerisation, service discovery, API routing, and CI/CD. Here's the complete picture.

Architecture Overview

A typical production setup for this stack looks like this:

  • Frontend: Next.js application served via Vercel, Cloudflare Pages, or a containerised Nginx deployment on Kubernetes
  • API Gateway: Kong, AWS API Gateway, or Spring Cloud Gateway routing requests to backend microservices
  • Backend: Multiple Spring Boot microservices, each in its own container, communicating via REST or Kafka
  • Service Mesh: Istio or Linkerd for mTLS between services, traffic management, and observability
  • Database: PostgreSQL or MySQL per service (database-per-service pattern), with connection pooling via PgBouncer
  • Message Broker: Apache Kafka or RabbitMQ for async inter-service communication

Containerising Java Microservices

A well-optimised Dockerfile for a Spring Boot application uses multi-stage builds to keep the final image small:

  • Stage 1 (build): Use eclipse-temurin:21-jdk-alpine, run ./mvnw package -DskipTests
  • Stage 2 (runtime): Use eclipse-temurin:21-jre-alpine, copy the JAR from stage 1
  • Run as a non-root user — add a dedicated app user in the Dockerfile
  • Use Spring Boot's layered JAR feature for better Docker layer caching
  • Set JVM flags: -XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0 for correct memory limits in containers
  • Target image size should be under 200 MB for a typical Spring Boot service

Need help implementing this?

Our certified engineers can assess your environment and build the right solution — free initial assessment, fixed-quote pricing.

Get Free Assessment

Next.js Deployment Options

Next.js gives you three deployment modes, each with different infrastructure implications:

  • Vercel (recommended for most teams) — zero-config, automatic preview deployments, edge functions, ISR support
  • Standalone output mode — next build produces a self-contained Node.js server, ideal for containerised deployments on Kubernetes
  • Static export — next export for fully static sites served from S3/CloudFront or OCI Object Storage
  • For Kubernetes: use the standalone output, build a Docker image with node:20-alpine, expose port 3000, and put it behind an Nginx ingress

Kubernetes Deployment for Microservices

Each Spring Boot microservice gets its own Kubernetes Deployment, Service, and HorizontalPodAutoscaler:

  • Use separate namespaces per environment (dev, staging, prod) — not separate clusters unless compliance demands it
  • Set resource requests and limits on every container — e.g. requests: cpu: 250m, memory: 512Mi
  • Configure liveness and readiness probes using Spring Boot Actuator's /actuator/health endpoint
  • Use Kubernetes Secrets (backed by AWS Secrets Manager or HashiCorp Vault via External Secrets Operator) for database credentials
  • Deploy a ConfigMap for non-sensitive application properties per environment
  • Use PodDisruptionBudgets to ensure at least one replica is always available during node maintenance

CI/CD Pipeline with GitHub Actions

A production-grade CI/CD pipeline for this stack typically has these stages:

  • Test — run unit and integration tests with Maven Surefire; run Jest/Vitest for Next.js
  • Build — build Docker images with multi-stage Dockerfiles, tag with Git SHA
  • Push — push images to ECR, GCR, or OCI Container Registry
  • Deploy to staging — update Kubernetes manifests via Helm or Kustomize, apply with kubectl
  • Smoke test — run a basic health check against the staging environment
  • Deploy to production — manual approval gate, then rolling update with zero downtime
  • Rollback — keep the previous image tag; rollback is a single kubectl rollout undo command

Observability Stack

You can't operate microservices without observability. The standard stack for Java + Next.js on Kubernetes:

  • Metrics: Prometheus scraping Spring Boot Actuator /actuator/prometheus and Next.js custom metrics; Grafana dashboards
  • Logs: Structured JSON logging from Spring Boot (Logback with logstash-logback-encoder); ship to Loki or Elasticsearch via Fluent Bit
  • Traces: OpenTelemetry Java agent for Spring Boot; Next.js instrumentation with @vercel/otel; Jaeger or Tempo as the backend
  • Alerts: Prometheus AlertManager for infrastructure alerts; PagerDuty or OpsGenie for on-call routing

Need Help Implementing This?

Our certified engineers can assess your environment and implement the right solution for your business.

Need help?

Chat with us on WhatsApp