Skip to content

Commit 4750aeb

Browse files
committed
feat(user-service): initial commit
1 parent 964b74c commit 4750aeb

File tree

12 files changed

+217
-0
lines changed

12 files changed

+217
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/gradlew text eol=lf
2+
*.bat text eol=crlf
3+
*.jar binary

services/user-service/.gitignore

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
HELP.md
2+
.gradle
3+
build/
4+
!gradle/wrapper/gradle-wrapper.jar
5+
!**/src/main/**/build/
6+
!**/src/test/**/build/
7+
8+
### STS ###
9+
.apt_generated
10+
.classpath
11+
.factorypath
12+
.project
13+
.settings
14+
.springBeans
15+
.sts4-cache
16+
bin/
17+
!**/src/main/**/bin/
18+
!**/src/test/**/bin/
19+
20+
### IntelliJ IDEA ###
21+
.idea
22+
*.iws
23+
*.iml
24+
*.ipr
25+
out/
26+
!**/src/main/**/out/
27+
!**/src/test/**/out/
28+
29+
### NetBeans ###
30+
/nbproject/private/
31+
/nbbuild/
32+
/dist/
33+
/nbdist/
34+
/.nb-gradle/
35+
36+
### VS Code ###
37+
.vscode/

services/user-service/Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
FROM gradle:9.1.0-jdk25 AS builder
2+
3+
WORKDIR /home/gradle/project
4+
5+
COPY build.gradle settings.gradle ./
6+
COPY src ./src
7+
8+
RUN gradle clean build --no-daemon -x test
9+
10+
FROM eclipse-temurin:25-jre AS runtime
11+
12+
LABEL maintainer="partho.kr@proton.me" \
13+
version="1.0.0" \
14+
description="User service for HeapDog"
15+
16+
ENV JAVA_OPTS="" \
17+
SERVER_PORT=8080 \
18+
SPRING_PROFILES_ACTIVE="prod"
19+
20+
21+
RUN groupadd -r appgroup && useradd -r -g appgroup appuser
22+
23+
WORKDIR /app
24+
VOLUME /tmp
25+
26+
ARG JAR_FILE=build/libs/*.jar
27+
28+
COPY --from=builder --chown=appuser:appgroup /home/gradle/project/${JAR_FILE} app.jar
29+
30+
EXPOSE ${SERVER_PORT}
31+
32+
HEALTHCHECK --interval=30s --timeout=3s --start-period=30s --retries=3 \
33+
CMD curl -f http://localhost:${SERVER_PORT}/actuator/health || exit 1
34+
35+
USER appuser
36+
37+
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]

services/user-service/build.gradle

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
plugins {
2+
id 'java'
3+
id 'org.springframework.boot' version '4.0.0'
4+
id 'io.spring.dependency-management' version '1.1.7'
5+
}
6+
7+
group = 'io.heapdog'
8+
version = '0.0.1-SNAPSHOT'
9+
description = 'Demo project for Spring Boot'
10+
11+
java {
12+
toolchain {
13+
languageVersion = JavaLanguageVersion.of(25)
14+
}
15+
}
16+
17+
configurations {
18+
compileOnly {
19+
extendsFrom annotationProcessor
20+
}
21+
}
22+
23+
repositories {
24+
mavenCentral()
25+
}
26+
27+
ext {
28+
set('springCloudVersion', "2025.1.0")
29+
}
30+
31+
dependencies {
32+
implementation 'org.springframework.cloud:spring-cloud-starter-gateway-server-webmvc'
33+
compileOnly 'org.projectlombok:lombok'
34+
annotationProcessor 'org.projectlombok:lombok'
35+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
36+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
37+
}
38+
39+
dependencyManagement {
40+
imports {
41+
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
42+
}
43+
}
44+
45+
tasks.named('test') {
46+
useJUnitPlatform()
47+
}
44.6 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'user-service'
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.heapdog.userservice;
2+
3+
4+
import lombok.Builder;
5+
import lombok.Data;
6+
7+
@Data
8+
@Builder
9+
public class User {
10+
11+
private int id;
12+
private String name;
13+
private String email;
14+
15+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package io.heapdog.userservice;
2+
3+
4+
import org.springframework.web.bind.annotation.GetMapping;
5+
import org.springframework.web.bind.annotation.RequestMapping;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
import java.util.List;
9+
10+
@RestController
11+
@RequestMapping("/users")
12+
public class UserController {
13+
14+
private final List<User> users = List.of(
15+
User.builder().id(1).name("User1").build(),
16+
User.builder().id(2).name("User2").build()
17+
);
18+
19+
@GetMapping
20+
public List<User> getAllUsers() {
21+
return users;
22+
}
23+
24+
25+
@GetMapping("/hostname")
26+
public String getHostName() {
27+
try {
28+
return java.net.InetAddress.getLocalHost().getHostName();
29+
} catch (Exception e) {
30+
return "unknown";
31+
}
32+
}
33+
34+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package io.heapdog.userservice;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class UserServiceApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(UserServiceApplication.class, args);
11+
}
12+
13+
}

0 commit comments

Comments
 (0)