Skip to content

Commit

Permalink
chore: admin-service 매니패스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
CChuYong committed Sep 7, 2024
1 parent 446e70d commit 09b97a1
Show file tree
Hide file tree
Showing 3 changed files with 195 additions and 3 deletions.
78 changes: 78 additions & 0 deletions .github/workflows/admin-service-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: 어드민 서비스 DEV 빌드 후 도커허브에 올리기
on:
push:
branches: [ 'dev' ]
paths:
- 'admin-service/**' # Admin Service 모듈 변경
- '.github/workflows/admin-service-dev.yaml' # Admin Service 워크플로우 변경

env:
SPRING_PROFILE: dev
IMAGE_NAME: spinachpasta/admin-service-dev
MODULE_PATH: admin-service
SERVER_PORT: 8080
GIT_ENVIRONMENT: dev (admin-service)

concurrency:
group: admin-service

jobs:
prepare-variables:
name: 환경변수 준비하기
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.setup-env.outputs.image-tag }}
module-path: ${{ steps.setup-env.outputs.module-path }}
spring-profile: ${{ steps.setup-env.outputs.spring-profile }}
server-port: ${{ steps.setup-env.outputs.server-port }}
image-name: ${{ steps.setup-env.outputs.image-name }}
git-environment: ${{ steps.setup-env.outputs.git-environment }}
steps:
- name: GitHub 에서 레포 받아오기
uses: actions/checkout@v3

- name: 환경변수 출력하기
id: setup-env
run: |
echo "image-tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "module-path=$MODULE_PATH" >> $GITHUB_OUTPUT
echo "spring-profile=$SPRING_PROFILE" >> $GITHUB_OUTPUT
echo "server-port=$SERVER_PORT" >> $GITHUB_OUTPUT
echo "image-name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "git-environment=$GIT_ENVIRONMENT" >> $GITHUB_OUTPUT
call-build-workflow:
if: github.event_name == 'push'
needs: [ prepare-variables ]
name: 이미지 빌드 & 푸쉬
uses: ./.github/workflows/jib-build.yaml
permissions:
id-token: write
contents: read
with:
spring-profile: ${{ needs.prepare-variables.outputs.spring-profile }}
server-port: ${{ needs.prepare-variables.outputs.server-port }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
module-path: ${{ needs.prepare-variables.outputs.module-path }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}


call-deploy-workflow:
needs: [ prepare-variables, call-build-workflow ]
name: ArgoCD로 배포하기
uses: ./.github/workflows/argocd-deploy.yaml
permissions:
contents: write
with:
argocd-repo-name: YAPP-Github/mafoo-argocd-manifest
overlay-name: ${{ needs.prepare-variables.outputs.spring-profile }}
service-name: ${{ needs.prepare-variables.outputs.module-path }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
environment: ${{ needs.prepare-variables.outputs.git-environment }}
default-image-name: spinachpasta/admin-service
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
78 changes: 78 additions & 0 deletions .github/workflows/admin-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: 어드민 서비스 빌드 후 도커허브에 올리기
on:
push:
branches: [ 'main' ]
paths:
- 'admin-service/**' # Admin Service 모듈 변경
- '.github/workflows/admin-service.yaml' # Admin Service 워크플로우 변경

env:
SPRING_PROFILE: prod
IMAGE_NAME: spinachpasta/admin-service
MODULE_PATH: admin-service
SERVER_PORT: 8080
GIT_ENVIRONMENT: prod (admin-service)

concurrency:
group: admin-service

jobs:
prepare-variables:
name: 환경변수 준비하기
runs-on: ubuntu-latest
outputs:
image-tag: ${{ steps.setup-env.outputs.image-tag }}
module-path: ${{ steps.setup-env.outputs.module-path }}
spring-profile: ${{ steps.setup-env.outputs.spring-profile }}
server-port: ${{ steps.setup-env.outputs.server-port }}
image-name: ${{ steps.setup-env.outputs.image-name }}
git-environment: ${{ steps.setup-env.outputs.git-environment }}
steps:
- name: GitHub 에서 레포 받아오기
uses: actions/checkout@v3

- name: 환경변수 출력하기
id: setup-env
run: |
echo "image-tag=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "module-path=$MODULE_PATH" >> $GITHUB_OUTPUT
echo "spring-profile=$SPRING_PROFILE" >> $GITHUB_OUTPUT
echo "server-port=$SERVER_PORT" >> $GITHUB_OUTPUT
echo "image-name=$IMAGE_NAME" >> $GITHUB_OUTPUT
echo "git-environment=$GIT_ENVIRONMENT" >> $GITHUB_OUTPUT
call-build-workflow:
if: github.event_name == 'push'
needs: [ prepare-variables ]
name: 이미지 빌드 & 푸쉬
uses: ./.github/workflows/jib-build.yaml
permissions:
id-token: write
contents: read
with:
spring-profile: ${{ needs.prepare-variables.outputs.spring-profile }}
server-port: ${{ needs.prepare-variables.outputs.server-port }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
module-path: ${{ needs.prepare-variables.outputs.module-path }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}


call-deploy-workflow:
needs: [ prepare-variables, call-build-workflow ]
name: ArgoCD로 배포하기
uses: ./.github/workflows/argocd-deploy.yaml
permissions:
contents: write
with:
argocd-repo-name: YAPP-Github/mafoo-argocd-manifest
overlay-name: ${{ needs.prepare-variables.outputs.spring-profile }}
service-name: ${{ needs.prepare-variables.outputs.module-path }}
image-name: ${{ needs.prepare-variables.outputs.image-name }}
image-tag: ${{ needs.prepare-variables.outputs.image-tag }}
environment: ${{ needs.prepare-variables.outputs.git-environment }}
default-image-name: spinachpasta/admin-service
secrets:
PAT_TOKEN: ${{ secrets.PAT_TOKEN }}
42 changes: 39 additions & 3 deletions admin-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
id("org.springframework.boot") version "3.3.3"
id("io.spring.dependency-management") version "1.1.6"
kotlin("plugin.jpa") version "1.9.25"
id("com.google.cloud.tools.jib") version "3.4.2"
}

group = "kr.mafoo"
Expand All @@ -20,16 +21,18 @@ repositories {
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-security")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
runtimeOnly("com.mysql:mysql-connector-j")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testImplementation("org.springframework.security:spring-security-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation("io.projectreactor.kotlin:reactor-kotlin-extensions")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-reactor")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core")
}

kotlin {
Expand All @@ -41,3 +44,36 @@ kotlin {
tasks.withType<Test> {
useJUnitPlatform()
}

jib {
val activeProfile: String? = System.getenv("SPRING_PROFILES_ACTIVE")
val imageName: String? = System.getenv("IMAGE_NAME")
val imageTag: String? = System.getenv("IMAGE_TAG")
val serverPort: String = System.getenv("SERVER_PORT") ?: "8080"
from {
image = "amazoncorretto:17-alpine3.17-jdk"
}
to {
image = imageName
tags = setOf(imageTag, "latest")
}
container {
jvmFlags =
listOf(
"-Dspring.profiles.active=$activeProfile",
"-Dserver.port=$serverPort",
"-Djava.security.egd=file:/dev/./urandom",
"-Dfile.encoding=UTF-8",
"-Duser.timezone=Asia/Seoul",
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UseContainerSupport",
"-XX:+UseG1GC",
"-XX:InitialHeapSize=1g",
"-XX:MaxHeapSize=1g",
"-XX:+DisableExplicitGC", // System.gc() 방어
"-server",
)
ports = listOf(serverPort)
}
}

0 comments on commit 09b97a1

Please sign in to comment.