question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to locate the project artifact during docker:build

See original GitHub issue

I am unable to really figure out which relative path is used by docker during the build process. Hence this request. The docker:build always fails with the output

[INFO] --- docker-maven-plugin:0.13.9:build (default-cli) @ sample-spring-boot-docker ---
[INFO] Copying files to /home/vagrant/SampleApp/greeting-service/target/docker/greeting-service/build/maven
[INFO] Building tar: /home/vagrant/SampleApp/greeting-service/target/docker/greeting-service/tmp/docker-build.tar
[ERROR] DOCKER> Error building image: lstat build/maven/sample-spring-boot-docker-0.1.0.jar: no such file or directory
[ERROR] DOCKER> lstat build/maven/sample-spring-boot-docker-0.1.0.jar: no such file or directory
[ERROR] DOCKER> lstat build/maven/sample-spring-boot-docker-0.1.0.jar: no such file or directory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

The pom.xml, Dockerfile and find output is given below:

<plugin>
                <groupId>org.jolokia</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.13.9</version>
                <configuration>
                    <images>
                        <image>
                        <name>greeting-service</name>
                        <build>
                            <assembly>
                                <descriptorRef>artifact</descriptorRef>
                                <dockerFileDir>.</dockerFileDir>
                            </assembly>
                        </build>
                        </image>
                    </images>
                </configuration>
            </plugin>
FROM somebaseimage

ADD sample-spring-boot-docker-0.1.0.jar app.jar
....
vagrant@greeting-service-host:~/SampleApp/greeting-service/target/docker$ find .
.
./greeting-service
./greeting-service/build
./greeting-service/build/maven
./greeting-service/build/maven/sample-spring-boot-docker-0.1.0.jar
./greeting-service/tmp
./greeting-service/tmp/docker-build.tar
./greeting-service/work

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
vrenjithcommented, Mar 13, 2017

@nitin-tiwari

pom.xml

	<build>
		<plugins>
			<plugin>
				<groupId>io.fabric8</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<version>0.14.0</version>
				<configuration>
					<images>
						<image>
							<alias>some-service-name-1</alias>
							<name>${localregistry}/${docker.image.prefix}/some-service-name</name>
							<build>
								<assembly>
									<descriptorRef>artifact</descriptorRef>
									<dockerFileDir>${project.basedir}/.</dockerFileDir>
								</assembly>
							</build>
							<run>
								<namingStrategy>alias</namingStrategy>
                                                                <envPropertyFile>LocalEnv</envPropertyFile>
								<net>pod-network</net>
								<ports>
                                                                        <port>8001:7199</port>
									<port>8000:8080</port>
								</ports>
							</run>
						</image>
					</images>
				</configuration>
				<executions>
					<execution>
						<id>start</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>build</goal>
							<goal>start</goal>
						</goals>
					</execution>
					<execution>
						<id>stop</id>
						<phase>post-integration-test</phase>
						<goals>
							<goal>stop</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins>
	</build>

Dockerfile

FROM which_ever_base_image
ADD maven/some-service-spring-boot-docker-0.1.0.jar app.jar
CMD java -jar app.jar
1reaction
rhusscommented, Feb 24, 2016

You have to distinguish between two build modes:

  • One with an assembly which is completely configured within the pom.xml
  • One with a dockerFileDir

Both are currently more or less orthogonal (however there is work to let a Dockerfile reference the assembly defined in the pom).

In your example you are using more or less both which at least seems to copy the assembly in the build directory. When you then use dockerFileDir then the build dir is the context dir for the Docker build. So you should use ADD maven/sample-spring-boot-docker-0.1.0.jar app.jar in the Dockerfile.

However, this approach is not recommended, since you would need to update the version number all the time. Instead you should use an assembly which maps the artifact name to a fixed outputFileName (this can be done in a custom assembly descriptor). Also, you could use a basedir / in the plugin’s build>assembly configuration so that it will be automatically added and you wouldn’t need to specify a dockerfile dir.

Do you have the full example as a github project ? If so, I could send you a PR with my suggestions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multi Module Maven Project and Docker: Cannot find artifact?
1-SNAPSHOT seems to be private, your Maven command inside Docker build needs to be able to either download it from private repository or...
Read more >
Artifacts file in Docker volumen not found - gitlab-runner
When I look into the runners file system I find the generated file under /builds/team/project/test.json for example.
Read more >
Quickstart: Store Docker container images in Artifact Registry
Artifact Registry provides a single location for managing private packages and Docker container images. This quickstart shows you how to:.
Read more >
CLI for JFrog Artifactory - JFrog CLI
Download all artifacts located in the my-local-repo repository with a jar extension to the all-my-frogs folder under the current directory. ? $ ...
Read more >
Jib Build - Skaffold
To use Jib, add a jib field to each artifact you specify in the artifacts part ... To build a Maven multi-module project,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found