Skip to content

Commit 9e4b34f

Browse files
committed
[chore] jib 설정분기
1 parent ff79c7f commit 9e4b34f

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

.github/workflows/deploy-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
env:
1414
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
1515
DOCKER_DEV_REPO: ${{ secrets.DOCKER_DEV_REPO }}
16-
CONTAINER_PORT_DEV: ${{ secrets.CONTAINER_PORT_DEV }}
16+
CONTAINER_PORT: ${{ secrets.CONTAINER_PORT_DEV }}
1717
steps:
1818
- name: 리포지토리를 가져옵니다
1919
uses: actions/checkout@v4

.github/workflows/deploy-test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ jobs:
1212
runs-on: ubuntu-latest
1313
env:
1414
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
15-
DOCKER_DEV_REPO: ${{ secrets.DOCKER_TEST_REPO }}
16-
CONTAINER_PORT_DEV: ${{ secrets.CONTAINER_PORT_DEV }}
15+
DOCKER_TEST_REPO: ${{ secrets.DOCKER_TEST_REPO }}
16+
CONTAINER_PORT: ${{ secrets.CONTAINER_PORT_DEV }}
1717
steps:
1818
- name: 리포지토리를 가져옵니다
1919
uses: actions/checkout@v4
@@ -46,7 +46,7 @@ jobs:
4646
runs-on: ubuntu-latest
4747
env:
4848
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
49-
DOCKER_DEV_REPO: ${{ secrets.DOCKER_TEST_REPO }}
49+
DOCKER_TEST_REPO: ${{ secrets.DOCKER_TEST_REPO }}
5050
steps:
5151
- name: AWS Credentials 설정
5252
uses: aws-actions/configure-aws-credentials@v4
@@ -55,7 +55,7 @@ jobs:
5555
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
5656
aws-region: ap-northeast-2
5757

58-
- name: 개발 서버 배포
58+
- name: 테스트 서버 배포
5959
uses: appleboy/ssh-action@v1.0.3
6060
with:
6161
host: ${{ secrets.TEST_AWS_EC2_PUBLIC_IP }}

build.gradle

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

94-
project.ext {
95-
dockerUser = System.getenv('DOCKER_USERNAME')
96-
containerPort = System.getenv('CONTAINER_PORT') ?: '8081'
97-
activeProfile = System.getProperty('spring.profiles.active') ?: System.getenv('ACTIVE_PROFILE') ?: 'dev'
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-
}
94+
def isTestEnvironment = System.getenv('DOCKER_TEST_REPO') != null
11195

11296
jib {
11397
from {
11498
image = 'eclipse-temurin:21-jre-alpine'
11599
}
116100
to {
117-
image = "${dockerUser}/${getDockerImage()}"
118-
tags = ["latest"]
101+
image = System.getenv('DOCKER_USERNAME') + '/' + (isTestEnvironment ? System.getenv('DOCKER_TEST_REPO') : System.getenv('DOCKER_DEV_REPO'))
102+
tags = ['latest']
119103
}
120104
container {
121-
jvmFlags = ["-Dspring.profiles.active=${activeProfile}", '-Dfile.encoding=UTF-8']
122-
ports = [containerPort]
105+
jvmFlags = ["-Dspring.profiles.active=${isTestEnvironment ? 'test' : 'dev'}", '-Dfile.encoding=UTF-8']
106+
ports = ['8081']
123107
}
124108
}

0 commit comments

Comments
 (0)