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
35 changes: 35 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Deploy to EC2 with Docker

on:
push:
branches: [jinlee-deploy]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Copy files to EC2
uses: appleboy/scp-action@v0.1.3
with:
host: ${{ secrets.EC2_HOST }}
username: ec2-user
key: ${{ secrets.EC2_KEY }}
source: "."
target: "/home/ec2-user/app"

- name: SSH into EC2 and deploy
uses: appleboy/ssh-action@v0.1.10
with:
host: ${{ secrets.EC2_HOST }}
username: ec2-user
key: ${{ secrets.EC2_KEY }}
script: |
cd /home/ec2-user/app
chmod +x gradlew
./gradlew clean build -x test
docker-compose down
docker-compose up --build -d
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM openjdk:17-jdk-alpine
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java", "-jar", "/app.jar"]
ENV JAVA_OPTS=""

ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app.jar"]
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-context'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'io.github.cdimascio:dotenv-java:3.0.0'
implementation 'mysql:mysql-connector-java:8.0.33'
Expand Down
16 changes: 16 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
services:
tagcafe:
image: tagcafe-app
build:
context: .
dockerfile: Dockerfile
ports:
- "8080:8080"
restart: always
environment:
DB_URL: ${DB_URL}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
KAKAO_CLIENT_ID: ${KAKAO_CLIENT_ID}
KAKAO_REDIRECT_URI: ${KAKAO_REDIRECT_URI}
SECURITY_JWT_SECRET: ${SECURITY_JWT_SECRET}
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ public RedirectView kakaoCallback(@RequestParam(name="code") String code) {
ResponseEntity<Map> tokenResponse = restTemplate.exchange(tokenUrl, HttpMethod.POST, request, Map.class);

if (tokenResponse.getBody() == null) {
return new RedirectView("http://localhost:3000/error?message=카카오 토큰 발급 실패");
return new RedirectView("https://tagcafe.site/error?message=카카오 토큰 발급 실패");
}

String accessToken = (String) tokenResponse.getBody().get("access_token");

if (accessToken == null) {
return new RedirectView("http://localhost:3000/error?message=액세스 토큰 발급 실패");
return new RedirectView("https://tagcafe.site/error?message=액세스 토큰 발급 실패");
}

// ✅ 4. 사용자 정보 요청
Expand All @@ -82,7 +82,7 @@ public RedirectView kakaoCallback(@RequestParam(name="code") String code) {
ResponseEntity<Map> userInfoResponse = restTemplate.exchange(userInfoUrl, HttpMethod.GET, entity, Map.class);

if (userInfoResponse.getBody() == null) {
return new RedirectView("http://localhost:3000/error?message=카카오 사용자 정보 가져오기 실패");
return new RedirectView("https://tagcafe.site/error?message=카카오 사용자 정보 가져오기 실패");
}

Map<String, Object> kakaoAccount = (Map<String, Object>) userInfoResponse.getBody().get("kakao_account");
Expand Down Expand Up @@ -114,7 +114,7 @@ public RedirectView kakaoCallback(@RequestParam(name="code") String code) {
String jwtToken = jwtUtil.generateToken(user.getEmail());

// ✅ 8. 프론트엔드로 리다이렉트 (닉네임은 DB에서 가져온 최신값)
return new RedirectView("http://localhost:3000/home?nickname=" + URLEncoder.encode(user.getNickname(), StandardCharsets.UTF_8)
return new RedirectView("https://tagcafe.site/home?nickname=" + URLEncoder.encode(user.getNickname(), StandardCharsets.UTF_8)
+ "&email=" + email
+ "&token=" + jwtToken);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/Minjin/TagCafe/config/WebConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public WebMvcConfigurer corsConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000", "https://kauth.kakao.com") // React 애플리케이션 도메인
.allowedOrigins("http://localhost:3000", "https://kauth.kakao.com","https://tacafe.site") // React 애플리케이션 도메인
.allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
.allowedHeaders("Authorization", "Content-Type", "X-Requested-With", "Accept")
.allowCredentials(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@RestController
@RequestMapping("/cafes")
@RequiredArgsConstructor
@CrossOrigin(origins = "https://localhost:3000") // React에서 API 호출 허용
@CrossOrigin(origins = "https://tagcafe.site") // React에서 API 호출 허용
public class CafeController {
private final CafeService cafeService;
private final CafeRepository cafeRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

@RestController
@RequestMapping("/faq")
@CrossOrigin(origins = "http://localhost:3000")
@CrossOrigin(origins = "http://tagcafe.site")
public class FAQController {

private final FeedbackRepository feedbackRepository;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
public class HomeController {
@GetMapping("/")
public RedirectView redirectToFrontend() {
return new RedirectView("http://localhost:3000");
return new RedirectView("https://tagcafe.site");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@RestController
@RequestMapping("/users")
@RequiredArgsConstructor
@CrossOrigin(origins = "http://localhost:3000", allowCredentials = "true")
@CrossOrigin(origins = "https://tagcafe.site", allowCredentials = "true")
public class UserController {
private final UserRepository userRepository;

Expand Down Expand Up @@ -69,7 +69,7 @@ public ResponseEntity<Map<String, String>> deleteUser(@RequestParam("email") Str
// ✅ 카카오 로그아웃 URL 반환
Map<String, String> response = new HashMap<>();
response.put("message", "회원 탈퇴 성공");
response.put("logoutUrl", "https://kauth.kakao.com/oauth/logout?client_id=" + kakaoClientId + "&logout_redirect_uri=http://localhost:3000");
response.put("logoutUrl", "https://kauth.kakao.com/oauth/logout?client_id=" + kakaoClientId + "&logout_redirect_uri=https://tagcafe.site");

return ResponseEntity.ok(response);
} else {
Expand Down