Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,7 @@ Using the following template, create a `Dockerfile` in a module for which you wa

```dockerfile

# leave it empty, the value is passed from outside
ARG DOCKER_BASE_IMAGE_PREFIX

# specify your desired base image
ARG MY_BASE_IMAGE=my_base_docker_image_coordinates

# all pulling images MUST be prefixed like this
FROM "$DOCKER_BASE_IMAGE_PREFIX""$MY_BASE_IMAGE"
FROM base_docker_image_coordinates

# legal stuff
LABEL \
Expand All @@ -161,7 +154,6 @@ LABEL \
# ARG PROJECT_BUILD_FINAL_NAME

# The rest of your Dockerfile here
???

```

Expand All @@ -179,8 +171,8 @@ In the corresponding `pom.xml`, specify the Docker image name and enable the doc
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
Expand All @@ -206,7 +198,7 @@ Specify `dockerfile.repositoryUrl` property accordingly and execute Maven `deplo

The example command below with create an image and push into the AbsaOSS space on the Docker Hub.
```shell
mvn install -Ddocker -Ddockerfile.repositoryUrl=docker.io/absaoss
mvn deploy -Ddocker -Ddockerfile.repositoryUrl=docker.io/absaoss
```

##### Tweaking image names and tags
Expand Down
63 changes: 32 additions & 31 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@
<dockerfile.repositorySuffix><!-- defined externally --></dockerfile.repositorySuffix>
<dockerfile.repository>${dockerfile.repositoryPrefix}${dockerfile.imageName}${dockerfile.repositorySuffix}</dockerfile.repository>

<!-- The optional prefix for the base images in Dockerfile (mainly used in custom CI/CD pipelines to pull images from alternative locations) -->
<dockerfile.baseImagePrefix><!-- defined externally --></dockerfile.baseImagePrefix>

<!-- Test -->
<jacoco.version>0.8.8</jacoco.version>
</properties>
Expand Down Expand Up @@ -271,45 +268,49 @@
<build>
<plugins>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<executions>
<execution>
<id>tag-version</id>
<id>docker-build</id>
<phase>install</phase>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
<configuration>
<tag>${dockerfile.versionTagName}</tag>
</configuration>
</execution>
<execution>
<id>tag-latest</id>
<id>docker-push</id>
<phase>deploy</phase>
<goals>
<goal>tag</goal>
<goal>push</goal>
</goals>
<configuration>
<tag>${dockerfile.latestTagName}</tag>
</configuration>
</execution>
</executions>
<configuration>
<skip>true</skip>
<!-- Dockerfile plugin requires <repository> to be non-empty even if <skip> is true -->
<repository>${dockerfile.repository}</repository>
<buildArgs combine.children="append">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line was there to make it easy to pass more properties into the dockerfile from the child POM.
How is this achieved in the new configuration?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only needed for adding elements of the same name. Since args have each different name there is no need for it.

<DOCKER_BASE_IMAGE_PREFIX>${dockerfile.baseImagePrefix}</DOCKER_BASE_IMAGE_PREFIX>
<PROJECT_NAME>${project.name}</PROJECT_NAME>
<PROJECT_GROUP_ID>${project.groupId}</PROJECT_GROUP_ID>
<PROJECT_ARTIFACT_ID>${project.artifactId}</PROJECT_ARTIFACT_ID>
<PROJECT_VERSION>${project.version}</PROJECT_VERSION>
<PROJECT_BASEDIR>${project.basedir}</PROJECT_BASEDIR>
<PROJECT_BUILD_DIRECTORY>${project.build.directory}</PROJECT_BUILD_DIRECTORY>
<PROJECT_BUILD_FINAL_NAME>${project.build.finalName}</PROJECT_BUILD_FINAL_NAME>
</buildArgs>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<images>
<image>
<name>${dockerfile.repository}</name>
<build>
<contextDir>${project.basedir}</contextDir>
<tags>
<tag>${dockerfile.versionTagName}</tag>
<tag>${dockerfile.latestTagName}</tag>
</tags>
<filter>false</filter>
<args>
<PROJECT_NAME>${project.name}</PROJECT_NAME>
<PROJECT_GROUP_ID>${project.groupId}</PROJECT_GROUP_ID>
<PROJECT_ARTIFACT_ID>${project.artifactId}</PROJECT_ARTIFACT_ID>
<PROJECT_VERSION>${project.version}</PROJECT_VERSION>
<PROJECT_BASEDIR>${project.basedir}</PROJECT_BASEDIR>
<PROJECT_BUILD_DIRECTORY>${project.build.directory}</PROJECT_BUILD_DIRECTORY>
<PROJECT_BUILD_FINAL_NAME>${project.build.finalName}</PROJECT_BUILD_FINAL_NAME>
</args>
</build>

</image>
</images>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -400,9 +401,9 @@
<version>1.6.8</version>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.13</version>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.40.3</version>
</plugin>
</plugins>
</pluginManagement>
Expand Down