Skip to content

Commit e3c190f

Browse files
First commit
0 parents  commit e3c190f

16 files changed

Lines changed: 549 additions & 0 deletions

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
*#
2+
*.iml
3+
*.ipr
4+
*.iws
5+
*.jar
6+
*.sw?
7+
*~
8+
.#*
9+
.*.md.html
10+
.DS_Store
11+
.classpath
12+
.factorypath
13+
.gradle
14+
.idea
15+
.metadata
16+
.project
17+
.recommenders
18+
.settings
19+
.springBeans
20+
/build
21+
/code
22+
MANIFEST.MF
23+
_site/
24+
activemq-data
25+
bin
26+
build
27+
build.log
28+
dependency-reduced-pom.xml
29+
dump.rdb
30+
interpolated*.xml
31+
lib/
32+
manifest.yml
33+
overridedb.*
34+
settings.xml
35+
target
36+
transaction-logs
37+
.flattened-pom.xml
38+
secrets.yml
39+
.gradletasknamecache
40+
.sts4-cache
41+

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM java:8-jre-alpine
2+
3+
EXPOSE 8080
4+
5+
RUN mkdir /app
6+
COPY target/*.jar /app/spring-boot-application.jar
7+
8+
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app/spring-boot-application.jar"]
9+
10+
HEALTHCHECK --interval=1m --timeout=3s CMD wget -q -T 3 -s http://localhost:8080/actuator/health/ || exit 1

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"# codefresh-java-workshop"

pom.xml

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<artifactId>spring-boot-sample-actuator</artifactId>
7+
<name>Spring Boot Actuator Sample</name>
8+
<version>2.0.2</version>
9+
<description>Spring Boot Actuator Sample</description>
10+
11+
<packaging>jar</packaging>
12+
<parent>
13+
<groupId>org.springframework.boot</groupId>
14+
<artifactId>spring-boot-starter-parent</artifactId>
15+
<version>2.0.2.RELEASE</version>
16+
<relativePath /> <!-- lookup parent from repository -->
17+
</parent>
18+
19+
20+
<properties>
21+
22+
<java.version>1.8</java.version>
23+
24+
</properties>
25+
26+
<dependencies>
27+
<!-- Compile -->
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-actuator</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.springframework.boot</groupId>
34+
<artifactId>spring-boot-starter-web</artifactId>
35+
</dependency>
36+
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter-jdbc</artifactId>
40+
</dependency>
41+
42+
<!-- Runtime -->
43+
<dependency>
44+
<groupId>org.apache.httpcomponents</groupId>
45+
<artifactId>httpclient</artifactId>
46+
<scope>runtime</scope>
47+
</dependency>
48+
<dependency>
49+
<groupId>com.h2database</groupId>
50+
<artifactId>h2</artifactId>
51+
<scope>runtime</scope>
52+
</dependency>
53+
54+
<!-- Optional -->
55+
<dependency>
56+
<groupId>org.springframework.boot</groupId>
57+
<artifactId>spring-boot-configuration-processor</artifactId>
58+
<optional>true</optional>
59+
</dependency>
60+
61+
<!-- Test -->
62+
<dependency>
63+
<groupId>org.springframework.boot</groupId>
64+
<artifactId>spring-boot-starter-test</artifactId>
65+
<scope>test</scope>
66+
</dependency>
67+
<dependency>
68+
<groupId>io.rest-assured</groupId>
69+
<artifactId>rest-assured</artifactId>
70+
<scope>test</scope>
71+
</dependency>
72+
<dependency>
73+
<groupId>org.codehaus.groovy</groupId>
74+
<artifactId>groovy-all</artifactId>
75+
<scope>test</scope>
76+
</dependency>
77+
</dependencies>
78+
<build>
79+
<plugins>
80+
<plugin>
81+
<groupId>org.springframework.boot</groupId>
82+
<artifactId>spring-boot-maven-plugin</artifactId>
83+
</plugin>
84+
<plugin>
85+
<groupId>org.apache.maven.plugins</groupId>
86+
<artifactId>maven-surefire-plugin</artifactId>
87+
<version>2.9</version>
88+
<configuration>
89+
<useFile>false</useFile>
90+
<includes>
91+
<include>**/*Test.java</include>
92+
</includes>
93+
</configuration>
94+
</plugin>
95+
96+
<plugin>
97+
<groupId>org.apache.maven.plugins</groupId>
98+
<artifactId>maven-failsafe-plugin</artifactId>
99+
<version>2.18</version>
100+
<executions>
101+
<execution>
102+
<goals>
103+
<goal>integration-test</goal>
104+
<goal>verify</goal>
105+
</goals>
106+
</execution>
107+
</executions>
108+
<configuration>
109+
<useFile>false</useFile>
110+
<includes>
111+
<include>**/*IT.java</include>
112+
</includes>
113+
</configuration>
114+
</plugin>
115+
</plugins>
116+
</build>
117+
118+
</project>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2012-2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package sample.actuator;
18+
19+
import org.springframework.boot.actuate.health.Health;
20+
import org.springframework.boot.actuate.health.HealthIndicator;
21+
import org.springframework.stereotype.Component;
22+
23+
@Component
24+
public class ExampleHealthIndicator implements HealthIndicator {
25+
26+
@Override
27+
public Health health() {
28+
return Health.up().withDetail("counter", 42).build();
29+
}
30+
31+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2012-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package sample.actuator;
18+
19+
import java.util.Collections;
20+
21+
import org.springframework.boot.actuate.info.Info;
22+
import org.springframework.boot.actuate.info.InfoContributor;
23+
import org.springframework.stereotype.Component;
24+
25+
@Component
26+
public class ExampleInfoContributor implements InfoContributor {
27+
28+
@Override
29+
public void contribute(Info.Builder builder) {
30+
builder.withDetail("example", Collections.singletonMap("someKey", "someValue"));
31+
}
32+
33+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2012-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package sample.actuator;
18+
19+
import org.springframework.stereotype.Component;
20+
21+
@Component
22+
public class HelloWorldService {
23+
24+
25+
26+
public String getHelloMessage() {
27+
return "Spring boot says hello from a Docker container";
28+
}
29+
30+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2012-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package sample.actuator;
18+
19+
import org.springframework.boot.SpringApplication;
20+
import org.springframework.boot.actuate.health.Health;
21+
import org.springframework.boot.actuate.health.HealthIndicator;
22+
import org.springframework.boot.autoconfigure.SpringBootApplication;
23+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
24+
import org.springframework.context.annotation.Bean;
25+
26+
@SpringBootApplication
27+
@EnableConfigurationProperties(ServiceProperties.class)
28+
public class SampleActuatorApplication {
29+
30+
public static void main(String[] args) {
31+
SpringApplication.run(SampleActuatorApplication.class, args);
32+
}
33+
34+
@Bean
35+
public HealthIndicator helloHealthIndicator() {
36+
return new HealthIndicator() {
37+
38+
@Override
39+
public Health health() {
40+
return Health.up().withDetail("hello", "world").build();
41+
}
42+
43+
};
44+
}
45+
46+
}

0 commit comments

Comments
 (0)