diff --git a/cloudbank-v4/OBaaS_Container_Image_Build_Guide.MD b/cloudbank-v4/OBaaS_Container_Image_Build_Guide.MD new file mode 100644 index 000000000..f66c83859 --- /dev/null +++ b/cloudbank-v4/OBaaS_Container_Image_Build_Guide.MD @@ -0,0 +1,225 @@ +# OBaaS 2.0 Container Image Build Guide + +## Overview + +This guide documents the client-side container image building approach for OBaaS 2.0's hybrid architecture. Each framework uses different tooling to build and push container images to Oracle Cloud Registry, while maintaining a consistent developer experience. + +## Prerequisites + +- Java 17 or later +- Maven 3.8 or later +- Docker or Podman +- Oracle Cloud Registry access and authentication +- kubectl configured with cluster access + +## Registry Configuration + +All services use these common properties: + +```xml + + us-phoenix-1.ocir.io/tenancy + 0.0.1 + +``` + +## Spring Boot Services (Account Service) + +### Technology Stack +- **Framework**: Spring Boot 3.x +- **Build Tool**: Spring Boot Maven Plugin with Cloud Native Buildpacks +- **Package Type**: Fat JAR +- **Container Strategy**: Buildpacks (automatic optimization) + +### POM Configuration + +```xml + + org.springframework.boot + spring-boot-maven-plugin + + + ${obaas.registry}/${project.artifactId}:${obaas.image.version} + false + + + +``` + +### Commands + +```bash +# Build JAR and container image +mvn clean package spring-boot:build-image + +# Push to Oracle Cloud Registry +docker push us-phoenix-1.ocir.io/tenancy/account:0.0.1 +``` + +### Output +- **JAR**: `target/account-0.0.1-SNAPSHOT.jar` (fat JAR with all dependencies) +- **Image**: Uses optimized buildpacks base image with automatic JVM tuning + +## Helidon Services (Customer Service) + +### Technology Stack +- **Framework**: Helidon MP 4.2.3 +- **Build Tool**: Eclipse JKube Kubernetes Maven Plugin +- **Package Type**: Thin JAR + libs directory +- **Container Strategy**: JKube generator with Helidon detection + +### POM Configuration + +```xml + + 4.0.14 + 1.16.2 + us-phoenix-1.ocir.io/maacloud/${project.artifactId}:${project.version} + + + + org.eclipse.jkube + kubernetes-maven-plugin + ${jkube.version} + +``` + +### Environment Setup (macOS with Rancher Desktop) + +```bash +# Set Docker host for JKube compatibility +export DOCKER_HOST=unix:///Users/$USER/.rd/docker.sock +``` + +### Commands + +```bash +# Build thin JAR and libs +mvn clean package + +# Build container image +mvn k8s:build + +# Push to Oracle Cloud Registry +docker push us-phoenix-1.ocir.io/tenancy/customer-helidon:1.0-SNAPSHOT +``` + +### Output +- **JAR**: `target/customer-helidon.jar` (thin JAR) +- **Dependencies**: `target/libs/` (all dependencies) +- **Deployment**: `target/customer-helidon-deployment.zip` +- **Image**: Uses JKube Java base image with automatic Helidon configuration + +## Alternative: Helidon with Jib + +For environments where JKube has Docker connectivity issues: + +### POM Configuration + +```xml + + com.google.cloud.tools + jib-maven-plugin + 3.4.0 + + + ${obaas.registry}/${project.artifactId}:${obaas.image.version} + + + io.helidon.microprofile.cdi.Main + + 8080 + + + + +``` + +### Commands + +```bash +# Build and push directly (no Docker daemon required) +mvn compile jib:build +``` + + + +## Authentication + +### Oracle Cloud Registry Login + +```bash +docker login us-phoenix-1.ocir.io +# Username: / +# Password: +``` + +## Troubleshooting + +### Common Issues + +#### Spring Boot: Buildpacks Authentication Issues +**Symptom**: "Anonymous users are only allowed read access" +**Solution**: Use separate build and push: +```bash +mvn clean package spring-boot:build-image +docker push +``` + +#### Helidon: Docker Connectivity Issues +**Symptom**: "No DOCKER_HOST given" +**Solution**: Export Docker host for Rancher Desktop: +```bash +export DOCKER_HOST=unix:///Users/$USER/.rd/docker.sock +``` + +#### JKube: Wrong Image Name +**Symptom**: Image tagged as `example/customer-helidon:latest` +**Solution**: Add build configuration to JKube plugin as shown above + +## OBaaS 2.0 Hybrid Workflow + +### Phase 1: Client-Side (Build & Push) + +```bash +# Spring Boot +mvn clean package spring-boot:build-image +docker push us-phoenix-1.ocir.io/tenancy/account:0.0.1 + +# Helidon +mvn clean package k8s:build +docker push us-phoenix-1.ocir.io/tenancy/customer-helidon:1.0-SNAPSHOT +``` + +### Phase 2: Server-Side (Deploy) + +```bash +# Orchestrated deployment via OBaaS server +mvn obaas:deploy +``` + +## Benefits by Framework + +### Spring Boot +- **Mature Tooling**: Built-in buildpacks support +- **Automatic Optimization**: JVM tuning, security updates +- **Cross-Platform**: Works on any OS +- **Layer Caching**: Efficient rebuilds + +### Helidon +- **Thin JAR Benefits**: Better Docker layer caching +- **Framework Support**: JKube has native Helidon detection +- **Flexibility**: Choice between JKube and Jib +- **Lightweight**: Smaller base images + +## Performance Comparison + +| Aspect | Spring Boot | Helidon | +|--------|-------------|---------| +| **Build Time** | ~30-60 seconds | ~30-45 seconds | +| **Image Size** | ~150-200 MB | ~120-150 MB | +| **Startup Time** | ~3-5 seconds | ~2-4 seconds | +| **Memory Usage** | Higher (fat JAR) | Lower (thin JAR) | +| **Layer Caching** | Good | Excellent | + +Both approaches provide fast, reliable container image building suitable for enterprise CI/CD pipelines and local development workflows. \ No newline at end of file diff --git a/cloudbank-v4/account/pom.xml b/cloudbank-v4/account/pom.xml index 89dacd537..775efa27f 100644 --- a/cloudbank-v4/account/pom.xml +++ b/cloudbank-v4/account/pom.xml @@ -16,6 +16,12 @@ account Account Application + + us-phoenix-1.ocir.io/maacloud + + 0.0.2 + + org.springframework.boot @@ -49,6 +55,15 @@ org.springframework.boot spring-boot-maven-plugin + + + ${obaas.registry}/${project.artifactId}:${obaas.image.version} + false + + 21 + + + org.graalvm.buildtools diff --git a/cloudbank-v4/customer-helidon/Dockerfile b/cloudbank-v4/customer-helidon/Dockerfile deleted file mode 100644 index 15b11afef..000000000 --- a/cloudbank-v4/customer-helidon/Dockerfile +++ /dev/null @@ -1,35 +0,0 @@ -# 1st stage, build the app -FROM container-registry.oracle.com/java/jdk-no-fee-term:21 as build - -# Install maven -WORKDIR /usr/share -RUN set -x && \ - curl -O https://archive.apache.org/dist/maven/maven-3/3.8.4/binaries/apache-maven-3.8.4-bin.tar.gz && \ - tar -xvf apache-maven-*-bin.tar.gz && \ - rm apache-maven-*-bin.tar.gz && \ - mv apache-maven-* maven && \ - ln -s /usr/share/maven/bin/mvn /bin/ - -WORKDIR /helidon - -# Create a first layer to cache the "Maven World" in the local repository. -ADD pom.xml . -RUN mvn package -Dmaven.test.skip -Declipselink.weave.skip -DskipOpenApiGenerate - -# Do the Maven build with fat JAR! -ADD src src -RUN mvn package -DskipTests - -# 2nd stage, build the runtime image -FROM container-registry.oracle.com/java/jdk-no-fee-term:21 - -WORKDIR /helidon - -# Copy ONLY the fat JAR (not libs directory) -COPY --from=build /helidon/target/*.jar app.jar - -# Simple fat JAR execution -CMD ["java", "-jar", "app.jar"] - -EXPOSE 8080 - diff --git a/cloudbank-v4/customer-helidon/pom.xml b/cloudbank-v4/customer-helidon/pom.xml index 645702ed9..0161e0657 100644 --- a/cloudbank-v4/customer-helidon/pom.xml +++ b/cloudbank-v4/customer-helidon/pom.xml @@ -13,6 +13,12 @@ customer-helidon 1.0-SNAPSHOT + + 4.0.14 + 1.16.2 + us-phoenix-1.ocir.io/maacloud/${project.artifactId}:${project.version} + + io.helidon.microprofile.bundles @@ -208,6 +214,18 @@ + + + io.helidon.build-tools + helidon-maven-plugin + ${helidon-maven-plugin.version} + + + + org.eclipse.jkube + kubernetes-maven-plugin + ${jkube.version} + @@ -240,4 +258,5 @@ - + + \ No newline at end of file