File tree Expand file tree Collapse file tree 8 files changed +143
-22
lines changed
src/test/java/br/com/helpdev/atdd
java/br/com/helpdev/config Expand file tree Collapse file tree 8 files changed +143
-22
lines changed Original file line number Diff line number Diff line change
1
+ FROM openjdk:17.0.2
2
+
3
+ ARG RUN_JAVA_VERSION=1.3.8
4
+ ENV FLYWAY_VERSION 7.5.2
5
+ ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en'
6
+
7
+ # Install java and the run-java script
8
+ # Also set up permissions for user `1001`
9
+ RUN microdnf update \
10
+ && microdnf install curl ca-certificates tar gzip \
11
+ && microdnf clean all \
12
+ && mkdir /deployments \
13
+ && mkdir /flyway \
14
+ && chown 1001 /deployments \
15
+ && chmod "g+rwX" /deployments \
16
+ && chown 1001:root /deployments \
17
+ && curl https://repo1.maven.org/maven2/io/fabric8/run-java-sh/${RUN_JAVA_VERSION}/run-java-sh-${RUN_JAVA_VERSION}-sh.sh -o /deployments/run-java.sh \
18
+ && chown 1001 /deployments/run-java.sh \
19
+ && chmod 540 /deployments/run-java.sh
20
+
21
+ # Install and configure Flyway
22
+ RUN curl https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/${FLYWAY_VERSION}/flyway-commandline-${FLYWAY_VERSION}.tar.gz -o /flyway/flyway-commandline-${FLYWAY_VERSION}.tar.gz \
23
+ && tar -xzf /flyway/flyway-commandline-${FLYWAY_VERSION}.tar.gz --strip-components=1 -C /flyway \
24
+ && rm /flyway/flyway-commandline-${FLYWAY_VERSION}.tar.gz \
25
+ && chown 1001 /flyway/flyway \
26
+ && chmod 540 /flyway/flyway
27
+
28
+ COPY app/spring-app/target/*.jar /deployments/app.jar
29
+ COPY resources/flyway/db/migration /flyway/sql
30
+
31
+ EXPOSE 8080
32
+ USER 1001
33
+
34
+ ENTRYPOINT [ "/deployments/run-java.sh" ]
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ Fornecendo toda infraestrutura necessária para o desenvolvedor.
79
79
80
80
### Requerido
81
81
82
- - Java 11 +
82
+ - Java 17 +
83
83
- Maven 3+
84
84
- docker
85
85
- docker-compose
Original file line number Diff line number Diff line change 90
90
</dependency >
91
91
</dependencies >
92
92
93
+ <profiles >
94
+ <profile >
95
+ <id >quarkus</id >
96
+ <activation >
97
+ <activeByDefault >true</activeByDefault >
98
+ </activation >
99
+ <properties >
100
+ <dockerfile >Dockerfile</dockerfile >
101
+ </properties >
102
+ </profile >
103
+ <profile >
104
+ <id >spring</id >
105
+ <activation >
106
+ <activeByDefault >false</activeByDefault >
107
+ </activation >
108
+ <properties >
109
+ <dockerfile >Dockerfile.spring</dockerfile >
110
+ </properties >
111
+ </profile >
112
+
113
+ </profiles >
93
114
94
115
<build >
95
116
<plugins >
112
133
<alias >dockerfile</alias >
113
134
<build >
114
135
<contextDir >${project.parent.basedir} </contextDir >
115
- <dockerFile >${project.parent.basedir} /Dockerfile </dockerFile >
136
+ <dockerFile >${project.parent.basedir} /${dockerfile} </dockerFile >
116
137
</build >
117
138
</image >
118
139
</images >
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ private static GenericContainer<?> buildAppContainer(final Startable... dependsO
66
66
.withEnv ("MYSQL_PASSWORD" , "test" )
67
67
.withEnv ("MYSQL_URL" , "jdbc:mysql://testdb:" + MySQLContainer .MYSQL_PORT + "/test?autoReconnect=true&useSSL=false" )
68
68
.withExposedPorts (8080 )
69
+ //TODO: change to: '/actuator/health' if you use spring
69
70
.waitingFor (Wait .forHttp ("/q/health/ready" ).forStatusCode (200 ))
70
71
.withLogConsumer (new Slf4jLogConsumer (LoggerFactory .getLogger ("APP_CONTAINER" )));
71
72
}
Original file line number Diff line number Diff line change 39
39
<groupId >org.springframework.boot</groupId >
40
40
<artifactId >spring-boot-starter-jersey</artifactId >
41
41
</dependency >
42
+ <dependency >
43
+ <groupId >org.springframework.boot</groupId >
44
+ <artifactId >spring-boot-starter-aop</artifactId >
45
+ </dependency >
42
46
<dependency >
43
47
<groupId >${project.groupId} </groupId >
44
48
<artifactId >jaxrs-controller-v1</artifactId >
64
68
<groupId >org.springframework.boot</groupId >
65
69
<artifactId >spring-boot-starter-actuator</artifactId >
66
70
</dependency >
71
+ <dependency >
72
+ <groupId >io.micrometer</groupId >
73
+ <artifactId >micrometer-core</artifactId >
74
+ </dependency >
67
75
<dependency >
68
76
<groupId >io.micrometer</groupId >
69
77
<artifactId >micrometer-registry-prometheus</artifactId >
70
78
</dependency >
79
+
80
+ <dependency >
81
+ <groupId >ch.qos.logback</groupId >
82
+ <artifactId >logback-core</artifactId >
83
+ </dependency >
84
+
71
85
<dependency >
72
- <groupId >org.springframework.boot </groupId >
73
- <artifactId >spring-boot-starter-test </artifactId >
74
- <scope >test</ scope >
86
+ <groupId >net.logstash.logback </groupId >
87
+ <artifactId >logstash-logback-encoder </artifactId >
88
+ <version > ${logstash-logback-encoder-version} </ version >
75
89
</dependency >
76
90
</dependencies >
77
91
81
95
<plugin >
82
96
<groupId >org.springframework.boot</groupId >
83
97
<artifactId >spring-boot-maven-plugin</artifactId >
98
+ <version >${spring-boot.version} </version >
84
99
<configuration >
85
100
<mainClass >br.com.helpdev.SpringSampleApplication</mainClass >
86
101
<layers >
87
102
<enabled >true</enabled >
88
103
<configuration >${project.basedir} /src/layers.xml</configuration >
89
104
</layers >
90
105
</configuration >
91
-
92
106
<executions >
93
107
<execution >
94
108
<goals >
95
109
<goal >repackage</goal >
96
110
</goals >
97
111
</execution >
98
112
</executions >
99
-
100
113
</plugin >
101
114
</plugins >
102
115
</build >
Original file line number Diff line number Diff line change 1
1
package br .com .helpdev .config ;
2
2
3
+ import java .util .Objects ;
4
+ import java .util .stream .Collectors ;
5
+ import javax .ws .rs .Path ;
6
+ import javax .ws .rs .ext .Provider ;
3
7
import org .glassfish .jersey .server .ResourceConfig ;
4
- import org .springframework .stereotype .Component ;
8
+ import org .springframework .context .annotation .ClassPathScanningCandidateComponentProvider ;
9
+ import org .springframework .context .annotation .Configuration ;
10
+ import org .springframework .core .type .filter .AnnotationTypeFilter ;
11
+ import org .springframework .util .ClassUtils ;
5
12
6
- @ Component
13
+ @ Configuration
7
14
public class WebJerseyConfiguration extends ResourceConfig {
8
15
9
16
public WebJerseyConfiguration () {
10
17
packages ("br.com.helpdev.controller" );
18
+ var scanner = new ClassPathScanningCandidateComponentProvider (false );
19
+ scanner .addIncludeFilter (new AnnotationTypeFilter (Provider .class ));
20
+ scanner .addIncludeFilter (new AnnotationTypeFilter (Path .class ));
21
+ registerClasses (
22
+ scanner .findCandidateComponents ("br.com.helpdev.controller" ).stream ()
23
+ .map (
24
+ beanDefinition ->
25
+ ClassUtils .resolveClassName (
26
+ Objects .requireNonNull (beanDefinition .getBeanClassName ()),
27
+ getClassLoader ()))
28
+ .collect (Collectors .toSet ()));
11
29
}
12
30
}
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <configuration >
3
+ <appender name =" out-json" class =" ch.qos.logback.core.ConsoleAppender" >
4
+ <encoder class =" net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder" >
5
+ <providers >
6
+ <timestamp >
7
+ <fieldName >ts</fieldName >
8
+ <timeZone >UTC</timeZone >
9
+ </timestamp >
10
+ <loggerName >
11
+ <fieldName >logger</fieldName >
12
+ </loggerName >
13
+ <logLevel >
14
+ <fieldName >severity</fieldName >
15
+ </logLevel >
16
+ <threadName >
17
+ <fieldName >thread</fieldName >
18
+ </threadName >
19
+ <mdc />
20
+ <arguments >
21
+ <includeNonStructuredArguments >false</includeNonStructuredArguments >
22
+ </arguments >
23
+ <stackTrace >
24
+ <fieldName >stack</fieldName >
25
+ </stackTrace >
26
+ <message >
27
+ <fieldName >message</fieldName >
28
+ </message >
29
+ </providers >
30
+ </encoder >
31
+ </appender >
32
+ <appender name =" out-console" class =" ch.qos.logback.core.ConsoleAppender" >
33
+ <encoder >
34
+ <pattern >%d{HH:mm:ss.SSS} [%X{traceId},%X{spanId}] %X{external.id} [%t] %-5level %logger{36} - %msg%n</pattern >
35
+ </encoder >
36
+ </appender >
37
+ <!-- Env: LOG_LEVEL options: debug, info, warn, error -->
38
+ <root level =" ${LOG_LEVEL:-info}" >
39
+ <!-- Env: LOG_APPENDER options: out-json, out-console -->
40
+ <appender-ref ref =" ${LOG_APPENDER:-out-console}" />
41
+ </root >
42
+ </configuration >
Original file line number Diff line number Diff line change 102
102
<!-- Others -->
103
103
<jersey .version>2.32</jersey .version>
104
104
<lombok .version>1.18.20</lombok .version>
105
- <slf4j .version>1.7.30</slf4j .version>
105
+
106
+ <slf4j .version>1.7.36</slf4j .version>
107
+ <logback-core .version>1.2.3</logback-core .version>
108
+ <logstash-logback-encoder-version >6.6</logstash-logback-encoder-version >
109
+
106
110
<rest-assured .version>4.3.3</rest-assured .version>
107
111
<jackson-databind .version>2.13.4.2</jackson-databind .version>
108
112
<jackson-datatype .version>2.14.1</jackson-datatype .version>
292
296
<version >${testcontainers.version} </version >
293
297
<scope >test</scope >
294
298
</dependency >
295
- <dependency >
296
- <groupId >com.jparams</groupId >
297
- <artifactId >to-string-verifier</artifactId >
298
- <version >${to-string-verifier.version} </version >
299
- <scope >test</scope >
300
- </dependency >
301
- <dependency >
302
- <groupId >nl.jqno.equalsverifier</groupId >
303
- <artifactId >equalsverifier</artifactId >
304
- <version >${equals-verifier.version} </version >
305
- <scope >test</scope >
306
- </dependency >
307
299
<dependency >
308
300
<groupId >com.github.javafaker</groupId >
309
301
<artifactId >javafaker</artifactId >
You can’t perform that action at this time.
0 commit comments