From b414b9b065c45b8d26cc76b978b37f727f15cfd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20Hu=C3=9F?= Date: Sat, 6 Apr 2019 19:54:20 +0200 Subject: [PATCH] chore: Some minor fixes (#1188) --- doc/changelog.md | 3 ++- src/main/asciidoc/inc/build/_overview.adoc | 26 +++++++++++++++++-- .../maven/docker/util/DockerFileUtil.java | 14 ---------- .../maven/docker/util/DockerFileUtilTest.java | 4 +-- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/doc/changelog.md b/doc/changelog.md index 43bfa50cd..7810fb062 100644 --- a/doc/changelog.md +++ b/doc/changelog.md @@ -12,7 +12,8 @@ - Support docker SHELL setting for runCmds (#1157) - Added 'autoRemove' option for running containers (#1179) - Added support for AWS EC2 instance roles when pushing to AWS ECR (#1186) - + - Add support for auto-pulling multiple base image for multi stage builds (#1057) + * **0.28.0** (2018-12-13) - Update to JMockit 1.43 - Compiles with Java 11 diff --git a/src/main/asciidoc/inc/build/_overview.adoc b/src/main/asciidoc/inc/build/_overview.adoc index c15f16239..6e61ebfec 100644 --- a/src/main/asciidoc/inc/build/_overview.adoc +++ b/src/main/asciidoc/inc/build/_overview.adoc @@ -26,7 +26,7 @@ The files of the assembly are stored in a build context relative directory `mave E.g. the files can be added with .Example -[source,dockerfils] +[source,dockerfile] ---- COPY maven/ /my/target/directory ---- @@ -34,8 +34,30 @@ COPY maven/ /my/target/directory so that the assembly files will end up in `/my/target/directory` within the container. If this directory contains a `.maven-dockerignore` (or alternatively, a `.maven-dockerexclude` file), then it is used for excluding files for the build. Each line in this file is treated as a http://ant.apache.org/manual/Types/fileset.html[FileSet exclude pattern] as used by the http://maven.apache.org/plugins/maven-assembly-plugin[maven-assembly-plugin]. It is similar to `.dockerignore` when using Docker but has a slightly different syntax (hence the different name). +<> is an example which excludes all compiled Java classes. -If this directory contains a `.maven-dockerinclude` file, then it is used for including only those files for the build. Each line in this file is also treated as a http://ant.apache.org/manual/Types/fileset.html[FileSet exclude pattern] as used by the http://maven.apache.org/plugins/maven-assembly-plugin[maven-assembly-plugin]. +[[ex-build-dockerexclude]] +.Example `.maven-dockerexclude` or `.maven-dockerignore` +==== +[source] +---- +target/classes/** # <1> +---- +<1> Exclude all compiled classes +==== + + +If this directory contains a `.maven-dockerinclude` file, then it is used for including only those files for the build. Each line in this file is also treated as a http://ant.apache.org/manual/Types/fileset.html[FileSet exclude pattern] as used by the http://maven.apache.org/plugins/maven-assembly-plugin[maven-assembly-plugin]. <> shows how to include only jar file that have build to the Docker build context. + +[[ex-build-dockerinclude]] +.Example `.maven-dockerinclude` +==== +[source] +---- +target/*.jar # <1> +---- +<1> Only add jar file to you Docker build context. +==== Except for the <> all other configuration options are ignored for now. diff --git a/src/main/java/io/fabric8/maven/docker/util/DockerFileUtil.java b/src/main/java/io/fabric8/maven/docker/util/DockerFileUtil.java index 4538bb975..06dceef70 100644 --- a/src/main/java/io/fabric8/maven/docker/util/DockerFileUtil.java +++ b/src/main/java/io/fabric8/maven/docker/util/DockerFileUtil.java @@ -42,20 +42,6 @@ public class DockerFileUtil { private DockerFileUtil() {} - /** - * Extract the base image from a dockerfile. The first line containing a FROM is - * taken. - * - * @param dockerFile file from where to extract the base image - * @param interpolator interpolator for replacing properties - * @deprecated Use {@link DockerFileUtil#extractBaseImages} extractBaseImages instead - */ - @Deprecated - public static String extractBaseImage(File dockerFile, FixedStringSearchInterpolator interpolator) throws IOException { - List result = extractBaseImages(dockerFile, interpolator); - return result.isEmpty() ? null : result.iterator().next(); - } - /** * Extract the base images from a dockerfile. All lines containing a FROM is * taken. diff --git a/src/test/java/io/fabric8/maven/docker/util/DockerFileUtilTest.java b/src/test/java/io/fabric8/maven/docker/util/DockerFileUtilTest.java index 26b707140..1bf9c9d25 100644 --- a/src/test/java/io/fabric8/maven/docker/util/DockerFileUtilTest.java +++ b/src/test/java/io/fabric8/maven/docker/util/DockerFileUtilTest.java @@ -44,8 +44,8 @@ public class DockerFileUtilTest { @Test public void testSimple() throws Exception { File toTest = copyToTempDir("Dockerfile_from_simple"); - assertEquals("fabric8/s2i-java", DockerFileUtil.extractBaseImage( - toTest, FixedStringSearchInterpolator.create())); + assertEquals("fabric8/s2i-java", DockerFileUtil.extractBaseImages( + toTest, FixedStringSearchInterpolator.create()).get(0)); } @Test