Skip to content

Commit

Permalink
✨ feat: ci cd 없는 docker로 원상복구
Browse files Browse the repository at this point in the history
  • Loading branch information
choiseoji committed Sep 15, 2024
1 parent a873e57 commit 232a749
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 92 deletions.
5 changes: 2 additions & 3 deletions JejuDorang/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM openjdk:17
ARG JAR_FILE=build/libs/*.jar
ARG PROFILES
ARG ENV
COPY ${JAR_FILE} app.jar
COPY .env ./
ENTRYPOINT ["java", "-Dspring.profiles.active=${PROFILES}", "-Dserver.env=${ENV}", "-jar", "app.jar"]
ENV TZ=Asia/Seoul
ENTRYPOINT ["java", "-jar", "/app.jar"]
46 changes: 46 additions & 0 deletions JejuDorang/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
services:
database:
container_name: jejudorang
image: mysql:8.0
platform: linux/amd64
environment:
MYSQL_DATABASE: JEJUDORANG_DB
MYSQL_ROOT_HOST: '%'
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
TZ: 'Asia/Seoul'
ports:
- "3306:3306"
command:
- "mysqld"
- "--character-set-server=utf8mb4"
- "--collation-server=utf8mb4_unicode_ci"
networks:
- network
healthcheck:
test: [ "CMD-SHELL", "mysqladmin ping -h 127.0.0.1 -p${DB_PASSWORD} --silent" ]
interval: 30s
retries: 5
start_period: 10s
timeout: 10s

application:
container_name: main-server
build:
dockerfile: dockerfile
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: ${DB_URL}
SPRING_DATASOURCE_USERNAME: ${DB_USERNAME}
SPRING_DATASOURCE_PASSWORD: ${DB_PASSWORD}
depends_on:
database:
condition: service_healthy
networks:
- network
env_file:
- .env

networks:
network:
driver: bridge
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,8 @@
@RequiredArgsConstructor
public class KakaoService {

@Value("${spring.security.oauth2.client.registration.kakao.client-secret}")
private String client_id;

@Value("${spring.security.oauth2.client.registration.kakao.redirect-uri}")
private String redirect_uri;
@Autowired
private final KakaoConfig kakaoConfig;

public KakaoAccessTokenDto getAccessToken(String code) {
// httpHeader 오브젝트 생성
Expand All @@ -36,8 +33,8 @@ public KakaoAccessTokenDto getAccessToken(String code) {
// httpBody 오브젝트 생성
MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
params.add("grant_type", "authorization_code");
params.add("client_id", client_id);
params.add("redirect_uri", redirect_uri);
params.add("client_id", kakaoConfig.getClientId());
params.add("redirect_uri", kakaoConfig.getRedirectUri());
params.add("code", code);

// httpHeader + httpBody
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.authorizeHttpRequests(authz -> authz
.requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
.requestMatchers("/auth/kakao/**").permitAll() // /auth/kakao/ 경로만 접근 허용
// .anyRequest().authenticated()) // 나머지 요청은 인증 필요
.anyRequest().permitAll())
.anyRequest().authenticated()) // 나머지 요청은 인증 필요
// .anyRequest().permitAll())
.addFilterBefore(new JwtAuthFilter(jwtTokenProvider), UsernamePasswordAuthenticationFilter.class);

return http.build(); // SecurityFilterChain 반환
Expand Down
80 changes: 0 additions & 80 deletions JejuDorang/src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,84 +1,4 @@
spring:
profiles:
active: local
group:
local: local, common
blue: blue, common
green: green, common

server:
env: blue

---

spring:
config:
activate:
on-profile: local
security:
oauth2:
client:
registration:
kakao:
redirect-uri: http://localhost:5173/auth/kakao/callback

server:
port: 8080
serverAddress: localhost

serverName: local_server

---

spring:
config:
activate:
on-profile: blue
security:
oauth2:
client:
registration:
kakao:
redirect-uri: http://3.36.151.149/auth/kakao/callback

server:
port: 8080
serverAddress: 3.36.151.149

serverName: blue_server

---

spring:
config:
activate:
on-profile: green
security:
oauth2:
client:
registration:
kakao:
redirect-uri: http://3.36.151.149/auth/kakao/callback

server:
port: 8081
serverAddress: 3.36.151.149

serverName: green_server

---

# 공통부분
spring:
config:
activate:
on-profile: common
security:
oauth2:
client:
registration:
kakao:
client-secret: ${KAKAO_REST_API_KEY}
jackson:
serialization:
fail-on-empty-beans: false
Expand Down

0 comments on commit 232a749

Please sign in to comment.