You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2018/12/23 23:25:07 UTC

[directory-buildtools] branch master updated: Add generic maven build docker image

This is an automated email from the ASF dual-hosted git repository.

seelmann pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/directory-buildtools.git


The following commit(s) were added to refs/heads/master by this push:
     new bc95534  Add generic maven build docker image
bc95534 is described below

commit bc9553499f8d80425d24047ed9773753ffdba251
Author: Stefan Seelmann <ma...@stefan-seelmann.de>
AuthorDate: Mon Dec 24 00:24:52 2018 +0100

    Add generic maven build docker image
---
 docker/maven-build/Dockerfile    | 37 +++++++++++++++++++++++
 docker/maven-build/README.md     | 63 ++++++++++++++++++++++++++++++++++++++++
 docker/maven-build/build.sh      | 15 ++++++++++
 docker/maven-build/entrypoint.sh |  8 +++++
 4 files changed, 123 insertions(+)

diff --git a/docker/maven-build/Dockerfile b/docker/maven-build/Dockerfile
new file mode 100644
index 0000000..67a320e
--- /dev/null
+++ b/docker/maven-build/Dockerfile
@@ -0,0 +1,37 @@
+#
+#   Licensed to the Apache Software Foundation (ASF) under one 
+#   or more contributor license agreements.  See the NOTICE file
+#   distributed with this work for additional information
+#   regarding copyright ownership.  The ASF licenses this file
+#   to you 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.
+#
+
+ARG JDK_VERSION=8
+FROM maven:3-jdk-${JDK_VERSION}
+
+# Create home directory
+RUN mkdir -p /home/user/project && chmod 777 /home/user && chmod 777 /home/user/project
+WORKDIR /home/user/project
+
+# Make /etc/passwd writeable to be able to inject username with dynamic uid/gid
+RUN chmod 666 /etc/passwd
+
+# Add and configure entrypoint script
+ADD entrypoint.sh /usr/local/bin
+ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
+
+# Add build script and make it the default command
+ADD build.sh /usr/local/bin
+CMD "/usr/local/bin/build.sh"
+
diff --git a/docker/maven-build/README.md b/docker/maven-build/README.md
new file mode 100644
index 0000000..701d107
--- /dev/null
+++ b/docker/maven-build/README.md
@@ -0,0 +1,63 @@
+> Licensed to the Apache Software Foundation (ASF) under one
+> or more contributor license agreements.  See the NOTICE file
+> distributed with this work for additional information
+> regarding copyright ownership.  The ASF licenses this file
+> to you 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.
+
+
+# About
+
+A docker image to run a regular Maven build within a docker container.
+
+It contains all requirements:
+* OpenJDK 8 or 11
+* Maven 3.6
+
+
+## Build image
+
+See <https://hub.docker.com/_/maven> for available Maven base image tags.
+
+    JDK_VERSION=8
+    docker pull maven:3-jdk-${JDK_VERSION}
+    docker build -t apachedirectory/maven-build:jdk-${JDK_VERSION} --build-arg JDK_VERSION=${JDK_VERSION} .
+
+
+## Publish image
+
+    docker push apachedirectory/maven-build:jdk-${JDK_VERSION}
+
+
+## Usage
+
+Local:
+
+    docker run -it --rm \
+        -u $(id -u):$(id -g) \
+        -v ~/.m2:/home/user/.m2 \
+        -v $(pwd):/home/user/project \
+        apachedirectory/maven-build:jdk-8 bash
+
+    mvn clean install
+
+
+On Jenkins:
+
+    docker run -i --rm \
+        -u $(id -u):$(id -g) \
+        -v ~/.m2:/home/user/.m2 \
+        -v $(pwd):/home/user/project \
+        apachedirectory/maven-build:jdk-8
+
+
diff --git a/docker/maven-build/build.sh b/docker/maven-build/build.sh
new file mode 100755
index 0000000..b4f5767
--- /dev/null
+++ b/docker/maven-build/build.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# stop execution if any command fails (i.e. exits with status code > 0)
+set -e
+
+# trace commands
+set -x
+
+# Temporary workaround with Surefire on Debian with Java 8
+# https://issues.apache.org/jira/browse/SUREFIRE-1588
+# https://stackoverflow.com/questions/53010200/maven-surefire-could-not-find-forkedbooter-class
+export _JAVA_OPTIONS=-Djdk.net.URLClassPath.disableClassPathURLCheck=true
+
+mvn -V clean install
+
diff --git a/docker/maven-build/entrypoint.sh b/docker/maven-build/entrypoint.sh
new file mode 100755
index 0000000..b304ee9
--- /dev/null
+++ b/docker/maven-build/entrypoint.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+set -e
+
+echo "user:x:$(id -u):$(id -g)::/home/user:/bin/bash" >> /etc/passwd
+export HOME=/home/user
+
+exec "$@"
+