Skip to content

Commit 8fbde2b

Browse files
authored
Merge pull request #13 from Throyer/debug-in-docker
Debug in docker
2 parents f263eae + 1cf6679 commit 8fbde2b

File tree

6 files changed

+55
-32
lines changed

6 files changed

+55
-32
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
.volumes/
21
target/
2+
.volumes/
33
.git

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,20 +141,19 @@ existem dois scripts `bash` que podem ser usados para criação de arquivos de m
141141

142142
| **Descrição** | **parâmetro** | **Valor padrão** |
143143
| ------------------------------------------- | -------------------------------------- | ------------------------- |
144-
| contexto da aplicação | `contexto` | api/ |
145-
| porta da aplicação | `port` | 8080 |
146-
| url do banco | `db-url` | localhost:3306/common_app |
147-
| nome de usuário (banco) | `db-username` | root |
148-
| senha do usuário (banco) | `db-password` | root |
149-
| mostrar sql na saida | `show-sql` | false |
150-
| valor do secret na geração dos tokens | `token-secret` | secret |
151-
| tempo de expiração do token em horas | `token-expiration-time-in-hours` | 24 |
152-
| tempo de expiração do refresh token em dias | `refresh-token-expiration-time-in-day` | 7 |
153-
| máximo de conexões com o banco | `max-connections` | 5 |
154-
| endereço do servidor smtp | `smtp-host` | smtp.gmail.com |
155-
| porta do servidor smtp | `smtp-port` | 587 |
156-
| nome de usuário smtp | `smtp-username` | user |
157-
| senha do servidor smtp | `smtp-password` | secret |
144+
| porta da aplicação | `SERVER_PORT` | 8080 |
145+
| url do banco | `DB_URL` | localhost:3306/common_app |
146+
| nome de usuário (banco) | `DB_USERNAME` | root |
147+
| senha do usuário (banco) | `DB_PASSWORD` | root |
148+
| mostrar sql na saida | `DB_SHOW_SQL` | false |
149+
| máximo de conexões com o banco | `DB_MAX_CONNECTIONS` | 5 |
150+
| valor do secret na geração dos tokens | `TOKEN_SECRET` | secret |
151+
| tempo de expiração do token em horas | `TOKEN_EXPIRATION_IN_HOURS` | 24 |
152+
| tempo de expiração do refresh token em dias | `REFRESH_TOKEN_EXPIRATION_IN_DAYS` | 7 |
153+
| endereço do servidor smtp | `SMTP_HOST` | smtp.gmail.com |
154+
| porta do servidor smtp | `SMTP_PORT` | 587 |
155+
| nome de usuário smtp | `SMTP_USERNAME` | user |
156+
| senha do servidor smtp | `SMTP_PASSWORD` | secret |
158157

159158
> são definidas em: [**application.properties**](./src/main/resources/application.properties)
160159
>

docker-compose.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ services:
33

44
mariadb:
55
image: mariadb:10.6.1
6-
network_mode: host
7-
restart: always
6+
container_name: mariadb-container
87
ports:
98
- 3306:3306
109
environment:
@@ -13,3 +12,19 @@ services:
1312
volumes:
1413
- ./.volumes/database:/var/lib/mysql
1514

15+
api:
16+
build: ./
17+
links:
18+
- mariadb
19+
depends_on:
20+
- mariadb
21+
ports:
22+
- 8080:8080
23+
- 8000:8000
24+
environment:
25+
DB_URL: "mariadb:3306/common_app"
26+
DB_USERNAME: "root"
27+
DB_PASSWORD: "root"
28+
volumes:
29+
- ./:/app
30+
- ./.volumes/maven:/root/.m2

dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM maven:3.8.3
2+
3+
WORKDIR /app
4+
5+
ENTRYPOINT ["mvn", "spring-boot:run"]

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@
165165
<plugin>
166166
<groupId>org.springframework.boot</groupId>
167167
<artifactId>spring-boot-maven-plugin</artifactId>
168+
<configuration>
169+
<jvmArguments>
170+
-agentlib:jdwp=transport=dt_socket,server=y,address=*:8000,suspend=n
171+
</jvmArguments>
172+
</configuration>
168173
<executions>
169174
<execution>
170175
<goals>

src/main/resources/application.properties

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
# Mais configuracoes: https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html
33

44
# Porta do sistema.
5-
server.port=${port:8080}
5+
server.port=${SERVER_PORT:8080}
66

77
# logger
88
logging.level.springfox.documentation=off
99
logging.level.org.springframework.web=trace
1010
spring.output.ansi.enabled=always
1111
spring.jpa.properties.hibernate.format_sql=true
12-
spring.jpa.show-sql=${show-sql:true}
12+
spring.jpa.show-sql=${DB_SHOW_SQL:true}
1313

1414
# Banco de dados
15-
spring.datasource.hikari.maximum-pool-size=${max-connections:5}
16-
spring.datasource.url=jdbc:mysql://${db-url:localhost:3306/common_app}?useSSL=false&createDatabaseIfNotExist=true&serverTimezone=America/Sao_Paulo
17-
spring.datasource.username=${db-username:root}
18-
spring.datasource.password=${db-password:root}
15+
spring.datasource.hikari.maximum-pool-size=${DB_MAX_CONNECTIONS:5}
16+
spring.datasource.url=jdbc:mysql://${DB_URL:localhost:3306/common_app}?useSSL=false&createDatabaseIfNotExist=true&serverTimezone=America/Sao_Paulo
17+
spring.datasource.username=${DB_USERNAME:root}
18+
spring.datasource.password=${DB_PASSWORD:root}
1919
spring.jpa.hibernate.ddl-auto=none
2020
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
2121
spring.jpa.properties.javax.persistence.validation.mode=none
@@ -27,15 +27,15 @@ springfox.documentation.swagger-ui.base-url=/documentation
2727
springfox.documentation.swagger.v2.use-model-v3=false
2828

2929
# token
30-
token.expiration-in-hours=${token-expiration-time-in-hours:24}
31-
token.refresh.expiration-in-days=${refresh-token-expiration-time-in-days:7}
32-
token.secret=${token-secret:secret}
30+
token.expiration-in-hours=${TOKEN_EXPIRATION_IN_HOURS:24}
31+
token.refresh.expiration-in-days=${REFRESH_TOKEN_EXPIRATION_IN_DAYS:7}
32+
token.secret=${TOKEN_SECRET:secret}
3333

3434
# smtp configurations
35-
spring.mail.host=${smtp-host:smtp.gmail.com}
36-
spring.mail.port=${smtp-port:587}
37-
spring.mail.username=${smtp-username:user}
38-
spring.mail.password=${smtp-password:secret}
35+
spring.mail.host=${SMTP_HOST:smtp.gmail.com}
36+
spring.mail.port=${SMTP_PORT:587}
37+
spring.mail.username=${SMTP_USERNAME:user}
38+
spring.mail.password=${SMTP_PASSWORD:secret}
3939

4040
spring.mail.properties.mail.smtp.auth=true
4141
spring.mail.properties.mail.smtp.connectiontimeout=5000
@@ -44,5 +44,4 @@ spring.mail.properties.mail.smtp.writetimeout=5000
4444
spring.mail.properties.mail.smtp.starttls.enable=true
4545

4646
# templates
47-
spring.resources.cache.period=0
48-
47+
spring.resources.cache.period=0

0 commit comments

Comments
 (0)