java - How to create a Dockerfile with Maven on a Windows box and then sent to a remote Linux server for building an image and then ran? -


i have java project building maven. want dynamically create dockerfile when builds. end goal create executable jar , dockerfile, send them both server dockerfile used build image execute jar , run container. used in build/test process don't want commit code or publish jar artifactory of sort before each test. feel 4 separate authentications server inefficient. i've tried find maven plugin can of without luck. there plugin that can of me or better way i'm doing? in advance. mark answers helpful if , mark correct answer such. in advance! below current progress maven plugin work.

<!--this plugin transfer executable jar , dockerfile file remote server, build image , run -->         <plugin>             <groupid>org.apache.maven.plugins</groupid>             <artifactid>maven-antrun-plugin</artifactid>             <version>1.8</version>             <executions>                 <execution>                     <phase>install</phase>                     <goals>                         <goal>run</goal>                     </goals>                     <configuration>                         <tasks>                             <!-- create docerfile -->                              <echo file="${project.build.directory}/dockerfile.txt"                                    message="from java:8${line.separator}"                                    append="true"/>                             <echo file="${project.build.directory}/dockerfile.txt"                                   message="add ${pi.deploydirectory}/${project.build.finalname}-jar-with-dependencies.jar ${pi.deploydirectory}/demo/${project.build.finalname}-jar-with-dependencies.jar${line.separator}"                                   append="true"/>                             <echo file="${project.build.directory}/dockerfile.txt"                                    message="cmd [&quot;java&quot;,&quot;-jar&quot;,&quot;${pi.deploydirectory}/demo/${project.build.finalname}-jar-with-dependencies.jar&quot;]"                                   append="true"/>                              <!-- ensure target directory exists on server -->                             <sshexec host="${server.host}" port="${server.port}" username="${server.user}" password="${server.password}"                                       trust="true" failonerror="false" verbose="true"                                       command="mkdir --parents ${server.deploydirectory}"/>                              <!-- copy jar file server -->                             <scp                                 file="${project.build.directory}/${project.build.finalname}-jar-with-dependencies.jar"                                 todir="${server.user}:${server.password}@${server.host}:${server.deploydirectory}"                                 port="${server.port}" trust="true" verbose="true" failonerror="true">                             </scp>                               <!-- copy dockerfile file server -->                             <scp                                 file="${project.build.directory}/${project.build.finalname}-jar-with-dependencies.jar"                                 todir="${server.user}:${server.password}@${server.host}:${server.deploydirectory}"                                 port="${server.port}" trust="true" verbose="true" failonerror="true">                             </scp>                               <!-- todo: add section on remote server build container using new dockerfile , run container -->                              <!-- run jar file on server no in container-->                             <sshexec host="${server.host}" port="${server.port}" username="${server.user}"                                      password="${server.password}" trust="true" failonerror="false"                                      verbose="true"                                       command="java -jar ${server.deploydirectory}/${project.build.finalname}-jar-with-dependencies.jar"/>                         </tasks>                     </configuration>                 </execution>             </executions>             <dependencies>                 <dependency>                     <groupid>org.apache.ant</groupid>                     <artifactid>ant-jsch</artifactid>                     <version>1.9.6</version>                 </dependency>             </dependencies>         </plugin> 


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -