reduce ccsdk-ansible-server image footprint
[ccsdk/distribution.git] / ansible-server / pom.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <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/maven-v4_0_0.xsd">
3
4    <parent>
5         <groupId>org.onap.ccsdk.parent</groupId>
6         <artifactId>odlparent-lite</artifactId>
7         <version>1.2.1-SNAPSHOT</version>
8     </parent>
9
10     <modelVersion>4.0.0</modelVersion>
11     <packaging>pom</packaging>
12     <groupId>org.onap.ccsdk.distribution</groupId>
13     <artifactId>ansible-server</artifactId>
14     <version>0.4.1-SNAPSHOT</version>
15
16     <name>ccsdk :: distribution :: ${project.artifactId}</name>
17     <description>Creates ansible-server Docker container</description>
18
19     <properties>
20         <image.name>onap/ccsdk-ansible-server-image</image.name>
21         <ccsdk.project.version>${project.version}</ccsdk.project.version>
22               <ccsdk.distribution.version>${project.version}</ccsdk.distribution.version>
23         <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy>
24         <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
25     </properties>
26
27
28     <build>
29         <plugins>
30             <plugin>
31                 <groupId>org.codehaus.groovy.maven</groupId>
32                 <artifactId>gmaven-plugin</artifactId>
33                 <executions>
34                     <execution>
35                         <phase>validate</phase>
36                         <goals>
37                             <goal>execute</goal>
38                         </goals>
39                         <configuration>
40                             <source>
41                                 println project.properties['ccsdk.project.version'];
42                                 def versionArray;
43                                 if ( project.properties['ccsdk.project.version'] != null ) {
44                                 versionArray = project.properties['ccsdk.project.version'].split('\\.');
45                                 }
46
47                                 if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT"))
48                                 {
49                                 project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest";
50                                 } else {
51                                 project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest";
52                                 }
53
54                                 println 'New Tag for docker:' + project.properties['project.docker.latesttag.version'];
55                             </source>
56                         </configuration>
57                     </execution>
58                 </executions>
59             </plugin>
60
61             <plugin>
62                 <artifactId>maven-resources-plugin</artifactId>
63                 <version>2.6</version>
64                 <executions>
65                     <execution>
66                         <id>copy-dockerfile</id>
67                         <goals>
68                             <goal>copy-resources</goal>
69                         </goals><!-- here the phase you need -->
70                         <phase>validate</phase>
71                         <configuration>
72                             <outputDirectory>${basedir}/target/docker-stage</outputDirectory>
73                             <resources>
74                                 <resource>
75                                     <directory>src/main</directory>
76                                     <includes>
77                                         <include>**/*</include>
78                                     </includes>
79                                     <filtering>false</filtering>
80                                 </resource>
81                             </resources>
82                         </configuration>
83                     </execution>
84                 </executions>
85             </plugin>
86
87             <plugin>
88                 <artifactId>exec-maven-plugin</artifactId>
89                 <groupId>org.codehaus.mojo</groupId>
90                 <version>1.5.0</version>
91                 <executions>
92                     <execution>
93                         <id>change python permissions</id>
94                         <phase>process-sources</phase>
95                         <goals>
96                             <goal>exec</goal>
97                         </goals>
98                         <configuration>
99                             <executable>/usr/bin/find</executable>
100                             <arguments>
101                                 <argument>${basedir}/target/docker-stage/ansible-server</argument>
102                                 <argument>-name</argument>
103                                 <argument>*.py</argument>
104                                 <argument>-exec</argument>
105                                 <argument>chmod</argument>
106                                 <argument>+x</argument>
107                                 <argument>{}</argument>
108                                 <argument>;</argument>
109                             </arguments>
110                         </configuration>
111                     </execution>
112                 </executions>
113             </plugin>
114         </plugins>
115     </build>
116
117     <profiles>
118         <profile>
119             <id>docker</id>
120             <build>
121                 <plugins>
122                     <plugin>
123                         <groupId>io.fabric8</groupId>
124                         <artifactId>docker-maven-plugin</artifactId>
125                         <version>0.16.5</version>
126                         <inherited>false</inherited>
127                         <configuration>
128                             <images>
129                                 <image>
130                                     <name>${image.name}</name>
131                                     <build>
132                                         <cleanup>try</cleanup>
133                                         <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir>
134                                         <dockerFile>${basedir}/target/docker-stage/Dockerfile</dockerFile>
135                                         <tags>
136                                             <tag>${project.version}</tag>
137                                             <tag>${project.version}-STAGING-${maven.build.timestamp}</tag>
138                                             <tag>${project.docker.latesttag.version}</tag>
139                                         </tags>
140                                     </build>
141                                 </image>
142                             </images>
143                         </configuration>
144                         <executions>
145                             <execution>
146                                 <id>generate-images</id>
147                                 <phase>package</phase>
148                                 <goals>
149                                     <goal>build</goal>
150                                 </goals>
151                             </execution>
152
153                             <execution>
154                                 <id>push-images</id>
155                                 <phase>deploy</phase>
156                                 <goals>
157                                     <goal>build</goal>
158                                     <goal>push</goal>
159                                 </goals>
160                             </execution>
161                         </executions>
162                     </plugin>
163                 </plugins>
164             </build>
165         </profile>
166     </profiles>
167     <organization>
168         <name>ONAP</name>
169     </organization>
170 </project>