Skip to content

Commit b7b8a5d

Browse files
committed
2 parents 179c199 + fc26061 commit b7b8a5d

File tree

58 files changed

+2333
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2333
-0
lines changed

.gitattributes

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

.github/pull_request_template.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## 📌 관련 이슈
2+
- 관련된 이슈 번호를 적어주세요. (예: #12)
3+
4+
## ✨ 변경 사항
5+
- 이번 PR에서 변경된 주요 내용을 간단히 작성해주세요.
6+
- 기능 추가/수정/삭제
7+
- 버그 수정
8+
- 리팩토링
9+
10+
## ✅ 체크리스트
11+
- [ ] 코드 스타일 가이드 준수
12+
- [ ] 로컬에서 정상 동작 확인
13+
- [ ] 관련 테스트 추가/수정 완료
14+
- [ ] 문서화 필요 시 업데이트 완료
15+
16+
## 📸 스크린샷 (선택)
17+
- UI 변경이 있는 경우 첨부해주세요.
18+
19+
## 📢 기타 참고 사항
20+
- 리뷰어가 알아야 할 추가 사항을 적어주세요.

.github/workflows/deploy-helm.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Auth-Service Image Build
2+
3+
env:
4+
SERVICE_NAME: auth-service
5+
BUILD_ID: ${{ github.sha }}-${{ github.run_id }}
6+
HELM_VALUE: auth-service/values.yaml
7+
HELM_BRANCH: main
8+
INFRA_REPO: ${{ secrets.INFRA_REPO }}
9+
10+
on:
11+
push:
12+
branches: [ "main" ]
13+
14+
jobs:
15+
build-and-deploy:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v3
21+
22+
- name: Set up JDK 17
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: '17'
26+
distribution: 'temurin'
27+
28+
# Gradle 빌드
29+
- name: Build with Gradle
30+
run: ./gradlew clean build -x test
31+
32+
# Docker 로그인
33+
- name: Log in to Docker Hub
34+
uses: docker/login-action@v3
35+
with:
36+
username: ${{ secrets.DOCKER_USERNAME }}
37+
password: ${{ secrets.DOCKER_PAT }}
38+
39+
# 태그명 변수화 + 짧게 만들기
40+
- name: Set Image Version Tag
41+
id: vars
42+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
43+
44+
# Docker Image 빌드 및 푸시
45+
- name: Build and push image to Docker Hub
46+
env:
47+
IMAGE_TAG: docker.io/${{ secrets.DOCKER_USERNAME }}/${{ env.SERVICE_NAME }}:${{ env.BUILD_ID }}
48+
run: |
49+
docker build -f ./Dockerfile -t "$IMAGE_TAG" .
50+
docker push "$IMAGE_TAG"
51+
52+
# ArgoCD가 참조하는 Repository로 checkout
53+
- name: Checkout Helm Repository
54+
uses: actions/checkout@v4
55+
with:
56+
repository: ${{ env.INFRA_REPO }}
57+
path: helm-chart
58+
ref: ${{ env.HELM_BRANCH }}
59+
token: ${{ secrets.GH_PAT }}
60+
61+
- name: Change Image tag of the Helm Chart
62+
uses: mikefarah/yq@v4.34.1
63+
with:
64+
cmd: yq -i '.image.tag = "${{ env.BUILD_ID }}"' helm-chart/${{ env.HELM_VALUE }}
65+
66+
- name: Commit and Push Helm Chart Changes
67+
run: |
68+
cd helm-chart
69+
git config --local user.email "githubaction@gmail.com"
70+
git config --local user.name "githubaction"
71+
git add ${{ env.HELM_VALUE }}
72+
git commit -m "Update ${SERVICE_NAME} image tag to ${{ env.BUILD_ID }}" || echo "No changes to commit"
73+
74+
# Push with retry logic
75+
attempts=0
76+
max_attempts=3
77+
78+
while [ $attempts -lt $max_attempts ]; do
79+
if git push origin ${{ env.HELM_BRANCH }}; then
80+
echo "Push successful!"
81+
break
82+
else
83+
echo "Push failed. Attempting rebase with remote branch."
84+
git pull --rebase origin ${{ env.HELM_BRANCH }}
85+
attempts=$((attempts+1))
86+
if [ $attempts -eq $max_attempts ]; then
87+
echo "Push failed after $max_attempts attempts"
88+
exit 1
89+
fi
90+
echo "Retrying push..."
91+
fi
92+
done

.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/

Dockerfile

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Multi-stage build for optimization
2+
FROM gradle:8.4-jdk17 AS builder
3+
4+
WORKDIR /app
5+
COPY build.gradle settings.gradle ./
6+
COPY gradle/ gradle/
7+
RUN gradle dependencies --no-daemon
8+
9+
COPY src/ src/
10+
RUN gradle build --no-daemon -x test
11+
12+
# Runtime stage
13+
FROM eclipse-temurin:17-jre-jammy
14+
15+
# Create non-root user for security
16+
RUN groupadd -r appuser && useradd -r -g appuser appuser
17+
18+
# Install necessary packages
19+
RUN apt-get update && apt-get install -y \
20+
curl \
21+
&& rm -rf /var/lib/apt/lists/*
22+
23+
# Set working directory
24+
WORKDIR /app
25+
26+
# Copy jar file from builder stage
27+
COPY --from=builder /app/build/libs/auth-service-0.0.1-SNAPSHOT.jar app.jar
28+
29+
# Change ownership to non-root user
30+
RUN chown -R appuser:appuser /app
31+
USER appuser
32+
33+
# Health check
34+
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
35+
CMD curl -f http://localhost:8080/actuator/health || exit 1
36+
37+
# Expose port
38+
EXPOSE 8080
39+
40+
# JVM optimization for containers
41+
ENTRYPOINT ["java", \
42+
"-XX:+UseContainerSupport", \
43+
"-XX:MaxRAMPercentage=75.0", \
44+
"-XX:+UseG1GC", \
45+
"-XX:+UseStringDeduplication", \
46+
"-Djava.security.egd=file:/dev/./urandom", \
47+
"-jar", "app.jar"]

build.gradle

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
plugins {
2+
id 'java'
3+
id 'org.springframework.boot' version '3.5.6'
4+
id 'io.spring.dependency-management' version '1.1.7'
5+
}
6+
7+
group = 'com.project'
8+
version = '0.0.1-SNAPSHOT'
9+
description = 'auth-service'
10+
11+
java {
12+
toolchain { languageVersion = JavaLanguageVersion.of(17) }
13+
}
14+
15+
repositories { mavenCentral() }
16+
17+
configurations {
18+
compileOnly {
19+
extendsFrom annotationProcessor
20+
}
21+
}
22+
23+
dependencies {
24+
// Spring
25+
developmentOnly 'org.springframework.boot:spring-boot-devtools'
26+
implementation 'org.springframework.boot:spring-boot-starter-web'
27+
implementation 'org.springframework.boot:spring-boot-starter-security'
28+
implementation 'org.springframework.boot:spring-boot-starter-validation'
29+
implementation 'org.springframework.boot:spring-boot-starter-actuator'
30+
implementation 'io.micrometer:micrometer-registry-prometheus'
31+
32+
// Apache HttpClient5
33+
implementation 'org.apache.httpcomponents.client5:httpclient5:5.3.1'
34+
35+
// Kafka
36+
implementation "org.springframework.kafka:spring-kafka"
37+
38+
// Lombok
39+
compileOnly 'org.projectlombok:lombok'
40+
annotationProcessor 'org.projectlombok:lombok'
41+
42+
// Redis / Cache
43+
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
44+
implementation 'org.springframework.boot:spring-boot-starter-cache'
45+
46+
// JWT
47+
implementation 'io.jsonwebtoken:jjwt-api:0.11.2'
48+
implementation 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.0'
49+
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.0'
50+
runtimeOnly 'io.jsonwebtoken:jjwt-impl:0.11.2'
51+
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.2'
52+
53+
// Swagger
54+
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'
55+
56+
testImplementation 'org.springframework.boot:spring-boot-starter-test'
57+
testImplementation 'org.springframework.security:spring-security-test'
58+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
59+
}
60+
61+
tasks.named('test') { useJUnitPlatform() }

gradle/wrapper/gradle-wrapper.jar

42.7 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-8.14.3-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)