Skip to content

Commit

Permalink
build: make container build part of tar package
Browse files Browse the repository at this point in the history
Motivation:
The docker image is built from the tar package, however as being a
different module the dependency resolution is quite complicated, thus
the module is always disabled. As a part of tar packaging, the building
of containers much simpler and can be a part of standard pipeline.

Modification:
Move container build as a part of tar packaging. Switch to io.fabric8
maven plugin.

Result:

mvn -am -pl packages/tar -P container package

Acked-by: Lea Morschel
Target: master
Require-book: no
Require-notes: yes
  • Loading branch information
kofemann committed Apr 18, 2023
1 parent c8b83db commit a760a0b
Show file tree
Hide file tree
Showing 11 changed files with 313 additions and 221 deletions.
14 changes: 4 additions & 10 deletions BUILDING.md
Expand Up @@ -91,20 +91,14 @@ module:
Building a docker image
-----------------------

Building a docker image is disabled by default. This is because it
Building a container image is disabled by default. This is because it
requires a running docker deployment, which not all developers have
installed.

You may enable building of docker images by activating the `docker`
profile; e.g.,
You may enable building of docker images by activating the `container`
profile for the `tar` packaging:

mvn clean package -Pdocker

To build only the docker image, you may select the docker module,
`packages/docker` explicitly, as above. However, it is still required
to enable the `docker` profile; e.g.,

mvn clean package -am -pl packages/docker -Pdocker
mvn clean package -am -pl packages/tar -P container


The system-test module
Expand Down
14 changes: 0 additions & 14 deletions packages/docker/Dockerfile

This file was deleted.

89 changes: 0 additions & 89 deletions packages/docker/pom.xml

This file was deleted.

9 changes: 0 additions & 9 deletions packages/pom.xml
Expand Up @@ -224,13 +224,4 @@
<module>system-test</module>
</modules>

<profiles>
<profile>
<id>docker</id>

<modules>
<module>docker</module>
</modules>
</profile>
</profiles>
</project>
237 changes: 138 additions & 99 deletions packages/tar/pom.xml
@@ -1,110 +1,149 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.dcache</groupId>
<artifactId>packaging</artifactId>
<version>9.1.0-SNAPSHOT</version>
</parent>
<parent>
<groupId>org.dcache</groupId>
<artifactId>packaging</artifactId>
<version>9.1.0-SNAPSHOT</version>
</parent>

<artifactId>dcache-tar</artifactId>
<packaging>pom</packaging>
<artifactId>dcache-tar</artifactId>
<packaging>pom</packaging>

<name>dCache tarball packaging</name>
<name>dCache tarball packaging</name>

<properties>
<modules>${project.basedir}/..</modules>
<skel>${project.basedir}/../../skel</skel>
<filtered-skel>${project.basedir}/target/filtered-skel</filtered-skel>
</properties>
<properties>
<modules>${project.basedir}/..</modules>
<skel>${project.basedir}/../../skel</skel>
<filtered-skel>${project.basedir}/target/filtered-skel</filtered-skel>
</properties>

<build>
<finalName>dcache-${tar.version}</finalName>
<plugins>
<build>
<finalName>dcache-${tar.version}</finalName>
<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>tar.version</name>
<value>${project.version}</value>
<regex>-SNAPSHOT</regex>
<replacement>-\${git.commit.id.abbrev}</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>regex-property</id>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>tar.version</name>
<value>${project.version}</value>
<regex>-SNAPSHOT</regex>
<replacement>-\${git.commit.id.abbrev}</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<!-- The files in our skel directory need some
variable substitution.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<!-- The files in our skel directory need some
variable substitution.
The assembly plugin however only supports
${} substitution and that conflicts with
shell variables and dCache configuration
properties.
The assembly plugin however only supports
${} substitution and that conflicts with
shell variables and dCache configuration
properties.
Therefore we use the resource plugin to
make a filtered copy of the skel and use
those files in the assembly whenever we
need a filtered file. -->
<id>copy-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${filtered-skel}</outputDirectory>
<resources>
<resource>
<directory>${skel}</directory>
<filtering>true</filtering>
</resource>
</resources>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
<filters>
<filter>${project.basedir}/src/main/assembly/filter.properties</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
Therefore we use the resource plugin to
make a filtered copy of the skel and use
those files in the assembly whenever we
need a filtered file. -->
<id>copy-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${filtered-skel}</outputDirectory>
<resources>
<resource>
<directory>${skel}</directory>
<filtering>true</filtering>
</resource>
</resources>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
<filters>
<filter>${project.basedir}/src/main/assembly/filter.properties</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/tar.xml</descriptor>
</descriptors>
<formats>
<format>tar.gz</format>
</formats>
<appendAssemblyId>false</appendAssemblyId>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/main/assembly/tar.xml</descriptor>
</descriptors>
<formats>
<format>tar.gz</format>
</formats>
<appendAssemblyId>false</appendAssemblyId>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>container</id>

<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.42.1</version>
<configuration>
<images>
<image>
<name>%g/dcache:%l</name>
<build>
<dockerFile>${basedir}/src/main/container/Dockerfile</dockerFile>
<assembly>
<descriptor>${basedir}/src/main/assembly/tar.xml</descriptor>
</assembly>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit a760a0b

Please sign in to comment.