-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
53 lines (50 loc) · 1.95 KB
/
docker-compose.yml
File metadata and controls
53 lines (50 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
services:
app:
image: imjuyongp/setbangsari:latest
ports:
- "8080:8080" # 호스트의 8080 포트를 컨테이너의 8080 포트와 매핑
env_file:
- .env
environment:
- SPRING_PROFILES_ACTIVE=prod
- TZ=Asia/Seoul
volumes:
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
command:
- java -Duser.timezone=Asia/Seoul -Dspring.profiles.active=${SPRING_PROFILES_ACTIVE} -jar app.jar
# 실행 명령어: jar 파일을 실행하면서 Spring 프로필 활성화
depends_on:
- mysql # 이 서비스가 mysql이 먼저 실행된 후 시작되도록
networks:
- cesco-network # mysql과 같은 네트워크를 공유
mysql:
image: mysql:8.0 # 공식 MySQL 8.0 이미지를 사용
ports:
- "3306:3306" # 호스트와 컨테이너의 MySQL 포트를 매핑
environment:
- MYSQL_DATABASE=setbangsari # 초기 생성될 데이터베이스 이름
- MYSQL_USER=cesco
- MYSQL_PASSWORD=cesco07
- MYSQL_ROOT_PASSWORD=1234 # 루트 계정의 비밀번호
- TZ=Asia/Seoul
- JAVA_OPTS=-Duser.timezone=Asia/Seoul
command:
- --character-set-server=utf8mb4
- --collation-server=utf8mb4_unicode_ci
- --default-authentication-plugin=mysql_native_password
- --init-connect=SET NAMES utf8mb4
- --default-time-zone=+09:00
volumes:
- mysql-data:/var/lib/mysql
# MySQL의 데이터 파일을 호스트에 볼륨으로 영구 저장
# 컨테이너가 삭제돼도 DB 내용은 유지됨
- /etc/localtime:/etc/localtime:ro #
- /etc/timezone:/etc/timezone:ro
networks:
- cesco-network # Spring과 같은 네트워크 상에 있어서 mysql이라는 호스트 이름으로 접근 가능
networks:
cesco-network:
driver: bridge # Docker 기본 브리지 네트워크를 사용
volumes:
mysql-data: # 위에서 정의한 MySQL 데이터를 저장할 볼륨