Skip to content

Commit 430f18f

Browse files
committed
[chore] jib 설정분기
1 parent f5a7770 commit 430f18f

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

.github/workflows/deploy-dev.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
1515
DOCKER_DEV_REPO: ${{ secrets.DOCKER_DEV_REPO }}
1616
CONTAINER_PORT_DEV: ${{ secrets.CONTAINER_PORT_DEV }}
17+
ACTIVE_PROFILE: 'dev'
1718
steps:
1819
- name: 리포지토리를 가져옵니다
1920
uses: actions/checkout@v4

.github/workflows/deploy-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
1515
DOCKER_DEV_REPO: ${{ secrets.DOCKER_TEST_REPO }}
1616
CONTAINER_PORT_DEV: ${{ secrets.CONTAINER_PORT_DEV }}
17+
ACTIVE_PROFILE: 'test'
1718
steps:
1819
- name: 리포지토리를 가져옵니다
1920
uses: actions/checkout@v4

build.gradle

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,34 @@ tasks.register('copySecret', Copy) {
9191
into('src/main/resources')
9292
}
9393

94-
def dockerUser = System.getenv('DOCKER_USERNAME')
95-
def dockerImage = System.getenv('DOCKER_DEV_REPO')
96-
def containerPort = System.getenv('CONTAINER_PORT_DEV')
94+
project.ext {
95+
dockerUser = System.getenv('DOCKER_USERNAME')
96+
activeProfile = System.getenv('ACTIVE_PROFILE') ?: 'dev'
97+
containerPort = System.getenv('CONTAINER_PORT') ?: '8081'
98+
}
99+
100+
101+
def getDockerImage() {
102+
switch (activeProfile) {
103+
case 'dev':
104+
return System.getenv('DOCKER_DEV_REPO')
105+
case 'test':
106+
return System.getenv('DOCKER_TEST_REPO')
107+
default:
108+
return System.getenv('DOCKER_DEV_REPO')
109+
}
110+
}
97111

98112
jib {
99113
from {
100114
image = 'eclipse-temurin:21-jre-alpine'
101115
}
102116
to {
103-
image = "${dockerUser}/${dockerImage}"
104-
tags = ['latest']
117+
image = "${dockerUser}/${getDockerImage()}"
118+
tags = ["latest"]
105119
}
106120
container {
107-
jvmFlags = ['-Dspring.profiles.active=dev', '-Dfile.encoding=UTF-8']
121+
jvmFlags = ["-Dspring.profiles.active=${activeProfile}", '-Dfile.encoding=UTF-8']
108122
ports = [containerPort]
109123
}
110124
}

0 commit comments

Comments
 (0)