Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WINDUP-3763 Added 'multi-arch' profile to multi-arch CLI container build #75

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ So sign up yourself to Quay.io at https://quay.io/signin/ taking care that the Q
6. Paste that command in a shell window on your local machine and execute it
7. Now your local Docker installation will have the credentials in ~/.docker/config.json

### Create Docker images
### Create Container images
1. Build this project: `$ mvn clean install -Ddocker.name.windup.web=<your_quay_id>/windup-web-openshift -Ddocker.name.windup.web.executor=<your_quay_id>/windup-web-openshift-messaging-executor`
1. Push images to docker hub:
1. `$ docker login`
Expand All @@ -40,6 +40,13 @@ So sign up yourself to Quay.io at https://quay.io/signin/ taking care that the Q

If you want you can also set the tag for the built images (e.g. if you are working on a specific branch and you want to create images tagged with the branch name), you just have to add the tag name to the `docker.name.windup.web` and `docker.name.windup.web.executor` system properties' values (i.e. from the above example `-Ddocker.name.windup.web=<your_quay_id>/windup-web-openshift:tag_value -Ddocker.name.windup.web.executor=<your_quay_id>/windup-web-openshift-messaging-executor:tag_value`)

### Create CLI multi-arch container image
1. Login to Quay.io container repository executing
`$ docker login quay.io`
1. Build the CLI multi-arch container and push it to Quay repository
`$ mvn clean install -DskipTests -f cli/ -Dmulti-arch -Ddocker.name.windup.cli=quay.io/<your_quay_id>/windup-cli-openshift`


### Point to your images
Now that your images are available on Quay.io repository, you have to reference them in WINDUP template in order to use these images in the deployments.
1. open [`./templates/src/main/resources/web-template-empty-dir-executor.json`](templates/src/main/resources/web-template-empty-dir-executor.json) in an IDE or text editor
Expand Down
209 changes: 163 additions & 46 deletions cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@

<properties>
<docker.name.windup.cli>%a:%v</docker.name.windup.cli>
<from.image>registry.access.redhat.com/ubi8/openjdk-11:latest</from.image>
<entrypoint>/opt/migrationtoolkit/bin/windup-cli</entrypoint>
<targetDir>/opt</targetDir>
<outputDirectory>migrationtoolkit/</outputDirectory>
<permission>774</permission>
</properties>

<dependencyManagement>
Expand All @@ -27,52 +32,6 @@

<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${version.jkube}</version>
<executions>
<execution>
<id>jkube</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<buildStrategy>docker</buildStrategy>
<autoPull>always</autoPull>
<images>
<image>
<name>${docker.name.windup.cli}</name>
<build>
<from>registry.access.redhat.com/ubi8/openjdk-11:latest</from>
<cmd>/opt/migrationtoolkit/bin/windup-cli</cmd>
<assembly>
<targetDir>/opt</targetDir>
<exportTargetDir>false</exportTargetDir>
<excludeFinalOutputArtifact>true</excludeFinalOutputArtifact>
<permissions>keep</permissions>
<mode>tgz</mode>
<layers>
<layer>
<fileSets>
<fileSet>
<directory>${project.build.directory}/windup-cli/${product-name}-cli-${version.windup.cli}/</directory>
<outputDirectory>migrationtoolkit/</outputDirectory>
<directoryMode>0774</directoryMode>
<fileMode>0774</fileMode>
</fileSet>
</fileSets>
</layer>
</layers>
</assembly>
</build>
</image>
</images>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
Expand Down Expand Up @@ -100,4 +59,162 @@
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
<property>
<name>!multi-arch</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>kubernetes-maven-plugin</artifactId>
<version>${version.jkube}</version>
<executions>
<execution>
<id>jkube</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
<configuration>
<buildStrategy>docker</buildStrategy>
<autoPull>always</autoPull>
<images>
<image>
<name>${docker.name.windup.cli}</name>
<build>
<from>${from.image}</from>
<entryPoint>
<shell>${entrypoint}</shell>
</entryPoint>
<assembly>
<targetDir>${targetDir}</targetDir>
<exportTargetDir>false</exportTargetDir>
<excludeFinalOutputArtifact>true</excludeFinalOutputArtifact>
<permissions>keep</permissions>
<mode>tgz</mode>
<layers>
<layer>
<fileSets>
<fileSet>
<directory>${project.build.directory}/windup-cli/${product-name}-cli-${version.windup.cli}/</directory>
<outputDirectory>${outputDirectory}</outputDirectory>
<directoryMode>0${permission}</directoryMode>
<fileMode>0${permission}</fileMode>
</fileSet>
</fileSets>
</layer>
</layers>
</assembly>
</build>
</image>
</images>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>multi-arch</id>
<activation>
<property>
<name>multi-arch</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>create-empty-directory</id>
<phase>process-classes</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<!--
The project has no 'src' folder so no 'target/classes' folder
will be created along the build process BUT the above jib-maven-plugin
always searches for classes in the 'target/classes' folder and
when not found it blocks with an error.
That's why there's this task for creating such empty folder.
-->
<mkdir dir="${project.build.outputDirectory}"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
<configuration>
<containerizingMode>packaged</containerizingMode>
<from>
<image>${from.image}</image>
<platforms>
<platform>
<architecture>amd64</architecture>
<os>linux</os>
</platform>
<platform>
<architecture>arm64</architecture>
<os>linux</os>
</platform>
<platform>
<architecture>ppc64le</architecture>
<os>linux</os>
</platform>
<platform>
<architecture>s390x</architecture>
<os>linux</os>
</platform>
</platforms>
</from>
<to>
<image>${docker.name.windup.cli}</image>
</to>
<container>
<entrypoint>${entrypoint}</entrypoint>
</container>
<extraDirectories>
<paths>
<path>
<from>${project.build.directory}/windup-cli/${product-name}-cli-${version.windup.cli}/</from>
<into>${targetDir}/${outputDirectory}</into>
</path>
</paths>
<permissions>
<permission>
<file>${targetDir}/${outputDirectory}**</file>
<mode>${permission}</mode>
</permission>
</permissions>
</extraDirectories>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>