Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

Specifying external Dockerfile broken #1097

Closed
hazim1093 opened this issue Nov 20, 2017 · 6 comments
Closed

Specifying external Dockerfile broken #1097

hazim1093 opened this issue Nov 20, 2017 · 6 comments
Assignees
Labels
group/dmp Features releated to docker-maven-plugin status/never-stale Pin this issue to get never marked as stale by stale-bot

Comments

@hazim1093
Copy link
Contributor

hazim1093 commented Nov 20, 2017

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

@rasheedamir
Copy link

Hi @ro14nd @nicolaferraro can you please guide how we can fix above issue?

@hrishin hrishin modified the milestone: Sprint 141 Nov 22, 2017
@rohanKanojia rohanKanojia added the group/dmp Features releated to docker-maven-plugin label Jul 24, 2018
@stale
Copy link

stale bot commented Oct 23, 2018

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale Issue/PR considered to be stale label Oct 23, 2018
@stale stale bot closed this as completed Oct 30, 2018
@edrandall
Copy link

This bug still exists on f-m-p 3.5.42

@rohanKanojia rohanKanojia reopened this Feb 25, 2019
@stale stale bot removed the status/stale Issue/PR considered to be stale label Feb 25, 2019
@rohanKanojia rohanKanojia added the status/never-stale Pin this issue to get never marked as stale by stale-bot label Feb 25, 2019
@edrandall
Copy link

edrandall commented 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.

@devang-gaur
Copy link
Contributor

  1. For the external Dockerfile mode, either dockerFile should be specified or, contextDir or dockerFileDir (deprecated now) should be specified under section in the XML configuration mode.

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.

When you use the XML config mode for specifying image configuration in ... section, the user has to explicitly define the whole image configuration by themselves.

Something like this

<image>
                  <name>spring-boot-sample</name>
                  <build>
                    <from>nginx</from>
                    <assembly>
                      <mode>tgz</mode>
                      <basedir>/opt/application</basedir>
                      <inline>
                        <id>add-files</id>
                        <fileSets>
                          <fileSet>
                            <directory>${project.basedir}/src/main/resources/addJars</directory>
                            <includes>
                              <include>*.jar</include>
                            </includes>
                            <outputDirectory>lib</outputDirectory>
                          </fileSet>
                          <fileSet>
                            <directory>${project.basedir}/src/main/resources/conf</directory>
                            <includes>
                              <include>**.*</include>
                            </includes>
                            <outputDirectory>etc/conf</outputDirectory>
                          </fileSet>
                        </fileSets>
                      </inline>
                    </assembly>
                    <contextDir>.</contextDir>
                  </build>
                </image>

@devang-gaur
Copy link
Contributor

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 #1814

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
group/dmp Features releated to docker-maven-plugin status/never-stale Pin this issue to get never marked as stale by stale-bot
Projects
None yet
Development

No branches or pull requests

6 participants