Skip to content

Commit

Permalink
chore: compose.yml 등 배포 관련 설정 파일 작성 (#43)
Browse files Browse the repository at this point in the history
* chore: compose.yml 등 배포 관련 설정 파일 작성

refactor: RedisProperty 사용

* chore: compose.yml 수정

MariaDB, Redis 포트 개방
컨테이너 restart 설정

* chore: test task를 위한 application.yml 추가

JWT 관련 속성 test에서 설정
test task, build task 정상화
  • Loading branch information
jmkim0 authored Dec 30, 2022
1 parent 7e50939 commit 90b7993
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# production
/build
/secrets

# misc
.DS_Store
Expand All @@ -20,4 +21,4 @@

npm-debug.log*
yarn-debug.log*
yarn-error.log*
yarn-error.log*
69 changes: 69 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
services:
web:
image: nginx
restart: always
ports:
- 80:80
volumes:
- ./client/build:/usr/share/nginx/html:ro
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- backend

db:
image: mariadb
restart: always
secrets:
- db-password
volumes:
- db-data:/var/lib/mysql
environment:
- MYSQL_DATABASE=stackoverflow
- MYSQL_ROOT_PASSWORD_FILE=/run/secrets/db-password
healthcheck:
test: ['CMD-SHELL', 'mysqladmin ping -h 127.0.0.1 --password="$$(cat /run/secrets/db-password)" --silent']
interval: 3s
retries: 5
start_period: 30s
ports:
- 3306:3306

redis:
image: redis
restart: always
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
interval: 3s
retries: 5
ports:
- 6379:6379

backend:
image: eclipse-temurin:11-jre
restart: always
secrets:
- backend-secrets
command: java -jar app.jar
volumes:
- ./server/build/libs/seb41-41-pre-project-0.0.1-SNAPSHOT.jar:/app.jar:ro
environment:
- SPRING_CONFIG_IMPORT=file:/run/secrets/backend-secrets[.yml]
- SPRING_PROFILES_ACTIVE=server
- SPRING_DATASOURCE_URL=jdbc:mysql://db/stackoverflow
- SPRING_DATASOURCE_USERNAME=root
- SPRING_REDIS_HOST=redis
# - SPRING_JPA_HIBERNATE_DDL-AUTO=create-only # 최초 기동시 스키마 생성을 위해 사용
depends_on:
db:
condition: service_healthy
redis:
condition: service_healthy

volumes:
db-data:

secrets:
db-password:
file: ./secrets/db-password
backend-secrets:
file: ./secrets/backend-secrets.yml
15 changes: 15 additions & 0 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
events {}

http {
server {
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri /index.html =404;
}

location /api/ {
proxy_pass http://backend:8080/api/;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seb4141preproject.security.auth.redis;

import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
Expand All @@ -15,15 +15,11 @@
@RequiredArgsConstructor
public class RedisConfig {

// @Value("${spring.redis.host}")
private final String host = "localhost";

// @Value("${spring.redis.port}")
private final int port = 6379;
private final RedisProperties redisProperties;

@Bean
public RedisConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory(host, port);
return new LettuceConnectionFactory(redisProperties.getHost(), redisProperties.getPort());
}

@Bean
Expand Down
1 change: 1 addition & 0 deletions server/src/main/resources/application-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ spring:
jpa:
hibernate:
ddl-auto: validate

4 changes: 4 additions & 0 deletions server/src/test/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
jwt:
key: kevin12341234123412341234123412341234adsfgeeettwaeaafasfsadf
ATExpiration: 10
RTExpiration: 420

0 comments on commit 90b7993

Please sign in to comment.