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

Building image without assembly #236

Closed
ngreatorex opened this issue Jul 25, 2015 · 1 comment
Closed

Building image without assembly #236

ngreatorex opened this issue Jul 25, 2015 · 1 comment
Assignees
Milestone

Comments

@ngreatorex
Copy link

I'm trying to build a Docker image from an existing image where the only change is to run a command. In this case it is to enable a plugin on RabbitMQ. Here's what I tried:

<plugin>
    <groupId>org.jolokia</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.13.2</version>

    <configuration>
        <images>
            <image>
                <alias>broker</alias>
                <name>${project.artifactId}-rabbitmq</name>
                <build>
                    <from>rabbitmq:management</from>
                    <runCmds>
                        <run>rabbitmq-plugins enable rabbitmq_consistent_hash_exchange</run>
                    </runCmds>
                </build>
                <run>
                    <ports>
                        <port>rabbitmq.port:5672</port>
                        <port>rabbitmq.management-port:15672</port>
                    </ports>
                    <log>
                        <prefix>MQ</prefix>
                        <date>DEFAULT</date>
                        <color>YELLOW</color>
                    </log>
                    <wait>
                        <log>Server startup complete</log>
                        <time>20000</time>
                    </wait>
                </run>
            </image>
        </images>
    </configuration>
</plugin>

However, this gives an exception on running mvn docker:build:

[ERROR] Failed to execute goal org.jolokia:docker-maven-plugin:0.13.2:build (default-cli) on project spring-sprong: Execution default-cli of goal org.jolokia:docker-maven-plugin:0.13.2:build failed. NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jolokia:docker-maven-plugin:0.13.2:build (default-cli) on project spring-sprong: Execution default-cli of goal org.jolokia:docker-maven-plugin:0.13.2:build failed.
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.jolokia:docker-maven-plugin:0.13.2:build failed.
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:143)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: java.lang.NullPointerException
    at org.jolokia.docker.maven.assembly.DockerAssemblyManager.createDockerTarArchive(DockerAssemblyManager.java:85)
    at org.jolokia.docker.maven.AbstractBuildSupporMojo.buildImage(AbstractBuildSupporMojo.java:79)
    at org.jolokia.docker.maven.BuildMojo.executeInternal(BuildMojo.java:36)
    at org.jolokia.docker.maven.AbstractDockerMojo.execute(AbstractDockerMojo.java:168)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    ... 20 more

This is the same error as in issue #214, but in this case I have a more sensible config!

I then tried adding a blank assembly element:

<plugin>
    <groupId>org.jolokia</groupId>
    <artifactId>docker-maven-plugin</artifactId>
    <version>0.13.2</version>

    <configuration>
        <images>
            <image>
                <alias>broker</alias>
                <name>${project.artifactId}-rabbitmq</name>
                <build>
                    <from>rabbitmq:management</from>
                    <runCmds>
                        <run>rabbitmq-plugins enable rabbitmq_consistent_hash_exchange</run>
                    </runCmds>
                    <assembly/>
                </build>
                <run>
                    <ports>
                        <port>rabbitmq.port:5672</port>
                        <port>rabbitmq.management-port:15672</port>
                    </ports>
                    <log>
                        <prefix>MQ</prefix>
                        <date>DEFAULT</date>
                        <color>YELLOW</color>
                    </log>
                    <wait>
                        <log>Server startup complete</log>
                        <time>20000</time>
                    </wait>
                </run>
            </image>
            ...
        </images>
    </configuration>
</plugin>

This gives a different error:

[ERROR] DOCKER> Error building image: maven: no such file or directory
[ERROR] DOCKER> maven: no such file or directory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.034 s
[INFO] Finished at: 2015-07-25T23:23:45+01:00
[INFO] Final Memory: 30M/124M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.jolokia:docker-maven-plugin:0.13.2:build (default-cli) on project spring-sprong: maven: no such file or directory  -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.jolokia:docker-maven-plugin:0.13.2:build (default-cli) on project spring-sprong: maven: no such file or directory 
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.MojoExecutionException: maven: no such file or directory 
    at org.jolokia.docker.maven.AbstractDockerMojo.execute(AbstractDockerMojo.java:170)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    ... 19 more
Caused by: org.jolokia.docker.maven.access.DockerAccessException: maven: no such file or directory 
    at org.jolokia.docker.maven.access.chunked.BuildResponseHandler.process(BuildResponseHandler.java:28)
    at org.jolokia.docker.maven.access.chunked.BuildResponseHandler.process(BuildResponseHandler.java:7)
    at org.jolokia.docker.maven.access.chunked.TextToJsonBridgeCallback.process(TextToJsonBridgeCallback.java:23)
    at org.jolokia.docker.maven.access.chunked.TextToJsonBridgeCallback.process(TextToJsonBridgeCallback.java:9)
    at org.jolokia.docker.maven.access.chunked.ChunkedResponseReader.process(ChunkedResponseReader.java:25)
    at org.jolokia.docker.maven.access.hc.DockerAccessWithHcClient.processChunkedResponse(DockerAccessWithHcClient.java:411)
    at org.jolokia.docker.maven.access.hc.DockerAccessWithHcClient.buildImage(DockerAccessWithHcClient.java:111)
    at org.jolokia.docker.maven.AbstractBuildSupporMojo.buildImage(AbstractBuildSupporMojo.java:81)
    at org.jolokia.docker.maven.BuildMojo.executeInternal(BuildMojo.java:36)
    at org.jolokia.docker.maven.AbstractDockerMojo.execute(AbstractDockerMojo.java:168)
    ... 21 more

I am temporarily adding an extra file to the image to work around this, but obviously this isn't ideal. Is it possible to build an image without adding any files (i.e. without an assembly config), and if so how?

Thanks.

PS. Great work on a great plugin!

@jgangemi
Copy link
Collaborator

the user manual states you can omit the assembly section if you don't need to include any files, so my guess is this is a bug/regression. i will see about finding some time today to investigate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants