Skip to content

Commit

Permalink
upgrade spring boot and jdk
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutoshsahoo committed Jun 14, 2024
1 parent 1f377ea commit 0445c3a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 46 deletions.
16 changes: 8 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
FROM openjdk:17-slim as builder
FROM openjdk:21-slim AS builder
WORKDIR /usr/local/temp
ARG JAR_FILE=build/libs/*.jar
ADD ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract
RUN java -Djarmode=tools -jar application.jar extract --layers --launcher

FROM openjdk:17-slim
FROM openjdk:21-slim
ARG VERSION=latest
LABEL version=${VERSION}
LABEL maintainer="Ashutosh Sahoo"
Expand All @@ -13,8 +13,8 @@ LABEL description="spring-boot-kubernetes-mysql"
WORKDIR /usr/local/app
RUN useradd --user-group --system --create-home --no-log-init app
USER app
COPY --from=builder /usr/local/temp/dependencies/ ./
COPY --from=builder /usr/local/temp/spring-boot-loader/ ./
COPY --from=builder /usr/local/temp/snapshot-dependencies/ ./
COPY --from=builder /usr/local/temp/application/ ./
ENTRYPOINT ["java","org.springframework.boot.loader.JarLauncher"]
COPY --from=builder /usr/local/temp/application/spring-boot-loader/ ./
COPY --from=builder /usr/local/temp/application/snapshot-dependencies/ ./
COPY --from=builder /usr/local/temp/application/dependencies/ ./
COPY --from=builder /usr/local/temp/application/application/ ./
ENTRYPOINT ["java","org.springframework.boot.loader.launch.JarLauncher"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Sample project to test and deploy spring boot application with mysql database in

- Docker with kubernetes enabled
- Kubernetes command-line tool(kubectl)
- JDK 17 LTS
- Gradle
- JDK 21 LTS
- Gradle 8

## Start application

Expand Down
69 changes: 37 additions & 32 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,60 +1,65 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.0.5'
id 'io.spring.dependency-management' version '1.1.0'
id 'idea'
id 'com.palantir.docker' version '0.35.0'
id 'java'
id 'org.springframework.boot' version '3.3.0'
id 'io.spring.dependency-management' version '1.1.5'
id 'idea'
id 'com.palantir.docker' version '0.36.0'
}

group 'com.ashu.practice'
version '5.0.0'
version '6.0.0'

sourceCompatibility = '17'

repositories {
mavenCentral()
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'com.mysql:mysql-connector-j'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.h2database:h2'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'com.mysql:mysql-connector-j'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.h2database:h2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()
}


jar {
enabled = false
enabled = false
}

docker {
dependsOn bootJar
name "ashutoshsahoo/${project.name}:latest"
buildArgs([JAR_FILE: "${project.name}-${project.version}.jar", VERSION: "${project.version}"])
files bootJar
dependsOn bootJar
name "ashutoshsahoo/${project.name}:latest"
buildArgs([JAR_FILE: "${project.name}-${project.version}.jar", VERSION: "${project.version}"])
files bootJar
// tag 'latest', "${project.parent.version}"
// noCache true
}


idea {
module {
downloadJavadoc = true
downloadSources = true
}
module {
downloadJavadoc = true
downloadSources = true
}
}
8 changes: 4 additions & 4 deletions deployment/app-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ items:
metadata:
labels:
app: spring-boot-kubernetes-mysql
version: 5.0.0
version: 6.0.0
name: spring-boot-kubernetes-mysql
spec:
ports:
Expand All @@ -30,7 +30,7 @@ items:
metadata:
labels:
app: spring-boot-kubernetes-mysql
version: 5.0.0
version: 6.0.0
name: spring-boot-kubernetes-mysql
spec:
selector:
Expand All @@ -40,12 +40,12 @@ items:
metadata:
labels:
app: spring-boot-kubernetes-mysql
version: 5.0.0
version: 6.0.0
spec:
serviceAccountName: spring-boot-kubernetes-mysql
containers:
- name: spring-boot-kubernetes-mysql
image: ashutoshsahoo/spring-boot-kubernetes-mysql:5.0.0
image: ashutoshsahoo/spring-boot-kubernetes-mysql:6.0.0
imagePullPolicy: IfNotPresent
resources:
limits:
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ server:
servlet:
context-path: /api/v1
spring:
application:
name: spring-boot-kubernetes-mysql
main:
banner-mode: off
jpa:
open-in-view: false
# datasource:
Expand Down

0 comments on commit 0445c3a

Please sign in to comment.