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.

Specifying external Dockerfile broken

See original GitHub issue

Description

Specifying an external dockerfile for springboot based project doesn’t work as expected and as mentioned in the documentation.

  • Placing the Dockerfile in default location i.e. src/main/docker, doesn’t have any effect on the build and fmp continues to use the default dockerfile instead of the external one. By specifying the dockerFileDir as ./, fmp was able to read the dockerfile. ./ refers to the exact same location src/main/docker which should have been set by default.

  • As mentioned in the documentation, the default location for assembly is maven/, but copying from this location in the dockerfile fails with the error No such file or directory found. Where as the default dockerfile used by fmp copy’s from the same location maven/ and does not fail.

Info

  • f-m-p version : 3.5.31
  • Maven version (mvn -v) : 3.3.9
  • Kubernetes / OpenShift setup and version : Kubernetes v1.7.8

Steps to reproduce:

  1. Create a Dockerfile identical to the one fmp uses by default, just change the base image (what I intended to do)
FROM myownbase
ENV JAVA_APP_DIR /deployments
COPY maven /deployments/
EXPOSE 8080 8778 9779
  1. Place the Dockerfile in src/main/docker, fmp won’t pick it up.
  2. Specify dockerfile directory in pom.xml
                    <images>
                        <image>
                            <name>my-own-image</name>
                            <build>
                                <dockerFileDir>./</dockerFileDir>
                            </build>
                        </image>
                    </images>

fmp will now pick it up and build using this dockerfile, But FAIL at the COPY maven /deployments/ step, as it would be unable to find the maven directory.

Workaround:

By @jstrachan

create a custom base image separately then just reference it like this https://github.com/fabric8io/generator-backend/blob/master/pom.xml#L39

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
edrandallcommented, Mar 2, 2019

When using an external Dockerfile, you get a default BusyBox image unless you specify dockerFileDir;

<plugin>
	<groupId>io.fabric8</groupId>
	<artifactId>fabric8-maven-plugin</artifactId>
	<version>3.5.42</version>
	<configuration>
		<mode>openshift</mode>
		<buildStrategy>docker</buildStrategy>
		<verbose>true</verbose>
		<images>
			<image>
				<!-- @see https://dmp.fabric8.io/#image-name -->
				<name>%g/%a:%t</name>
				<alias>%a</alias>
				<build>
					<dockerFileDir>.</dockerFileDir>
				</build>
			</image>
		</images>
	</configuration>
</plugin>

It would be better if it failed right away than give an unwanted/incorrect default busybox image too.

0reactions
dev-gaurcommented, May 8, 2020

I guess what the user might be looking for here, is the simple dockerfile build (https://maven.fabric8.io/#simple-dockerfile-build ) where they specify the dockerfile on projects’ base directory location and nothing in XML config.,

This feature also has a problem since the Dockerfile isn’t being picked up in the simple dockerfile build mode, I have created an issue for that… Closing this issue in favour of https://github.com/fabric8io/fabric8-maven-plugin/issues/1814

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to include files outside of Docker's build context?
The best way to work around this is to specify the Dockerfile independently of the build context, using -f. For instance, this command...
Read more >
Best practices for writing Dockerfiles - Docker Documentation
By “ephemeral”, we mean that the container can be stopped and destroyed, then rebuilt and replaced with an absolute minimum set up and...
Read more >
9 Common Dockerfile Mistakes - Runnablog
9 Common Dockerfile Mistakes · 1. Running apt-get · 2. Using ADD instead of COPY · 3. Adding your entire application directory in...
Read more >
How to Include Files Outside of Docker's Build Context
In general, the Docker build command restricts the sources of files we can use in our Docker images. We specify a build context, ......
Read more >
Why new Macs break your Docker build, and how to fix it
New Macs can break your Docker image build in unexpected ways; ... You're much better off specifying on a per-image basis whether it's ......
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