diff --git a/Dockerfile b/Dockerfile index 7ad3804..b48c63a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM adoptopenjdk/openjdk11:latest as BUILD_IMAGE +FROM openjdk:17-alpine as BUILD_IMAGE ENV WORK_DIR=/usr/app/ @@ -18,17 +18,15 @@ COPY src src # jar 파일 build RUN ./gradlew bootjar -FROM adoptopenjdk/openjdk11:latest +FROM openjdk:17-alpine ENV WORK_DIR=/usr/app/ WORKDIR $WORK_DIR -COPY --from=BUILD_IMAGE $WORK_DIR/build/libs/*.jar tripleapp.jar +COPY --from=BUILD_IMAGE $WORK_DIR/build/libs/*.jar dongne-api.jar ENTRYPOINT ["java", \ "-jar", \ "-Dspring.profiles.active=${PROFILE_OPTION}", \ -"-Dspring.datasource.url=${SPRING_DATASOURCE_URL}", \ -"-Dredis.host=${REDIS_HOST}", \ -"tripleapp.jar"] \ No newline at end of file +"dongne-api.jar"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 530cd58..a672861 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,15 +1,14 @@ version: "3.9" services: - nginx: - image: nginx - container_name: nginx - ports: - - "80:80" - volumes: - - ./nginx/:/etc/nginx/conf.d/ app-server: build: context: . dockerfile: Dockerfile + ports: + - "8080:8080" env_file: - env/app.env +networks: + default: + external: + name: api-net \ No newline at end of file diff --git a/env/app.env b/env/app.env new file mode 100644 index 0000000..e398751 --- /dev/null +++ b/env/app.env @@ -0,0 +1 @@ +PROFILE_OPTION=docker \ No newline at end of file diff --git a/nginx/app.conf b/nginx/app.conf new file mode 100644 index 0000000..172e262 --- /dev/null +++ b/nginx/app.conf @@ -0,0 +1,5 @@ +server { + listen 80; + listen [::]:80; + +} \ No newline at end of file diff --git a/src/main/resources/application-docker.yml b/src/main/resources/application-docker.yml new file mode 100644 index 0000000..329a30d --- /dev/null +++ b/src/main/resources/application-docker.yml @@ -0,0 +1,6 @@ +# local 내 docker 테스트용도 +spring: + datasource: + url: jdbc:mysql://beanie-test-db:3306/dongne?autoreconnect=true&characterEncoding=utf8&serverTimezone=Asia/Seoul + username: root + password: beaniejoy # TODO 추후 보안에 대해 생각해보기 diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml new file mode 100644 index 0000000..0a4ee95 --- /dev/null +++ b/src/main/resources/application-local.yml @@ -0,0 +1,5 @@ +spring: + datasource: + url: jdbc:mysql://localhost:3306/dongne?autoreconnect=true&characterEncoding=utf8&serverTimezone=Asia/Seoul + username: root + password: beaniejoy # TODO 추후 보안에 대해 생각해보기 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 61c16f5..436480a 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,8 +1,7 @@ spring: + profiles: + active: local datasource: - url: jdbc:mysql://localhost:3306/dongne?autoreconnect=true&characterEncoding=utf8&serverTimezone=Asia/Seoul - username: root - password: beaniejoy # TODO 추후 보안에 대해 생각해보기 driver-class-name: com.mysql.cj.jdbc.Driver jpa: hibernate: @@ -20,4 +19,4 @@ spring: logging: level: org.hibernate.SQL: debug # logger 통해 로깅 -# org.hibernate.type: trace + # org.hibernate.type: trace \ No newline at end of file