Building Spring Boot Applications for ARM Architecture with Jenkins Pipeline Deployment to Kubernetes

Environment Setup for Multi-Architecture Builds

Maven Container Image Acquisition

Retrieve the aprpopriate Maven container image for your target architecture:

https://hub.docker.com/_/maven/tags?page=&page_size=&ordering=&name=3.5.3-alpine

docker pull maven:3.5.3-alpine@sha256:4c4e266aacf8ea6976b52df8467134b9f628cfed347c2f6aaf9e6aff832f7c45

JDK Container Image Configuration

Obtain the corresponding OpenJDK image for your architecture:

https://hub.docker.com/_/openjdk/tags?page=&page_size=&ordering=&name=8u332

docker pull openjdk:8u332@sha256:a113091e38c3fa501056c435e8884dccc999569fa1be2b35be1cdee0502752c6

For offline environments, use these commands to manage images:

docker save -o custom-image-name.tar image-hash
docker load -i custom-image-name.tar
docker tag image-id:v1 registry.example.com/repository/image:tag

Jenkins Pipeline Configuration

Authentication and Docker Operations

Configure Jenkins pipeline to authenticate with container registry using stored credentials:

steps {
    withCredentials([usernamePassword(credentialsId: 'registry-auth', passwordVariable: 'REGISTRY_PASSWORD', usernameVariable: 'REGISTRY_USER')]) {
        sh '''
        docker build --build-arg BASE_IMAGE=registry.example.com/base-images/arm64/openjdk:8u332-custom \
        -f application/Dockerfile \
        -t registry.example.com/deployment/app-arm64:latest .
        
        docker login registry.example.com -u $REGISTRY_USER -p $REGISTRY_PASSWORD
        docker push registry.example.com/deployment/app-arm64:latest
        '''
    }
}

Complete Jenkins Pipeline Definition

Define a comprehensive pipeline that handles both compilation and deployment phases:

pipeline {
    agent {
        docker {
            image 'registry.example.com/build-tools/maven-arm64:3.5.3'
            args '-v /root/.m2:/root/.m2 -v /usr/bin/docker:/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -v /usr/bin/kubectl:/usr/bin/kubectl'
            label 'arm64-builder'
        }
    }
    
    environment {
        ACTIVE_PROFILE = "${params.PROFILE ?: 'production'}"
    }
    
    stages {
        stage('Compile Application') {
            steps {
                sh 'mvn clean package -U -P ${ACTIVE_PROFILE}'
            }
        }
        
        stage('Containerize and Deploy') {
            steps {
                withCredentials([usernamePassword(credentialsId: 'registry-auth', passwordVariable: 'REGISTRY_PASSWORD', usernameVariable: 'REGISTRY_USER')]) {
                    sh '''
                    docker build --build-arg BASE_IMAGE=registry.example.com/base-images/arm64/openjdk:8u332-custom \
                    -f application/Dockerfile \
                    -t registry.example.com/deployment/app-arm64:${BUILD_NUMBER} .
                    
                    docker login registry.example.com -u $REGISTRY_USER -p $REGISTRY_PASSWORD
                    docker push registry.example.com/deployment/app-arm64:${BUILD_NUMBER}
                    '''
                }
            }
        }
    }
}

Docker Container Configuration

Application Container Template

Create a flexible Dockerfile that accepts base image as build argument:

ARG BASE_IMAGE
FROM ${BASE_IMAGE}

# Set environment variables for timezone and locale
ENV LANG=C.UTF-8
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

# Copy application artifact
COPY target/application-*.jar /opt/application.jar

WORKDIR /app

EXPOSE 8080

# Accept runtime configurations from Kubernetes
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS $DEBUG_FLAGS $MONITORING_OPTS -jar /opt/application.jar --spring.config.location=$SPRING_CONFIG_PATH"]

Alternative Container Configuration

Sample Dockerfile with additional environment settinsg:

ARG BASE_IMAGE
FROM ${BASE_IMAGE}

ENV LANG=C.UTF-8
ENV TZ=Asia/Shanghai

# Database configuration environment variable
ENV DATABASE_TYPE=mysql

COPY target/service-*-SNAPSHOT.jar /opt/service.jar

EXPOSE 7998

# Runtime parameters managed by orchestration layer
CMD ["java", "-jar", "/opt/service.jar"]

Tags: spring-boot arm-architecture jenkins-pipeline kubernetes-deployment docker-build

Posted on Tue, 01 Sep 2026 16:23:39 +0000 by Steffen