From b33a746d7f35de22a9b08465553cc1b8c4af35f2 Mon Sep 17 00:00:00 2001 From: purovps Date: Sun, 15 Feb 2026 01:59:12 +0800 Subject: [PATCH] Initial commit: Hello Spring Boot --- .drone.yml | 14 ++++++ Dockerfile | 4 ++ pom.xml | 44 +++++++++++++++++++ .../java/im/puro/hello/HelloApplication.java | 25 +++++++++++ src/main/resources/application.properties | 2 + .../im/puro/hello/HelloApplicationTests.java | 11 +++++ 6 files changed, 100 insertions(+) create mode 100644 .drone.yml create mode 100644 Dockerfile create mode 100644 pom.xml create mode 100644 src/main/java/im/puro/hello/HelloApplication.java create mode 100644 src/main/resources/application.properties create mode 100644 src/test/java/im/puro/hello/HelloApplicationTests.java diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..6188b91 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,14 @@ +kind: pipeline +type: docker +name: build + +steps: + - name: build + image: maven:3.9-eclipse-temurin-21 + commands: + - mvn clean package -DskipTests + + - name: test + image: maven:3.9-eclipse-temurin-21 + commands: + - mvn test diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7fab4da --- /dev/null +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM eclipse-temurin:21-jre-alpine +COPY target/*.jar app.jar +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "/app.jar"] diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..41dca62 --- /dev/null +++ b/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.2.2 + + im.puro + hello-spring + 0.0.1 + hello-spring + + + 21 + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/src/main/java/im/puro/hello/HelloApplication.java b/src/main/java/im/puro/hello/HelloApplication.java new file mode 100644 index 0000000..ff48dda --- /dev/null +++ b/src/main/java/im/puro/hello/HelloApplication.java @@ -0,0 +1,25 @@ +package im.puro.hello; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@SpringBootApplication +@RestController +public class HelloApplication { + + public static void main(String[] args) { + SpringApplication.run(HelloApplication.class, args); + } + + @GetMapping("/") + public String hello() { + return "Hello from Puro DevOps! 🚀"; + } + + @GetMapping("/health") + public String health() { + return "OK"; + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..f5d8fa0 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,2 @@ +server.port=8080 +management.endpoints.web.exposure.include=health,info,prometheus diff --git a/src/test/java/im/puro/hello/HelloApplicationTests.java b/src/test/java/im/puro/hello/HelloApplicationTests.java new file mode 100644 index 0000000..feff9d4 --- /dev/null +++ b/src/test/java/im/puro/hello/HelloApplicationTests.java @@ -0,0 +1,11 @@ +package im.puro.hello; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class HelloApplicationTests { + @Test + void contextLoads() { + } +}