@@ -4,58 +4,119 @@ services:
44 database :
55 image : postgres:13
66 restart : unless-stopped
7- container_name : example-api-database
8- command : ["postgres", "-c", "log_statement=all", "-c", "log_destination=stderr"]
7+ container_name : ${COMPOSE_PROJECT_NAME}-database
8+ command :
9+ [
10+ " postgres" ,
11+ " -c" ,
12+ " log_statement=all" ,
13+ " -c" ,
14+ " log_destination=stderr"
15+ ]
916 ports :
10- - " 5432 :5432"
17+ - " ${DB_PORT} :5432"
1118 environment :
1219 POSTGRES_USER : ${DB_USERNAME}
1320 POSTGRES_PASSWORD : ${DB_PASSWORD}
14- POSTGRES_DB : example_api
15- TZ : America/Sao_Paulo
16- PGTZ : America/Sao_Paulo
21+ POSTGRES_DB : ${DB_NAME}
22+ TZ : ${TIMEZONE}
23+ PGTZ : ${TIMEZONE}
1724 volumes :
18- - . /.volumes/database:/var/lib/postgresql/data
25+ - ~ /.volumes/database/postgresql :/var/lib/postgresql/data
1926 networks :
20- - example-api
27+ - spring-boot- example-network
2128 tty : true
2229
2330 api :
24- image : maven:3.8.5-openjdk-17
31+ build :
32+ context : ../api
33+ dockerfile : ../api/docker/Dockerfile.dev
34+ image : throyer/springboot/example-api-development:latest
35+ platform : linux/x86_64
2536 restart : unless-stopped
26- container_name : example -api-development
37+ container_name : ${COMPOSE_PROJECT_NAME} -api
2738 links :
2839 - database
2940 ports :
30- - " 8080:8080 "
31- - " 8000:8000 "
41+ - " ${API_PORT}:${API_PORT} "
42+ - " ${API_DEBUG_PORT}:${API_DEBUG_PORT} "
3243 environment :
33- DB_URL : ${DB_URL}
44+
45+ # database
46+ DB_PORT : ${DB_PORT}
47+ DB_NAME : ${DB_NAME}
48+ DB_HOST : ${DB_HOST}
3449 DB_USERNAME : ${DB_USERNAME}
3550 DB_PASSWORD : ${DB_PASSWORD}
51+ DB_SHOW_SQL : ${DB_SHOW_SQL}
52+ DB_MAX_CONNECTIONS : ${DB_MAX_CONNECTIONS}
53+
54+ # security
55+ TOKEN_SECRET : ${TOKEN_SECRET}
56+ TOKEN_EXPIRATION_IN_HOURS : ${TOKEN_EXPIRATION_IN_HOURS}
57+ REFRESH_TOKEN_EXPIRATION_IN_DAYS : ${REFRESH_TOKEN_EXPIRATION_IN_DAYS}
58+ MINUTES_TO_EXPIRE_RECOVERY_CODE : ${MINUTES_TO_EXPIRE_RECOVERY_CODE}
59+ MAX_REQUESTS_PER_MINUTE : ${MAX_REQUESTS_PER_MINUTE}
60+
61+ # smtp
62+ SMTP_HOST : ${SMTP_HOST}
63+ SMTP_PORT : ${SMTP_PORT}
64+ SMTP_USERNAME : ${SMTP_USERNAME}
65+ SMTP_PASSWORD : ${SMTP_PASSWORD}
66+
67+ # swagger
68+ SWAGGER_URL : ${SWAGGER_URL}
69+ SWAGGER_USERNAME : ${SWAGGER_USERNAME}
70+ SWAGGER_PASSWORD : ${SWAGGER_PASSWORD}
3671 volumes :
3772 - ../api:/app
38- - ./.volumes/maven :/root/.m2
73+ - ~/.m2 :/root/.m2
3974 working_dir : /app
4075 networks :
41- - example-api
76+ - spring-boot- example-network
4277 tty : true
43- entrypoint : " mvn spring-boot:run"
44-
45- # web:
46- # image: node:16.14.2
47- # restart: unless-stopped
48- # container_name: example-api-front-end-development
49- # ports:
50- # - "4200:4200"
51- # volumes:
52- # - ../web:/app
53- # working_dir: /app
54- # networks:
55- # - vendas
56- # tty: true
57- # entrypoint: "npm start"
78+ entrypoint : [
79+ " dockerize" ,
80+ " -wait" ,
81+ " tcp://database:${DB_PORT}" ,
82+ " -timeout" ,
83+ " 20s" ,
84+ ' mvn' ,
85+ ' spring-boot:run' ,
86+ ' -Dspring-boot.run.jvmArguments="-agentlib:jdwp=transport=dt_socket,server=y,address=*:${API_DEBUG_PORT},suspend=n"'
87+ ]
88+
89+ web :
90+ image : throyer/springboot/example-web-development:latest
91+ build :
92+ context : ../web
93+ dockerfile : ../web/docker/Dockerfile.dev
94+ restart : unless-stopped
95+ container_name : ${COMPOSE_PROJECT_NAME}-web
96+ links :
97+ - api
98+ ports :
99+ - " ${APP_PORT}:${APP_PORT}"
100+ volumes :
101+ - ../web:/app
102+ working_dir : /app
103+ networks :
104+ - spring-boot-example-network
105+ tty : true
106+ environment :
107+ APP_PORT : ${APP_PORT}
108+ VITE_API_BASE_URL : ${APP_API_BASE_URL}
109+ entrypoint : [
110+ " dockerize" ,
111+ " -wait" ,
112+ " http://api:${API_PORT}/api" ,
113+ " -timeout" ,
114+ " 20s" ,
115+ " npm" ,
116+ " run" ,
117+ " dev"
118+ ]
58119
59120networks :
60- example-api :
61- driver : bridge
121+ spring-boot- example-network :
122+ driver : bridge
0 commit comments