docker copose

This commit is contained in:
jinho jeong
2022-04-27 14:34:42 +09:00
parent 2f53255ab0
commit f22e894a94
7 changed files with 103 additions and 35 deletions

5
Dockerfile Normal file
View File

@@ -0,0 +1,5 @@
FROM adoptopenjdk:11-jdk-hotspot
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} oneul.jar
ENTRYPOINT ["java", "-Dspring.profiles.active=prod", "-jar", "/oneul.jar"]

View File

@@ -24,13 +24,14 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.session:spring-session-data-redis'
// implementation 'org.springframework.session:spring-session-core'
runtimeOnly 'com.h2database:h2'
implementation 'org.springframework.session:spring-session-data-redis'
implementation 'org.springframework.session:spring-session-core'
runtimeOnly 'mysql:mysql-connector-java'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'

24
docker-compose.yml Normal file
View File

@@ -0,0 +1,24 @@
version: "3"
services:
oneul:
build: .
ports:
- 8080:8080
depends_on:
- mysql
- redis
mysql:
image: mysql
environment:
MYSQL_DATABASE: oneul
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_HOST: '%'
ports:
- 3306:3306
redis:
image: redis
ports:
- 6379:6379

View File

@@ -4,11 +4,9 @@ import java.util.Optional;
import com.example.oneul.domain.user.domain.UserEntity;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@RedisHash
@Repository
public interface UserCommandRepository extends CrudRepository<UserEntity, Long> {
Optional<UserEntity> findByUsername(String username);

View File

@@ -0,0 +1,33 @@
spring:
config:
activate:
on-profile: local
jpa:
properties:
hibernate:
show-sql: true
ddl-auto: update
hbm2ddl:
auto: update
format_sql: true
datasource:
url: jdbc:mysql://localhost:3306/onuel?serverTimezone=UTC&characterEncoding=UTF-8
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
redis:
host: localhost
port: 6379
server:
servlet:
session:
timeout: 60
logging:
level:
web: DEBUG
org:
hibernate:
SQL: DEBUG
log-in-page: www.naver.com

View File

@@ -0,0 +1,34 @@
spring:
config:
activate:
on-profile: prod
jpa:
properties:
hibernate:
show-sql: true
ddl-auto: update
hbm2ddl:
auto: update
format_sql: true
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql:3306/oneul?serverTimezone=UTC&characterEncoding=UTF-8&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: root
redis:
host: redis
port: 6379
server:
servlet:
session:
timeout: 60
logging:
level:
web: DEBUG
org:
hibernate:
SQL: DEBUG
log-in-page: www.naver.com

View File

@@ -1,30 +1,3 @@
spring:
jpa:
properties:
hibernate:
show-sql: true
ddl-auto: update
hbm2ddl:
auto: update
format_sql: true
datasource:
url: jdbc:h2:tcp://localhost/~/test
driver-class-name: org.h2.Driver
username: "sa"
redis:
host: 127.0.0.1
port: 6379
server:
servlet:
session:
timeout: 60
logging:
level:
web: DEBUG
org:
hibernate:
SQL: DEBUG
log-in-page: www.naver.com
profiles:
active: local