Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Commit

Permalink
Merge pull request #89 from npiguet/master
Browse files Browse the repository at this point in the history
Added support for supplying a custom Dockerfile location on build
  • Loading branch information
mattnworb authored Jan 15, 2019
2 parents eeffcd9 + 580f84d commit f3509a1
Show file tree
Hide file tree
Showing 13 changed files with 353 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bar
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
ADD resources/foo.txt /foo.txt
MAINTAINER David Flemström <dflemstr@spotify.com>
58 changes: 58 additions & 0 deletions plugin/src/it/build-with-custom-dockerfile/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-/-/-
Dockerfile Maven Plugin
%%
Copyright (C) 2015 - 2016 Spotify AB
%%
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-\-\-
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.spotify.it</groupId>
<artifactId>build-with-custom-dockerfile</artifactId>
<version>1.0-SNAPSHOT</version>

<description>The Dockerfile is manually specified by the user</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
</goals>
<configuration>
<repository>test/build-with-custom-dockerfile</repository>
<contextDirectory>context</contextDirectory>
<dockerfile>context/sub/Dockerfile</dockerfile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
30 changes: 30 additions & 0 deletions plugin/src/it/build-with-custom-dockerfile/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* -/-/-
* Dockerfile Maven Plugin
* %%
* Copyright (C) 2015 - 2016 Spotify AB
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -\-\-
*/
File imageIdFile = new File(basedir, "target/docker/image-id")
assert imageIdFile.isFile()

File repositoryFile = new File(basedir, "target/docker/repository")
assert repositoryFile.text == "test/build-with-custom-dockerfile\n"

File tagFile = new File(basedir, "target/docker/tag")
assert tagFile.text == "latest\n"

File imageNameFile = new File(basedir, "target/docker/image-name")
assert imageNameFile.text == "test/build-with-custom-dockerfile:latest\n"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
###
# -/-/-
# Dockerfile Maven Plugin
# %%
# Copyright (C) 2015 - 2016 Spotify AB
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -\-\-
###
invoker.buildResult=failure
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM scratch
MAINTAINER David Flemström <dflemstr@spotify.com>
60 changes: 60 additions & 0 deletions plugin/src/it/illegal-custom-dockerfile-location/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-/-/-
Dockerfile Maven Plugin
%%
Copyright (C) 2015 - 2016 Spotify AB
%%
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-\-\-
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.spotify.it</groupId>
<artifactId>illegal-custom-dockerfile-location</artifactId>
<version>1.0-SNAPSHOT</version>

<description>
A simple IT verifying it fails gracefully when a user defined dockerfile is not
located inside of the context directory.
</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
</goals>
<configuration>
<contextDirectory>context</contextDirectory>
<dockerfile>not-context/Dockerfile</dockerfile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
21 changes: 21 additions & 0 deletions plugin/src/it/illegal-custom-dockerfile-location/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* -/-/-
* Dockerfile Maven Plugin
* %%
* Copyright (C) 2015 - 2016 Spotify AB
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -\-\-
*/
String buildLog = new File("${basedir}/build.log").getText("UTF-8")
assert buildLog.contains("is not a child of the context directory")
20 changes: 20 additions & 0 deletions plugin/src/it/missing-custom-dockerfile/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
###
# -/-/-
# Dockerfile Maven Plugin
# %%
# Copyright (C) 2015 - 2016 Spotify AB
# %%
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# -\-\-
###
invoker.buildResult=failure
56 changes: 56 additions & 0 deletions plugin/src/it/missing-custom-dockerfile/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
-/-/-
Dockerfile Maven Plugin
%%
Copyright (C) 2015 - 2016 Spotify AB
%%
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-\-\-
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.spotify.it</groupId>
<artifactId>missing-custom-dockerfile</artifactId>
<version>1.0-SNAPSHOT</version>

<description>A simple IT verifying it fails gracefully when a user defined dockerfile is not found.</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
</goals>
<configuration>
<dockerfile>Custom</dockerfile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
21 changes: 21 additions & 0 deletions plugin/src/it/missing-custom-dockerfile/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* -/-/-
* Dockerfile Maven Plugin
* %%
* Copyright (C) 2015 - 2016 Spotify AB
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* -\-\-
*/
String buildLog = new File("${basedir}/build.log").getText("UTF-8")
assert buildLog.contains("Missing Dockerfile at")
Loading

0 comments on commit f3509a1

Please sign in to comment.