Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '21'
java-version: '17'
distribution: 'temurin'

# 3) Gradle 빌드 (테스트 생략 예시)
- name: Build Spring Boot
run: ./gradlew clean build -x test

# 4) EC2로 파일 전송
# - compose 파일: docker-compose-prod.yml
# - backendProject 폴더 안의 Dockerfile
# - CI에서 생성한 JAR (backendProject/build/libs/*.jar)
# - (있다면) .env
# 4) EC2로 파일 전송 (단, .env 제외)
- name: Upload artifacts to EC2
uses: appleboy/scp-action@v0.1.7
with:
Expand All @@ -40,7 +36,6 @@ jobs:
docker-compose-prod.yml
backendProject/Dockerfile
backendProject/build/libs/*.jar
.env
target: ${{ secrets.EC2_APP_DIR }}

# 5) EC2에서 배포 (Amazon Linux)
Expand All @@ -55,6 +50,11 @@ jobs:
APP_DIR="${{ secrets.EC2_APP_DIR }}"
cd "$APP_DIR"

# ---- 여기서 .env 파일 생성 ----
cat << 'EOF' > .env
${{ secrets.EC2_ENV_FILE }}
EOF

# Docker/compose 설치(없을 때)
if ! command -v docker >/dev/null 2>&1; then
if command -v dnf >/dev/null 2>&1; then
Expand All @@ -66,7 +66,7 @@ jobs:
fi
sudo systemctl enable docker
sudo systemctl start docker
sudo usermod -aG docker $USER || true
sudo usermod -aG docker ec2-user || true
fi
if ! docker compose version >/dev/null 2>&1; then
if command -v dnf >/dev/null 2>&1; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
import likelion.mlb.backendProject.domain.user.service.RefreshTokenService;
import likelion.mlb.backendProject.global.security.jwt.JwtTokenProvider;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.Authentication;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.stereotype.Component;
import org.springframework.web.util.UriComponentsBuilder;

@Component
@RequiredArgsConstructor
Expand All @@ -20,6 +22,9 @@ public class OAuth2SuccessHandler implements AuthenticationSuccessHandler {
private final JwtTokenProvider jwtTokenProvider;
private final RefreshTokenService refreshTokenService;

@Value("${frontend.https.url}")
private String frontendUrl;

@Override
public void onAuthenticationSuccess(HttpServletRequest request,
HttpServletResponse response,
Expand All @@ -42,7 +47,10 @@ public void onAuthenticationSuccess(HttpServletRequest request,
response.addCookie(refreshTokenCookie);

// 액세스 토큰은 URL 파라미터로 전달
String targetUrl = "http://localhost:5173/auth/callback?accessToken=" + accessToken;
String targetUrl = UriComponentsBuilder.fromUriString(frontendUrl)
.path("/auth/callback")
.queryParam("accessToken", accessToken)
.build().toUriString();
response.sendRedirect(targetUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,5 @@ spring.security.oauth2.client.provider.google.user-name-attribute=${GOOGLE_USER_
#jwt
jwt.secret = ${JWT_SECRET}

#url of frontend to solve CORS problem
frontend.http.url = ${FRONTEND_HTTP_URL}
frontend.https.url = ${FRONTEND_HTTPS_URL}
frontend.https.url = ${FRONTEND_HTTPS_URL}
40 changes: 1 addition & 39 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ services:
- discovery.type=single-node
- xpack.security.enabled=false
- xpack.security.transport.ssl.enabled=false
- ES_JAVA_OPTS=-Xms512m -Xmx512m
- ES_JAVA_OPTS=-Xms1g -Xmx1g # 로컬 자원에 맞춰 조절
ports:
- "9200:9200"
- "9300:9300"
Expand All @@ -92,44 +92,6 @@ services:
networks:
- backend

# Zookeeper (for Kafka)
mlb-zookeeper:
image: confluentinc/cp-zookeeper:7.4.1
container_name: mlb-zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ports:
- "2181:2181"
healthcheck:
test: ["CMD-SHELL", "bash -lc 'echo > /dev/tcp/127.0.0.1/2181'"]
interval: 10s
timeout: 3s
retries: 30
networks:
- backend

# Kafka
mlb-kafka:
image: confluentinc/cp-kafka:7.4.1
container_name: mlb-kafka
depends_on:
- mlb-zookeeper
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: mlb-zookeeper:2181
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://mlb-kafka:9092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
healthcheck:
test: ["CMD-SHELL", "bash -lc 'echo > /dev/tcp/127.0.0.1/9092'"]
interval: 10s
timeout: 3s
retries: 30
networks:
- backend

volumes:
es_data:
Expand Down