Skip to content

Commit c5af26e

Browse files
authored
Merge pull request #49 from prgrms-web-devcourse-final-project/develop
Chore[deploy]: 중단배포
2 parents a19b675 + c1263de commit c5af26e

File tree

9 files changed

+255
-4
lines changed

9 files changed

+255
-4
lines changed

.github/workflows/CI-CD_Pipeline.yml

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,22 +185,54 @@ jobs:
185185
deploy:
186186
needs: docker-build
187187
runs-on: ubuntu-latest
188+
if: github.ref == 'refs/heads/main' # ✅ main 브랜치일 때만 실행
188189
env:
189190
DOCKER_IMAGE_NAME: balaw
190191
steps:
192+
- name: Create prod .env file
193+
run: |
194+
cat > .env << 'EOF'
195+
SPRING_PROFILES_ACTIVE=prod
196+
PROD_DATASOURCE_URL=jdbc:mysql://mysql_1:3306/${{ secrets.DB_NAME }}
197+
PROD_DATASOURCE_USERNAME=${{ secrets.DB_USER }}
198+
PROD_DATASOURCE_PASSWORD=${{ secrets.DB_PASSWORD }}
199+
200+
PROD_REDIS_HOST=redis_1
201+
PROD_REDIS_PORT=6379
202+
PROD_REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }}
203+
EOF
204+
191205
- name: AWS SSM Send-Command
192206
uses: peterkimzz/aws-ssm-send-command@master
193207
id: ssm
194208
with:
195209
aws-region: ${{ secrets.AWS_REGION }}
196210
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
197211
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
198-
instance-ids: "i-006c2e31391fac356"
212+
instance-ids: "i-094fd5f8988b7330b"
199213
working-directory: /
200214
comment: Deploy
201215
command: |
216+
# EC2 내부에서 prod.env 파일 생성
217+
cat > /home/ec2-user/prod.env << 'EOF'
218+
SPRING_PROFILES_ACTIVE=prod
219+
220+
PROD_DATASOURCE_URL=jdbc:mysql://mysql_1:3306/${{ secrets.DB_NAME }}
221+
PROD_DATASOURCE_USERNAME=${{ secrets.DB_USER }}
222+
PROD_DATASOURCE_PASSWORD=${{ secrets.DB_PASSWORD }}
223+
224+
PROD_REDIS_HOST=redis_1
225+
PROD_REDIS_PORT=6379
226+
PROD_REDIS_PASSWORD=${{ secrets.REDIS_PASSWORD }}
227+
EOF
228+
229+
# 최신 이미지 pull & 컨테이너 실행
202230
docker pull ghcr.io/doohyojeong/${{ env.DOCKER_IMAGE_NAME }}:latest
203231
docker stop app1 2>/dev/null
204232
docker rm app1 2>/dev/null
205-
docker run -d --name app1 -p 8080:8080 ghcr.io/doohyojeong/${{ env.DOCKER_IMAGE_NAME }}:latest
206-
docker rmi $(docker images -f "dangling=true" -q)
233+
docker run --env-file /home/ec2-user/prod.env -d --name app1 -p 8080:8080 \
234+
ghcr.io/doohyojeong/${{ env.DOCKER_IMAGE_NAME }}:latest
235+
236+
# dangling image 정리 + .env 삭제
237+
docker rmi $(docker images -f "dangling=true" -q)
238+
rm -f /home/ec2-user/prod.env

backend/Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ WORKDIR /app
2525

2626
# 첫 번째 스테이지에서 빌드된 JAR 파일 복사
2727
COPY --from=builder /app/build/libs/*.jar app.jar
28-
COPY --from=builder /app/.env .env
2928

3029
# 실행할 JAR 파일 지정
3130
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-jar", "app.jar"]
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.ai.lawyer.domain.law.entity;
2+
3+
import com.fasterxml.jackson.annotation.JsonBackReference;
4+
import com.fasterxml.jackson.annotation.JsonIgnore;
5+
import com.fasterxml.jackson.annotation.JsonManagedReference;
6+
import jakarta.persistence.*;
7+
import lombok.Data;
8+
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
@Entity
13+
@Data
14+
public class Hang {
15+
@Id
16+
@GeneratedValue(strategy = GenerationType.IDENTITY)
17+
@JsonIgnore
18+
private Long id;
19+
20+
@Column(nullable = true, columnDefinition = "TEXT")
21+
String content;
22+
23+
@ManyToOne
24+
@JoinColumn(name = "jo_id")
25+
@JsonBackReference
26+
private Jo jo;
27+
28+
@OneToMany(mappedBy = "hang")
29+
@JsonManagedReference
30+
private List<Ho> hoList = new ArrayList<>();
31+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.ai.lawyer.domain.law.entity;
2+
3+
import com.fasterxml.jackson.annotation.JsonBackReference;
4+
import com.fasterxml.jackson.annotation.JsonIgnore;
5+
import jakarta.persistence.*;
6+
import lombok.Data;
7+
8+
@Entity
9+
@Data
10+
public class Ho {
11+
@Id
12+
@GeneratedValue(strategy = GenerationType.IDENTITY)
13+
@JsonIgnore
14+
private Long id;
15+
16+
@Column(nullable = true, columnDefinition = "TEXT")
17+
String content;
18+
19+
@ManyToOne
20+
@JoinColumn(name = "hang_id")
21+
@JsonBackReference
22+
private Hang hang;
23+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.ai.lawyer.domain.law.entity;
2+
3+
import com.fasterxml.jackson.annotation.JsonBackReference;
4+
import com.fasterxml.jackson.annotation.JsonIgnore;
5+
import com.fasterxml.jackson.annotation.JsonManagedReference;
6+
import jakarta.persistence.*;
7+
import lombok.Data;
8+
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
@Entity
13+
@Data
14+
public class Jang {
15+
@Id
16+
@GeneratedValue(strategy = GenerationType.IDENTITY)
17+
@JsonIgnore
18+
private Long id;
19+
20+
@Column(nullable = true, columnDefinition = "TEXT")
21+
String content;
22+
23+
@ManyToOne
24+
@JoinColumn(name = "law_id")
25+
@JsonBackReference
26+
private Law law;
27+
28+
@OneToMany(mappedBy = "jang")
29+
@JsonManagedReference
30+
private List<Jo> joList = new ArrayList<>();
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.ai.lawyer.domain.law.entity;
2+
3+
import com.fasterxml.jackson.annotation.JsonBackReference;
4+
import com.fasterxml.jackson.annotation.JsonIgnore;
5+
import com.fasterxml.jackson.annotation.JsonManagedReference;
6+
import jakarta.persistence.*;
7+
import lombok.Data;
8+
9+
import java.util.ArrayList;
10+
import java.util.List;
11+
12+
@Entity
13+
@Data
14+
public class Jo {
15+
@Id
16+
@GeneratedValue(strategy = GenerationType.IDENTITY)
17+
@JsonIgnore
18+
private Long id;
19+
20+
@Column(nullable = true, columnDefinition = "TEXT")
21+
String content;
22+
23+
@ManyToOne
24+
@JoinColumn(name = "jang_id")
25+
@JsonBackReference
26+
private Jang jang;
27+
28+
@OneToMany(mappedBy = "jo")
29+
@JsonManagedReference
30+
private List<Hang> hangList = new ArrayList<>();
31+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.ai.lawyer.domain.law.entity;
2+
3+
4+
import com.fasterxml.jackson.annotation.JsonIgnore;
5+
import com.fasterxml.jackson.annotation.JsonManagedReference;
6+
import jakarta.persistence.*;
7+
import lombok.Data;
8+
9+
import java.time.LocalDate;
10+
import java.util.ArrayList;
11+
import java.util.List;
12+
13+
@Entity
14+
@Data
15+
public class Law {
16+
@Id
17+
@GeneratedValue(strategy = GenerationType.IDENTITY)
18+
@JsonIgnore
19+
private Long id;
20+
21+
private String lawName; // 법령명
22+
23+
private String lawField; // 법령분야
24+
25+
private String ministry; // 소관부처
26+
27+
private String promulgationNumber; // 공포번호
28+
29+
private LocalDate promulgationDate; // 공포일자
30+
31+
private LocalDate enforcementDate; // 시행일자
32+
33+
@OneToMany(mappedBy = "law")
34+
@JsonManagedReference
35+
private List<Jang> jangList = new ArrayList<>();
36+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.ai.lawyer.domain.precedent.entity;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnore;
4+
import jakarta.persistence.*;
5+
import lombok.Data;
6+
7+
import java.time.LocalDate;
8+
9+
@Entity
10+
@Data
11+
public class Precedent {
12+
13+
@Id
14+
@GeneratedValue(strategy = GenerationType.IDENTITY)
15+
@JsonIgnore
16+
private Long id;
17+
18+
private String precedentNumber; // 판례일련번호
19+
20+
@Lob
21+
@Column(columnDefinition = "TEXT")
22+
private String caseName; // 사건명
23+
24+
private String caseNumber; // 사건번호
25+
26+
private LocalDate sentencingDate; // 선고일자
27+
28+
private String sentence; // 선고
29+
30+
private String courtName; // 법원명
31+
32+
private String courtTypeCode; // 법원종류코드
33+
34+
private String caseTypeName; // 사건종류명
35+
36+
private String caseTypeCode; // 사건종류코드
37+
38+
private String typeOfJudgment; // 판결유형
39+
40+
@Lob
41+
@Column(columnDefinition = "LONGTEXT")
42+
private String notice; // 판시사항
43+
44+
@Lob
45+
@Column(columnDefinition = "LONGTEXT")
46+
private String summaryOfTheJudgment; // 판결요지
47+
48+
@Lob
49+
@Column(columnDefinition = "LONGTEXT")
50+
private String referenceArticle; // 참조조문
51+
52+
@Lob
53+
@Column(columnDefinition = "LONGTEXT")
54+
private String referencePrecedent; // 참조판례
55+
56+
@Lob
57+
@Column(columnDefinition = "LONGTEXT")
58+
private String precedentContent; // 판례내용
59+
}

infra/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,15 @@ docker run -d \
228228
-v /dockerProjects/npm_1/volumes/etc/letsencrypt:/etc/letsencrypt \
229229
jc21/nginx-proxy-manager:latest
230230
231+
# redis 설치
232+
docker run -d \
233+
--name=redis_1 \
234+
--restart unless-stopped \
235+
--network common \
236+
-p 6379:6379 \
237+
-e TZ=Asia/Seoul \
238+
redis --requirepass ${var.password_1}
239+
231240
# mysql 설치
232241
docker run -d \
233242
--name mysql_1 \

0 commit comments

Comments
 (0)