From dbda5334e36f6febfb6a331fd15e75bc550e6b78 Mon Sep 17 00:00:00 2001 From: gimhanul Date: Thu, 22 Sep 2022 17:37:53 +0900 Subject: [PATCH] ADD :: nginx, bug fix (#1) --- .gitignore | 2 + Dockerfile | 5 +-- build.gradle | 6 +-- docker-compose.yml | 68 +++++++++++++----------------- nginx/conf.d/app.conf | 12 ++++++ src/main/resources/application.yml | 56 ++---------------------- 6 files changed, 51 insertions(+), 98 deletions(-) create mode 100644 nginx/conf.d/app.conf diff --git a/.gitignore b/.gitignore index c2065bc2..99251af3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +.DS_Store +.env HELP.md .gradle build/ diff --git a/Dockerfile b/Dockerfile index 74123219..07a2689d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,9 +3,8 @@ COPY ./ ./ RUN ./gradlew clean RUN chmod +x ./gradlew RUN ./gradlew bootJAR - +ENV TZ=Asia/Seoul FROM openjdk:11-jdk COPY --from=builder build/libs/*.jar app.jar EXPOSE 8080 -ENV TZ=Asia/Seoul -ENTRYPOINT ["java","-jar","/app.jar"] \ No newline at end of file +ENTRYPOINT ["java", "-jar", "/app.jar"] \ No newline at end of file diff --git a/build.gradle b/build.gradle index 9c59cdb1..010c8ec6 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { - id 'org.springframework.boot' version '2.6.4' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' + id 'org.springframework.boot' version '2.7.3' + id 'io.spring.dependency-management' version '1.0.13.RELEASE' id 'java' } @@ -34,8 +34,6 @@ dependencies { runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.2' implementation 'org.springframework.boot:spring-boot-starter-data-redis' - implementation 'org.hibernate:hibernate-core:5.6.5.Final' - implementation 'org.apache.commons:commons-lang3:3.0' implementation 'io.springfox:springfox-swagger-ui:2.9.2' diff --git a/docker-compose.yml b/docker-compose.yml index 06285b48..d30cb46b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,57 +1,47 @@ -version: '3.7' +version: "3" services: - - gati-db: - container_name: bamdoliro_gati_db + gati-web: + image: nginx + ports: + - 80:80 + volumes: + - ./nginx/conf.d:/etc/nginx/conf.d + depends_on: + - gati-application + + gati-database: image: mysql:8.0 - networks: - - gati-network environment: - MYSQL_ROOT_HOST: '%' + MYSQL_DATABASE: ${DB_NAME} MYSQL_USER: ${DB_USERNAME} MYSQL_PASSWORD: ${DB_PASSWORD} - MYSQL_DATABASE: ${DB_NAME} - MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD} + MYSQL_ROOT_PASSWORD: root + MYSQL_ROOT_HOST: '%' + expose: + - 3306 + volumes: + - gati-volume:/var/lib/mysql command: - "mysqld" - "--character-set-server=utf8mb4" - "--collation-server=utf8mb4_unicode_ci" - volumes: - - dbvol:/var/lib/mysql - ports: - - ${DB_PORT}:${DB_PORT} - restart: always - - gati-backend: - container_name: bamdoliro_gati_server - build: - context: . - dockerfile: ./Dockerfile - ports: - - "8080:8080" - networks: - - gati-network - depends_on: - - gati-db - env_file: - - .env - restart: always - - redis: - container_name: bamdoliro_gati_redis + + gati-redis: image: redis:latest hostname: ${REDIS_HOST} command: redis-server --port ${REDIS_PORT} ports: - ${REDIS_PORT}:6379 - networks: - - gati-network - -networks: - gati-network: - name: gati-network + gati-application: + build: . + expose: + - 8080 + env_file: + - .env + depends_on: + - gati-database volumes: - dbvol: \ No newline at end of file + gati-volume: {} \ No newline at end of file diff --git a/nginx/conf.d/app.conf b/nginx/conf.d/app.conf new file mode 100644 index 00000000..6e630d88 --- /dev/null +++ b/nginx/conf.d/app.conf @@ -0,0 +1,12 @@ +server { + listen 80; + access_log off; + + location / { + proxy_pass http://gati-application:8080; + proxy_set_header Host $host:$server_port; + proxy_set_header X-Forwarded-Host $server_name; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 6e640cde..72f598dc 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,66 +1,18 @@ spring: - profiles: - active: local mvc: pathmatch: matching-strategy: ant_path_matcher ---- -spring: - config: - activate: - on-profile: local - - datasource: - url: jdbc:mysql://127.0.0.1:3307/bamdoliro_gati - driver-class-name: com.mysql.cj.jdbc.Driver - username: bamdoliro - password: bamdoliro - - jpa: - show-sql: true - generate-ddl: true - hibernate: - ddl-auto: update - properties: - hibernate: - format_sql: true - - - jwt: - secret: asdfasdfasdfasfasdfadsfadsfasdfsadfsdfasfsfasdfsafasdfasdfasfasfasdsafsdffadsfasdfasfasf - - cache: - type: redis - - redis: - host: localhost - port: 6379 - - -socket: - config: - port: 9090 - -debug: true - - -logging: - level: - org.springframework.orm.jpa: DEBUG - org.springframework.transaction: DEBUG ---- -spring: - config: - activate: - on-profile: prod datasource: - url: jdbc:mysql://gati-db:${DB_PORT}/${DB_NAME}?useSSL=false&allowPublicKeyRetrieval=true + url: jdbc:mysql://gati-database:${DB_PORT}/${DB_NAME}?useSSL=false&allowPublicKeyRetrieval=true driver-class-name: com.mysql.cj.jdbc.Driver username: ${DB_USERNAME} password: ${DB_PASSWORD} + dialect: org.hibernate.dialect.MySQL8Dialect jpa: + database: mysql + database-platform: org.hibernate.dialect.MySQL8Dialect hibernate: ddl-auto: update properties: