Skip to content

Commit

Permalink
Fix fabric8io#554: Add support for multiple copy layers using multipl…
Browse files Browse the repository at this point in the history
…e assemblies

Signed-off-by: Brian O'Keefe <zer0keefie@gmail.com>
  • Loading branch information
zer0keefie committed Oct 19, 2020
1 parent 308792b commit 64ac850
Show file tree
Hide file tree
Showing 31 changed files with 1,378 additions and 136 deletions.
153 changes: 153 additions & 0 deletions it/multi-assembly/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.fabric8.dmp.itests</groupId>
<artifactId>dmp-it-parent</artifactId>
<version>0.34-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>dmp-multi-assembly</artifactId>
<version>0.34-SNAPSHOT</version>
<packaging>jar</packaging>

<description>Docker Maven Plugin Example with Spring Boot with Multiple Layers</description>

<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<docker.user>fabric8</docker.user>
<spring.version>2.3.3.RELEASE</spring.version>
</properties>

<dependencies>

<!-- Boot generator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring.version}</version>
</dependency>

<!-- API, java.xml.bind module -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>

<!-- Runtime, com.sun.xml.bind module -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>io.fabric8.maven.sample.springboot.layers.Application</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.version}</version>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.34-SNAPSHOT</version>
<configuration>
<verbose>true</verbose>
<images>
<image>
<name>${docker.user}/dmp-multi-assembly</name>
<build>
<from>fabric8/java-centos-openjdk8-jdk:1.5.6</from>
<assemblies>
<assembly>
<descriptorRef>dependencies</descriptorRef>
<name>deps</name>
<targetDir>/app/lib</targetDir>
</assembly>
<assembly>
<descriptorRef>artifact</descriptorRef>
<targetDir>/app</targetDir>
</assembly>
</assemblies>
<cmd>java -jar /app/${project.artifactId}-${project.version}.jar</cmd>
<workdir>/app</workdir>
<ports>
<port>8080</port>
</ports>
</build>
<run>
<wait>
<log>Hello from Spring Boot!</log>
</wait>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>docker-build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>docker-run</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker-stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.fabric8.maven.sample.springboot.layers;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class Application {
private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);

@Bean
public CommandLineRunner commandLineRunner(ApplicationContext applicationContext) {
return new CommandLineRunner() {
@Override
public void run(String... args) {
LOGGER.info("Hello from Spring Boot!");
SpringApplication.exit(applicationContext);
}
};
}

public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
1 change: 1 addition & 0 deletions it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,6 @@
<module>log</module>
<module>run-java</module>
<module>spring-boot-with-jib</module>
<module>multi-assembly</module>
</modules>
</project>
145 changes: 145 additions & 0 deletions samples/multi-assembly/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.fabric8.dmp.samples</groupId>
<artifactId>dmp-sample-parent</artifactId>
<version>0.34-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>dmp-sample-multi-assembly</artifactId>
<version>0.34-SNAPSHOT</version>
<packaging>jar</packaging>

<description>Docker Maven Plugin Example with Spring Boot with Multiple Layers</description>

<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<docker.user>fabric8</docker.user>
<spring.version>2.3.3.RELEASE</spring.version>
</properties>

<dependencies>

<!-- Boot generator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>${spring.version}</version>
</dependency>

<!-- API, java.xml.bind module -->
<dependency>
<groupId>jakarta.xml.bind</groupId>
<artifactId>jakarta.xml.bind-api</artifactId>
<version>2.3.2</version>
</dependency>

<!-- Runtime, com.sun.xml.bind module -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.2</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>io.fabric8.maven.sample.springboot.layers.Application</mainClass>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.version}</version>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.34-SNAPSHOT</version>
<configuration>
<verbose>true</verbose>
<images>
<image>
<name>${docker.user}/dmp-sample-multi-assembly</name>
<build>
<from>fabric8/java-centos-openjdk8-jdk:1.5.6</from>
<assemblies>
<assembly>
<descriptorRef>dependencies</descriptorRef>
<name>deps</name>
<targetDir>/app/lib</targetDir>
</assembly>
<assembly>
<descriptorRef>artifact</descriptorRef>
<targetDir>/app</targetDir>
</assembly>
</assemblies>
<cmd>java -jar /app/${project.artifactId}-${project.version}.jar</cmd>
<ports>
<port>8080</port>
</ports>
</build>
<run>
<wait>
<log>Hello from Spring Boot!</log>
</wait>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>docker-build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<execution>
<id>docker-run</id>
<phase>verify</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.fabric8.maven.sample.springboot.layers;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
public class Application {
private static final Logger LOGGER = LoggerFactory.getLogger(Application.class);

@Bean
public CommandLineRunner commandLineRunner(ApplicationContext applicationContext) {
return new CommandLineRunner() {
@Override
public void run(String... args) {
LOGGER.info("Hello from Spring Boot!");
SpringApplication.exit(applicationContext);
}
};
}

public static void main(String[] args) {
SpringApplication.run(Application.class);
}
}
1 change: 1 addition & 0 deletions samples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@
<module>log</module>
<module>run-java</module>
<module>spring-boot-with-jib</module>
<module>multi-assembly</module>
</modules>
</project>

0 comments on commit 64ac850

Please sign in to comment.