Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BSVR-25] docker 추가 #11

Merged
merged 22 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
33400d2
feat : server와 DB용 docker compose 추가
wjdwnsdnjs13 Jul 1, 2024
9e8f211
fix : 윈도우에서 makeGitHooksExecutable 에러 fix
wjdwnsdnjs13 Jul 2, 2024
2987bb3
feat : docker-compose 타임존 추가
wjdwnsdnjs13 Jul 2, 2024
caf5d9e
feat : dockerfile 구현
wjdwnsdnjs13 Jul 2, 2024
ed15fa4
feat : dockerfile 구현
wjdwnsdnjs13 Jul 3, 2024
67e0c25
remove : docker 파일 server-docker 폴더로 위치 이동
wjdwnsdnjs13 Jul 3, 2024
8ac2895
refactor : docker 이미지에 맞는 컨테이너 이름으로 변경
wjdwnsdnjs13 Jul 3, 2024
887779e
feat : 서버 애플리케이션 docker 이미지 생성을 위한 dockerfile 추가
wjdwnsdnjs13 Jul 3, 2024
ca658fb
Merge branch 'main' into feat/BSVR-25
wjdwnsdnjs13 Jul 3, 2024
36edee9
fix: 기존의 h2인메모리 드라이버와 mysql 드라이버 충돌 해결
pminsung12 Jul 5, 2024
61eb892
fix: openjdk 이미지 사용
pminsung12 Jul 5, 2024
45138a9
fix: dockerfile 사용해서 서버 이미지 빌드
pminsung12 Jul 5, 2024
15d7817
Merge branch 'main' into feat/BSVR-25
pminsung12 Jul 5, 2024
d2e9341
docs : docker db gitignore 추가
wjdwnsdnjs13 Jul 6, 2024
776da75
docs : 삭제된 p6spy 추가
wjdwnsdnjs13 Jul 6, 2024
54b3cc7
fix : mysql 컨테이너가 준비되기 전 server 컨테이너 동작 지연
wjdwnsdnjs13 Jul 6, 2024
a6ae20e
refactor: renaming containers
pminsung12 Jul 6, 2024
8b995b8
feat: 도커 파일에 빌드 스테이지 추가
pminsung12 Jul 7, 2024
95fff61
build: 기존 도커파일 삭제
pminsung12 Jul 7, 2024
957084d
build: 개발용 도커파일 재정의
pminsung12 Jul 7, 2024
3cbf619
build: docker-compose up --build를 통해 gradle 빌드까지 수행하도록 개선
pminsung12 Jul 7, 2024
7b8166a
chore: gitignore shell script 파일 추가
pminsung12 Jul 7, 2024
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# docker
db/**

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
Expand Down
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM openjdk:17-jdk-slim

WORKDIR /app

COPY application/build/libs/*.jar app.jar

EXPOSE 8080

ENTRYPOINT ["java","-jar","app.jar"]
36 changes: 36 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# docker-compose.yml

services:
mysql:
container_name: spot-mysql
image: mysql:8 # 선호하는 버전 있을 경우 선정 예정!
ports:
- 3306:3306 # 혹시나 기존에 MySQL 사용 중일 경우 앞자리를 다른 포트로 바꿔야함.
volumes:
- ./db/mysql/data:/var/lib/mysql # 기존 데이터 파일과 격리를 위해 db/mysql/data 로 설정함!
command:
- '--character-set-server=utf8mb4'
- '--collation-server=utf8mb4_unicode_ci'
environment:
TZ : "Asia/Seoul"
MYSQL_ROOT_PASSWORD: test1234 # 임시 비밀번호
MYSQL_DATABASE: spot # DB 이름 선정 시 변경 예정.
MYSQL_USER: test1234 # 임시 유저
MYSQL_PASSWORD: test1234 # 임시 비밀번호
healthcheck: # 생명주기? 확인 옵션 추가
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
timeout: 20s
retries: 10

server:
build: . # 디렉토리에 있는 도커파일 이용해서 이미지 빌드
container_name: spot-spring-server
ports:
- 8080:8080
depends_on: # 항상 mysql 실행하고 서버 실행되게 함.
mysql:
condition: service_healthy # mysql 컨테이너의 healthcheck가 정상일 때까지 대기!
environment:
SPRING_DATASOURCE_URL: jdbc:mysql://mysql:3306/spot
SPRING_DATASOURCE_USERNAME: test1234
SPRING_DATASOURCE_PASSWORD: test1234
6 changes: 3 additions & 3 deletions infrastructure/jpa/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ dependencies {
// spring
implementation("org.springframework.boot:spring-boot-starter-data-jpa:_")


runtimeOnly("com.mysql:mysql-connector-j")

// queryDSL
implementation("com.querydsl:querydsl-jpa:_:jakarta")
annotationProcessor("com.querydsl:querydsl-apt:_:jakarta")
Expand All @@ -13,9 +16,6 @@ dependencies {

// p6spy
implementation("com.github.gavlyukovskiy:p6spy-spring-boot-starter:_")

// h2 - DB (또는 도커) 세팅 후 사라질 예정,,
runtimeOnly("com.h2database:h2")
}

tasks.bootJar { enabled = false }
Expand Down
45 changes: 29 additions & 16 deletions infrastructure/jpa/src/main/resources/application-jpa.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
spring:
datasource:
driver-class-name: org.h2.Driver
url: jdbc:h2:mem:spot
username: sa
password:
url: jdbc:mysql://mysql:3306/spot
username: test1234
password: test1234
driver-class-name: com.mysql.cj.jdbc.Driver

jpa:
database: h2
database: mysql
database-platform: org.hibernate.dialect.MySQL8Dialect
hibernate:
ddl-auto: create
database-platform: org.hibernate.dialect.H2Dialect
open-in-view: false
defer-datasource-initialization: true
ddl-auto: update # 주의: 프로덕션 환경에서는 'validate' 사용 권장
show-sql: true
properties:
hibernate:
format_sql: true
use_sql_comments: true

h2:
console:
enabled: true
path: /h2-console
sql:
init:
mode: always # 필요한 경우 'never'로 변경

server:
port: 8080

logging:
level:
org.hibernate.SQL: DEBUG
org.hibernate.type.descriptor.sql.BasicBinder: TRACE

decorator:
datasource:
p6spy:
enable-logging: true
datasource:
p6spy:
enable-logging: true

# 필요한 경우 추가 설정

Loading