Skip to content

Commit c779a09

Browse files
author
nimuy99
committed
#29 Fix: deploy test 16
1 parent 5381758 commit c779a09

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ jobs:
1919
java-version: '17'
2020
cache: 'gradle'
2121

22-
- name: Create application.yml
22+
- name: Create application.yml in build context
2323
run: |
2424
mkdir -p src/main/resources
25-
echo "${{ secrets.APPLICATION_YML }}" | tee src/main/resources/application.yml
25+
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml
2626
shell: bash
2727

2828
- name: Build with Gradle
@@ -54,22 +54,12 @@ jobs:
5454
echo "$EC2_SSH_KEY" > private_key.pem
5555
chmod 600 private_key.pem
5656
57-
ssh -i private_key.pem -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_HOST << 'EOF'
58-
sudo mkdir -p /home/$EC2_USERNAME/.config/$MY_APP
59-
sudo chmod 700 /home/$EC2_USERNAME/.config/$MY_APP
60-
cat <<EOT | sudo tee /home/$EC2_USERNAME/.config/$MY_APP/application.yml > /dev/null
61-
${{ secrets.APPLICATION_YML }}
62-
EOT
63-
sudo chmod 600 /home/$EC2_USERNAME/.config/$MY_APP/application.yml
64-
EOF
65-
6657
ssh -i private_key.pem -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_HOST "
6758
docker pull $DOCKER_USERNAME/$MY_APP:latest
6859
docker stop $MY_APP || true
6960
docker rm $MY_APP || true
7061
docker run -d -p 8080:8080 --name $MY_APP \
71-
-e SPRING_CONFIG_LOCATION=file:/home/$EC2_USERNAME/.config/$MY_APP/application.yml \
7262
$DOCKER_USERNAME/$MY_APP:latest
73-
"
63+
"
7464
7565
rm -f private_key.pem

Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,28 @@ FROM bellsoft/liberica-openjdk-alpine:17 AS builder
33

44
WORKDIR /app
55

6+
# Gradle 관련 파일 복사 및 빌드
67
COPY gradlew build.gradle settings.gradle /app/
78
COPY gradle /app/gradle
8-
99
RUN chmod +x gradlew
1010
RUN ./gradlew dependencies --no-daemon
1111

12+
# 프로젝트 전체 복사 및 빌드 실행
1213
COPY . .
1314
RUN ./gradlew clean build -x test --no-daemon
1415

15-
1616
# Run stage
1717
FROM bellsoft/liberica-openjdk-alpine:17
1818

1919
WORKDIR /app
2020

21+
# JAR 파일 복사
2122
COPY --from=builder /app/build/libs/*.jar app.jar
2223

24+
# GitHub Actions에서 생성한 `application.yml`을 컨테이너 내부로 복사
25+
COPY src/main/resources/application.yml /app/config/application.yml
26+
2327
EXPOSE 8080
2428

25-
ENTRYPOINT ["java", "-jar", "app.jar"]
29+
# Spring Boot가 설정 파일을 읽을 수 있도록 `SPRING_CONFIG_LOCATION` 지정
30+
ENTRYPOINT ["java", "-jar", "app.jar", "--spring.config.location=/app/config/application.yml"]

0 commit comments

Comments
 (0)