forked from apache/nifi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NIFI-5249 Dockerfile enhancements: create data repository and log dir…
…ectories, explicit environment variable declarations to replace nifi-env.sh. Add integration tests, remove latest tag, since only one tag can be specified that will be used to build the image. Cover dockerhub image with the same tests as dockermaven Fix entrypoint to handle signals properly, also get rid of hardcoded paths This closes apache#2747
- Loading branch information
Showing
11 changed files
with
403 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ nb-configuration.xml | |
*.iws | ||
*~ | ||
|
||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- 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. --> | ||
<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> | ||
|
||
<parent> | ||
<groupId>org.apache.nifi</groupId> | ||
<artifactId>nifi-docker</artifactId> | ||
<version>1.7.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>dockerhub</artifactId> | ||
|
||
<profiles> | ||
<profile> | ||
<id>docker</id> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.spotify</groupId> | ||
<artifactId>dockerfile-maven-plugin</artifactId> | ||
<version>1.3.5</version> | ||
<executions> | ||
<execution> | ||
<id>default</id> | ||
<goals> | ||
<goal>build</goal> | ||
</goals> | ||
<configuration> | ||
<buildArgs> | ||
<UID>1000</UID> | ||
<GID>1000</GID> | ||
<NIFI_VERSION>1.6.0</NIFI_VERSION> | ||
</buildArgs> | ||
<repository>apache/nifi</repository> | ||
<!-- Right now we can only test against the latest released NiFi version to check our Dockerfile --> | ||
<tag>${project.version}-dockerhub</tag> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>exec-maven-plugin</artifactId> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<executions> | ||
<execution> | ||
<id>Docker integration tests</id> | ||
<phase>integration-test</phase> | ||
<goals> | ||
<goal>exec</goal> | ||
</goals> | ||
<configuration> | ||
<arguments> | ||
<argument>${project.version}-dockerhub</argument> | ||
<argument>1.6.0</argument> | ||
</arguments> | ||
<executable>${project.basedir}/../dockermaven/integration-test.sh</executable> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</profile> | ||
</profiles> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/bin/bash | ||
|
||
# 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. | ||
|
||
set -exuo pipefail | ||
|
||
TAG=$1 | ||
VERSION=$2 | ||
|
||
trap "{ docker rm -f nifi-${TAG}-integration-test; }" EXIT | ||
|
||
echo "Checking that all files are owned by NiFi" | ||
test -z $(docker run --rm --entrypoint /bin/bash apache/nifi:${TAG} -c "find /opt/nifi ! -user nifi") | ||
|
||
echo "Checking environment variables" | ||
test "/opt/nifi/nifi-${VERSION}" = "$(docker run --rm --entrypoint /bin/bash apache/nifi:${TAG} -c 'echo -n $NIFI_HOME')" | ||
test "/opt/nifi/nifi-${VERSION}/logs" = "$(docker run --rm --entrypoint /bin/bash apache/nifi:${TAG} -c 'echo -n $NIFI_LOG_DIR')" | ||
test "/opt/nifi/nifi-${VERSION}/run" = "$(docker run --rm --entrypoint /bin/bash apache/nifi:${TAG} -c 'echo -n $NIFI_PID_DIR')" | ||
test "/opt/nifi" = "$(docker run --rm --entrypoint /bin/bash apache/nifi:${TAG} -c 'echo -n $NIFI_BASE_DIR')" | ||
|
||
echo "Starting NiFi container..." | ||
docker run -d --name nifi-${TAG}-integration-test apache/nifi:${TAG} | ||
|
||
IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' nifi-${TAG}-integration-test) | ||
|
||
for i in $(seq 1 10) :; do | ||
if docker exec nifi-${TAG}-integration-test bash -c "ss -ntl | grep 8080"; then | ||
break | ||
fi | ||
sleep 10 | ||
done | ||
|
||
echo "Checking system diagnostics" | ||
test ${VERSION} = $(docker exec nifi-${TAG}-integration-test bash -c "curl -s $IP:8080/nifi-api/system-diagnostics | jq .systemDiagnostics.aggregateSnapshot.versionInfo.niFiVersion -r") | ||
|
||
echo "Stopping NiFi container" | ||
time docker stop nifi-${TAG}-integration-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh -e | ||
# 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. | ||
|
||
# 1 - value to search for | ||
# 2 - value to replace | ||
# 3 - file to perform replacement inline | ||
prop_replace () { | ||
target_file=${3:-${nifi_props_file}} | ||
echo 'replacing target file ' ${target_file} | ||
sed -i -e "s|^$1=.*$|$1=$2|" ${target_file} | ||
} | ||
|
||
# NIFI_HOME is defined by an ENV command in the backing Dockerfile | ||
export nifi_props_file=${NIFI_HOME}/conf/nifi.properties | ||
export hostname=$(hostname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/bin/sh -e | ||
|
||
# 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. | ||
|
||
scripts_dir='/opt/nifi/scripts' | ||
|
||
[ -f "${scripts_dir}/common.sh" ] && . "${scripts_dir}/common.sh" | ||
|
||
# Perform idempotent changes of configuration to support secure environments | ||
echo 'Configuring environment with SSL settings' | ||
|
||
: ${KEYSTORE_PATH:?"Must specify an absolute path to the keystore being used."} | ||
if [ ! -f "${KEYSTORE_PATH}" ]; then | ||
echo "Keystore file specified (${KEYSTORE_PATH}) does not exist." | ||
exit 1 | ||
fi | ||
: ${KEYSTORE_TYPE:?"Must specify the type of keystore (JKS, PKCS12, PEM) of the keystore being used."} | ||
: ${KEYSTORE_PASSWORD:?"Must specify the password of the keystore being used."} | ||
|
||
: ${TRUSTSTORE_PATH:?"Must specify an absolute path to the truststore being used."} | ||
if [ ! -f "${TRUSTSTORE_PATH}" ]; then | ||
echo "Keystore file specified (${TRUSTSTORE_PATH}) does not exist." | ||
exit 1 | ||
fi | ||
: ${TRUSTSTORE_TYPE:?"Must specify the type of truststore (JKS, PKCS12, PEM) of the truststore being used."} | ||
: ${TRUSTSTORE_PASSWORD:?"Must specify the password of the truststore being used."} | ||
|
||
prop_replace 'nifi.security.keystore' "${KEYSTORE_PATH}" | ||
prop_replace 'nifi.security.keystoreType' "${KEYSTORE_TYPE}" | ||
prop_replace 'nifi.security.keystorePasswd' "${KEYSTORE_PASSWORD}" | ||
prop_replace 'nifi.security.truststore' "${TRUSTSTORE_PATH}" | ||
prop_replace 'nifi.security.truststoreType' "${TRUSTSTORE_TYPE}" | ||
prop_replace 'nifi.security.truststorePasswd' "${TRUSTSTORE_PASSWORD}" | ||
|
||
# Disable HTTP and enable HTTPS | ||
prop_replace 'nifi.web.http.port' '' | ||
prop_replace 'nifi.web.http.host' '' | ||
prop_replace 'nifi.web.https.port' "${NIFI_WEB_HTTPS_PORT:-8443}" | ||
prop_replace 'nifi.web.https.host' "${NIFI_WEB_HTTPS_HOST:-$HOSTNAME}" | ||
prop_replace 'nifi.remote.input.secure' 'true' | ||
|
||
# Check if the user has specified a nifi.web.proxy.host setting and handle appropriately | ||
if [ -z "${NIFI_WEB_PROXY_HOST}" ]; then | ||
echo 'NIFI_WEB_PROXY_HOST was not set but NiFi is configured to run in a secure mode. The NiFi UI may be inaccessible if using port mapping.' | ||
else | ||
prop_replace 'nifi.web.proxy.host' "${NIFI_WEB_PROXY_HOST}" | ||
fi | ||
|
||
# Establish initial user and an associated admin identity | ||
sed -i -e 's|<property name="Initial User Identity 1"></property>|<property name="Initial User Identity 1">'"${INITIAL_ADMIN_IDENTITY}"'</property>|' ${NIFI_HOME}/conf/authorizers.xml | ||
sed -i -e 's|<property name="Initial Admin Identity"></property>|<property name="Initial Admin Identity">'"${INITIAL_ADMIN_IDENTITY}"'</property>|' ${NIFI_HOME}/conf/authorizers.xml |
Oops, something went wrong.