Skip to content

Commit 9841721

Browse files
committed
build docker image for nginx-www using spotify docker plugin
1 parent 6e717cf commit 9841721

File tree

4 files changed

+21
-56
lines changed

4 files changed

+21
-56
lines changed

samples/nginx-www/Dockerfile

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
FROM maven:3.6.1-jdk-12 AS build
2-
3-
WORKDIR /build
4-
5-
COPY pom.xml .
6-
7-
RUN mvn package
8-
9-
COPY src ./src
10-
11-
RUN mvn package
12-
131
FROM openjdk:12-alpine
142

15-
WORKDIR /app
16-
COPY --from=build /build/target/nginx-www-operator.jar .
3+
ENTRYPOINT ["java", "-jar", "/usr/share/operator/operator.jar"]
4+
5+
ARG JAR_FILE
6+
ADD target/${JAR_FILE} /usr/share/operator/operator.jar
177

18-
CMD java -jar nginx-www-operator.jar

samples/nginx-www/deploy.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

samples/nginx-www/pom.xml

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.github.containersolutions</groupId>
77
<artifactId>nginx-www-operator</artifactId>
8-
<version>0.2.1-SNAPSHOT</version>
8+
<version>0.3.2-SNAPSHOT</version>
99

1010
<name>Operator SDK - Samples - Nginx WWW</name>
1111
<description>Nginx Sample</description>
@@ -19,7 +19,7 @@
1919
<dependency>
2020
<groupId>com.github.containersolutions</groupId>
2121
<artifactId>operator-framework</artifactId>
22-
<version>0.2.0</version>
22+
<version>${project.version}</version>
2323
</dependency>
2424
<dependency>
2525
<groupId>org.junit.jupiter</groupId>
@@ -49,39 +49,25 @@
4949
</configuration>
5050
</plugin>
5151
<plugin>
52-
<groupId>org.apache.maven.plugins</groupId>
53-
<artifactId>maven-shade-plugin</artifactId>
54-
<version>2.4.3</version>
52+
<groupId>com.spotify</groupId>
53+
<artifactId>dockerfile-maven-plugin</artifactId>
54+
<version>1.4.12</version>
5555
<executions>
5656
<execution>
57-
<phase>package</phase>
57+
<id>default</id>
5858
<goals>
59-
<goal>shade</goal>
59+
<goal>build</goal>
60+
<goal>push</goal>
6061
</goals>
61-
<configuration>
62-
<createDependencyReducedPom>false</createDependencyReducedPom>
63-
<transformers>
64-
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
65-
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
66-
<manifestEntries>
67-
<Main-Class>com.github.containersolutions.operator.sample.NginxWwwOperator</Main-Class>
68-
<Build-Number>1.0</Build-Number>
69-
<Multi-Release>true</Multi-Release>
70-
</manifestEntries>
71-
</transformer>
72-
</transformers>
73-
<filters>
74-
<filter>
75-
<artifact>io.fabric8:openshift-client</artifact>
76-
<excludes>
77-
<exclude>io/fabric8/kubernetes/client/Config*</exclude>
78-
</excludes>
79-
</filter>
80-
</filters>
81-
<finalName>${project.artifactId}</finalName>
82-
</configuration>
8362
</execution>
8463
</executions>
64+
<configuration>
65+
<repository>adamsandor83</repository>
66+
<tag>${project.version}</tag>
67+
<buildArgs>
68+
<JAR_FILE>nginx-www-operator.jar</JAR_FILE>
69+
</buildArgs>
70+
</configuration>
8571
</plugin>
8672
</plugins>
8773
</build>

samples/nginx-www/src/main/java/com/github/containersolutions/operator/sample/NginxWwwController.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public Optional<NginxWww> createOrUpdateResource(NginxWww nginx, Context<NginxWw
8989
}
9090

9191
@Override
92-
public void deleteResource(NginxWww nginx, Context<NginxWww> context) {
92+
public boolean deleteResource(NginxWww nginx, Context<NginxWww> context) {
9393
log.info("Execution deleteResource for: {}", nginx.getMetadata().getName());
9494

9595
log.info("Deleting ConfigMap {}", configMapName(nginx));
@@ -115,6 +115,7 @@ public void deleteResource(NginxWww nginx, Context<NginxWww> context) {
115115
if (service.get() != null) {
116116
service.delete();
117117
}
118+
return true;
118119
}
119120

120121
private static String configMapName(NginxWww nginx) {

0 commit comments

Comments
 (0)