Skip to content

Commit bc0c998

Browse files
authored
[Feat]: AWS 인프라 구축 및 도메인 설정
### 인프라 (Terraform) - AWS 리소스 구성 (VPC, EC2, RDS, ECR) - Auto Scaling Group 설정 (t3.micro × 1) - RDS MySQL 설정 (db.t3.micro) - Security Group 구성 (HTTP/HTTPS/SSH 허용) ### 도메인 및 SSL - Route 53 DNS 설정 (api.bid-market.shop) - Let's Encrypt SSL 인증서 적용 - Nginx 리버스 프록시 설정 ### 애플리케이션 설정 - MySQL JDBC 드라이버 추가 - application-prod.yml 환경 변수 설정 - CORS 도메인 추가 (bid-market.shop) - Docker Compose Redis 추가 ### 참고 - Elastic IP: 15.165.154.40 - API 엔드포인트: https://api.bid-market.shop
2 parents e23e54d + 9049cd6 commit bc0c998

File tree

12 files changed

+941
-9
lines changed

12 files changed

+941
-9
lines changed

.gitignore

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,23 @@ db_dev.mv.db
4141
db_dev.trace.db
4242
src/main/generated/
4343
k6-tests/results
44+
*.pem
45+
*.key
4446

4547
### env ###
4648
.env
47-
*.env
49+
*.env
50+
### Terraform ###
51+
**/.terraform/*
52+
*.tfstate
53+
*.tfstate.*
54+
crash.log
55+
crash.*.log
56+
*.tfvars
57+
!terraform.tfvars.example
58+
override.tf
59+
override.tf.json
60+
*_override.tf
61+
*_override.tf.json
62+
.terraformrc
63+
terraform.rc

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Build stage
2+
FROM gradle:8.5-jdk21 AS builder
3+
4+
WORKDIR /app
5+
6+
# Copy Gradle files
7+
COPY build.gradle.kts settings.gradle.kts ./
8+
COPY gradle gradle
9+
10+
# Download dependencies
11+
RUN gradle dependencies --no-daemon || true
12+
13+
# Copy source code
14+
COPY src ./src
15+
16+
# Build application
17+
RUN gradle clean build -x test --no-daemon
18+
19+
# Runtime stage
20+
FROM eclipse-temurin:21-jre-alpine
21+
22+
WORKDIR /app
23+
24+
# Add non-root user
25+
RUN addgroup -S spring && adduser -S spring -G spring
26+
USER spring:spring
27+
28+
# Copy built jar from builder
29+
COPY --from=builder /app/build/libs/*.jar app.jar
30+
31+
# Expose port
32+
EXPOSE 8080
33+
34+
# Health check
35+
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
36+
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/actuator/health || exit 1
37+
38+
# Run application
39+
ENTRYPOINT ["java", \
40+
"-XX:+UseContainerSupport", \
41+
"-XX:MaxRAMPercentage=75.0", \
42+
"-Djava.security.egd=file:/dev/./urandom", \
43+
"-jar", \
44+
"app.jar"]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# WEB6_8_Bid_BE
2-
프로그래머스 6기 8회차 최종 프로젝트 12팀(Bid)
2+
3+
프로그래머스 6기 8회차 최종 프로젝트 12팀(Bid) - 백엔드

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ dependencies {
4848

4949
// DB
5050
runtimeOnly("com.h2database:h2")
51+
runtimeOnly("com.mysql:mysql-connector-j")
5152

5253
// QueryDSL
5354
implementation("io.github.openfeign.querydsl:querydsl-jpa:7.0")

src/main/java/com/backend/global/security/SecurityConfig.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ public UrlBasedCorsConfigurationSource corsConfigurationSource() {
6666
CorsConfiguration configuration = new CorsConfiguration();
6767

6868
// 허용할 오리진 설정
69-
configuration.setAllowedOrigins(List.of("https://cdpn.io", "http://localhost:3000"));
69+
configuration.setAllowedOrigins(List.of(
70+
"https://cdpn.io",
71+
"http://localhost:3000",
72+
"https://bid-market.shop",
73+
"https://www.bid-market.shop",
74+
"https://api.bid-market.shop"
75+
));
7076
configuration.setAllowedMethods(List.of("GET", "POST", "PUT", "PATCH", "DELETE"));
7177

7278
// 자격 증명 허용 설정
Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,34 @@
11
spring:
22
datasource:
3-
url: jdbc:h2:mem:db_test;MODE=MySQL
4-
username: sa
5-
password:
6-
driver-class-name: org.h2.Driver
3+
url: jdbc:mysql://${DB_HOST}:3306/${DB_NAME}?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Seoul
4+
username: ${DB_USERNAME}
5+
password: ${DB_PASSWORD}
6+
driver-class-name: com.mysql.cj.jdbc.Driver
7+
8+
jpa:
9+
hibernate:
10+
ddl-auto: validate
11+
properties:
12+
hibernate:
13+
dialect: org.hibernate.dialect.MySQL8Dialect
14+
15+
data:
16+
redis:
17+
host: ${REDIS_HOST:localhost}
18+
port: ${REDIS_PORT:6379}
19+
20+
jwt:
21+
secret: ${JWT_SECRET}
22+
access_token_expiration_minutes: ${JWT_ACCESS_TOKEN_EXPIRATION:30}
23+
refresh_token_expiration_days: ${JWT_REFRESH_TOKEN_EXPIRATION:7}
724

825
file:
926
upload:
1027
path: ${user.home}/uploads
11-
base-url: ${BACKEND_BASE_URL}/uploads
28+
base-url: https://api.bid-market.shop/uploads
1229
testdata:
1330
generation:
14-
enabled: false
31+
enabled: false
32+
33+
server:
34+
port: 8080

terraform/environments/dev/.terraform.lock.hcl

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# 로컬 변수 정의 - 리소스 네이밍을 일관되게 관리
2+
locals {
3+
team_prefix = "team12"
4+
env = var.environment
5+
6+
# 네이밍 규칙: team12-{resource-type}-{number}
7+
vpc_name = "${local.team_prefix}-vpc-1"
8+
igw_name = "${local.team_prefix}-igw-1"
9+
public_subnet_prefix = "${local.team_prefix}-public-subnet"
10+
private_subnet_prefix = "${local.team_prefix}-private-subnet"
11+
alb_sg_name = "${local.team_prefix}-alb-sg-1"
12+
ec2_sg_name = "${local.team_prefix}-ec2-sg-1"
13+
rds_sg_name = "${local.team_prefix}-rds-sg-1"
14+
alb_name = "${local.team_prefix}-alb-1"
15+
target_group_name = "${local.team_prefix}-tg-1"
16+
launch_template_name = "${local.team_prefix}-lt-1"
17+
asg_name = "${local.team_prefix}-asg-1"
18+
rds_name = "${local.team_prefix}-rds-1"
19+
ecr_name = "${local.team_prefix}-ecr-1"
20+
21+
# 공통 태그
22+
common_tags = {
23+
Team = "team12"
24+
Environment = var.environment
25+
Project = "auction-app"
26+
ManagedBy = "terraform"
27+
}
28+
}

0 commit comments

Comments
 (0)