diff --git a/.gitignore b/.gitignore index 9fe2eb1..86b4794 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ build/ !gradle/wrapper/gradle-wrapper.jar !**/src/main/**/build/ !**/src/test/**/build/ +*-local.yml ### STS ### .apt_generated diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d4ff0c2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM eclipse-temurin:21-jre +WORKDIR /app + +RUN useradd -m appuser +USER appuser + +COPY build/libs/*.jar app.jar + +EXPOSE 8080 +ENV JAVA_OPTS="" +ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"] \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..87e7107 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,58 @@ +spring: + config: + activate: + on-profile: prod + + datasource: + #TODO:도메인 이름 변경 + url: jdbc:mysql://plog-mysql:3306/plog?useSSL=false&allowPublicKeyRetrieval=true&characterEncoding=UTF-8&serverTimezone=Asia/Seoul + username: ${DB_USERNAME} + password: ${DB_PASSWORD} + driver-class-name: com.mysql.cj.jdbc.Driver + + jpa: + database-platform: org.hibernate.dialect.MySQL8Dialect + hibernate: + ddl-auto: update + defer-datasource-initialization: false + + security: + oauth2: + client: + registration: + kakao: + client-id: ${KAKAO_CLIENT_ID} + client-secret: ${KAKAO_CLIENT_SECRET} + client-authentication-method: client_secret_post + authorization-grant-type: authorization_code + redirect-uri: "https://your-domain.com/oauth/callback/kakao" + scope: + - profile_nickname + - profile_image + - account_email + client-name: Kakao + + naver: + client-id: ${NAVER_CLIENT_ID} + client-secret: ${NAVER_CLIENT_SECRET} + client-authentication-method: client_secret_post + authorization-grant-type: authorization_code + redirect-uri: "https://your-domain.com/oauth/callback/naver" + scope: + - name + - email + - profile_image + client-name: Naver + + provider: + kakao: + authorization-uri: https://kauth.kakao.com/oauth/authorize + token-uri: https://kauth.kakao.com/oauth/token + user-info-uri: https://kapi.kakao.com/v2/user/me + user-name-attribute: id + + naver: + authorization-uri: https://nid.naver.com/oauth2.0/authorize + token-uri: https://nid.naver.com/oauth2.0/token + user-info-uri: https://openapi.naver.com/v1/nid/me + user-name-attribute: response diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a67590e..33ed2f4 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,82 +1,11 @@ spring: - datasource: - # [H2 Configuration] >> TODO : 배포 시 제거하거나 프로필 분리(local/prod) 필요 - url: jdbc:h2:mem:progbe;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - username: sa - password: - driver-class-name: org.h2.Driver - - # [MySQL Configurations] >> TODO : 실제 DB 연결 시 주석 해제 및 환경변수 설정 확인 - # url: jdbc:mysql://localhost:3306/progbe?useSSL=false&characterEncoding=UTF-8&serverTimezone=UTC - # username: ${DB_USERNAME} - # password: ${DB_PASSWORD} - # driver-class-name: com.mysql.cj.jdbc.Driver - jpa: - # TODO: MySQL로 마이그레이션 시 수정 - database-platform: org.hibernate.dialect.H2Dialect - hibernate: - # TODO: 배포 시 Validate | None으로 수정 - 혹은 프로필 분리(local/prod) - ddl-auto: update properties: hibernate: format_sql: true show_sql: true - # H2 Console (http://localhost:8080/h2-console) - defer-datasource-initialization: true - - h2: - console: - enabled: true - path: /h2-console - - security: - oauth2: - client: - registration: - kakao: - client-id: ${KAKAO_CLIENT_ID} - client-secret: ${KAKAO_CLIENT_SECRET} - client-authentication-method: client_secret_post - authorization-grant-type: authorization_code - # TODO: 프론트에서 등록한 redirect-uri 확인 (사용 안해도 정책 상 필요) - redirect-uri: "http://localhost:3000/oauth/callback/kakao" - scope: - - profile_nickname - - profile_image - - account_email - client-name: Kakao - - naver: - client-id: ${NAVER_CLIENT_ID} - client-secret: ${NAVER_CLIENT_SECRET} - client-authentication-method: client_secret_post - authorization-grant-type: authorization_code - # TODO: 프론트에서 등록한 redirect-uri 확인 (사용 안해도 정책 상 필요) - redirect-uri: "http://localhost:3000/oauth/callback/naver" - scope: - - name - - email - - profile_image - client-name: Naver - - # FIXME: AuthService가 아래 Provider 쓰도록 - provider: - kakao: - authorization-uri: https://kauth.kakao.com/oauth/authorize - token-uri: https://kauth.kakao.com/oauth/token - user-info-uri: https://kapi.kakao.com/v2/user/me - user-name-attribute: id - - naver: - authorization-uri: https://nid.naver.com/oauth2.0/authorize - token-uri: https://nid.naver.com/oauth2.0/token - user-info-uri: https://openapi.naver.com/v1/nid/me - user-name-attribute: response jwt: secret: ${JWT_SECRET_KEY} - # Access Token = 30분 access-expiration: 1800000 - # Refresh Token = 2주 - refresh-expiration: 1209600000 \ No newline at end of file + refresh-expiration: 1209600000