You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by kr...@apache.org on 2019/01/24 16:57:08 UTC
[knox] branch master updated: KNOX-1285 - Create Apache Knox
Dockerfile and image
This is an automated email from the ASF dual-hosted git repository.
krisden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/knox.git
The following commit(s) were added to refs/heads/master by this push:
new fbad8fd KNOX-1285 - Create Apache Knox Dockerfile and image
fbad8fd is described below
commit fbad8fdc247e55e143353806a662efea5315199f
Author: Kevin Risden <kr...@apache.org>
AuthorDate: Mon Sep 24 15:55:55 2018 -0400
KNOX-1285 - Create Apache Knox Dockerfile and image
Signed-off-by: Kevin Risden <kr...@apache.org>
---
gateway-docker/README.md | 25 ++++
gateway-docker/pom.xml | 139 +++++++++++++++++++++
gateway-docker/src/assembly/docker-files.xml | 34 +++++
.../src/main/resources/docker-compose.yml | 28 +++++
.../src/main/resources/docker/Dockerfile | 49 ++++++++
.../main/resources/docker/gateway-entrypoint.sh | 26 ++++
.../src/main/resources/docker/ldap-entrypoint.sh | 25 ++++
pom.xml | 2 +
8 files changed, 328 insertions(+)
diff --git a/gateway-docker/README.md b/gateway-docker/README.md
new file mode 100644
index 0000000..9e1921d
--- /dev/null
+++ b/gateway-docker/README.md
@@ -0,0 +1,25 @@
+<!--
+{% comment %}
+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.
+{% endcomment %}
+-->
+
+## Docker
+
+`src/resources/docker` contains a Dockerfile and Docker-compose
+configuration files to launch an Apache Knox server. Maven automation
+exists for the base Docker image "apache/knox" which can be invoked with
+the "-Pdocker" Maven profile.
diff --git a/gateway-docker/pom.xml b/gateway-docker/pom.xml
new file mode 100644
index 0000000..d8de5ca
--- /dev/null
+++ b/gateway-docker/pom.xml
@@ -0,0 +1,139 @@
+<?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.knox</groupId>
+ <artifactId>gateway</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>gateway-docker</artifactId>
+
+ <name>gateway-docker</name>
+ <description>Docker images for the Apache Knox project</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.knox</groupId>
+ <artifactId>gateway-release</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-assembly-plugin</artifactId>
+ <!-- Use the execution instead of configuration to bind it to package -->
+ <executions>
+ <execution>
+ <id>binary-assembly</id>
+ <goals>
+ <goal>single</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <descriptors>
+ <descriptor>src/assembly/docker-files.xml</descriptor>
+ </descriptors>
+ <tarLongFileMode>gnu</tarLongFileMode>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <profiles>
+ <!-- Profile for building official Docker images. Not bound to build phases since that would require anyone build to have the Docker engine installed on their machine -->
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-resources</id>
+ <phase>package</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.outputDirectory}/docker</outputDirectory>
+ <overwrite>true</overwrite>
+ <resources>
+ <resource>
+ <directory>${project.basedir}/../target/${project.version}</directory>
+ <includes>
+ <include>knox-${project.version}.zip</include>
+ </includes>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.spotify</groupId>
+ <artifactId>dockerfile-maven-plugin</artifactId>
+ <version>${dockerfile-maven-plugin.version}</version>
+ <configuration>
+ <contextDirectory>${project.build.outputDirectory}/docker</contextDirectory>
+ <repository>apache/knox</repository>
+ <buildArgs>
+ <RELEASE_FILE>knox-${project.version}.zip</RELEASE_FILE>
+ </buildArgs>
+ </configuration>
+ <executions>
+ <execution>
+ <id>gateway</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <tag>gateway-${project.version}</tag>
+ <buildArgs>
+ <ENTRYPOINT>gateway-entrypoint.sh</ENTRYPOINT>
+ <EXPOSE_PORT>8443</EXPOSE_PORT>
+ </buildArgs>
+ </configuration>
+ </execution>
+ <execution>
+ <id>ldap</id>
+ <phase>package</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>tag</goal>
+ </goals>
+ <configuration>
+ <tag>ldap-${project.version}</tag>
+ <buildArgs>
+ <ENTRYPOINT>ldap-entrypoint.sh</ENTRYPOINT>
+ <EXPOSE_PORT>33389</EXPOSE_PORT>
+ </buildArgs>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/gateway-docker/src/assembly/docker-files.xml b/gateway-docker/src/assembly/docker-files.xml
new file mode 100644
index 0000000..f65c840
--- /dev/null
+++ b/gateway-docker/src/assembly/docker-files.xml
@@ -0,0 +1,34 @@
+<?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.
+-->
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+ <id>docker-files</id>
+ <formats>
+ <format>tar.gz</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>src/main/resources</directory>
+ <outputDirectory></outputDirectory>
+ <includes>
+ <include>**</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/gateway-docker/src/main/resources/docker-compose.yml b/gateway-docker/src/main/resources/docker-compose.yml
new file mode 100644
index 0000000..2e23654
--- /dev/null
+++ b/gateway-docker/src/main/resources/docker-compose.yml
@@ -0,0 +1,28 @@
+# 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
+# <p>
+# http://www.apache.org/licenses/LICENSE-2.0
+# <p>
+# 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.
+
+version: '3'
+services:
+ ldap:
+ image: apache/knox:ldap-1.3.0-SNAPSHOT
+ ports:
+ - "33389:33389"
+
+ gateway:
+ depends_on:
+ - ldap
+ image: apache/knox:gateway-1.3.0-SNAPSHOT
+ ports:
+ - "8443:8443"
diff --git a/gateway-docker/src/main/resources/docker/Dockerfile b/gateway-docker/src/main/resources/docker/Dockerfile
new file mode 100644
index 0000000..27c916d
--- /dev/null
+++ b/gateway-docker/src/main/resources/docker/Dockerfile
@@ -0,0 +1,49 @@
+# 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.
+
+FROM openjdk:8-jre-alpine
+MAINTAINER Apache Knox <de...@knox.apache.org>
+
+# Make sure required packages are available
+RUN apk --no-cache add bash procps ca-certificates && update-ca-certificates
+
+# Create an knox user
+RUN addgroup -S knox && adduser -S -G knox knox
+
+# Dependencies
+ARG RELEASE_FILE
+COPY ${RELEASE_FILE} /home/knox/
+
+# Extract the Knox release tar.gz
+RUN cd /home/knox && unzip /home/knox/*.zip && rm -f /home/knox/*.zip && ln -nsf /home/knox/*/ /home/knox/knox
+
+# Make sure knox owns its files
+RUN chown -R knox: /home/knox
+
+# Add the entrypoint script
+ARG ENTRYPOINT
+COPY ${ENTRYPOINT} /home/knox/knox/entrypoint.sh
+RUN chmod +x /home/knox/knox/entrypoint.sh
+
+WORKDIR /home/knox/knox
+
+# Expose the default port as a convenience
+ARG EXPOSE_PORT
+EXPOSE ${EXPOSE_PORT}
+
+# Switch off of the root user
+USER knox
+
+ENTRYPOINT ["./entrypoint.sh"]
diff --git a/gateway-docker/src/main/resources/docker/gateway-entrypoint.sh b/gateway-docker/src/main/resources/docker/gateway-entrypoint.sh
new file mode 100755
index 0000000..a6c32cd
--- /dev/null
+++ b/gateway-docker/src/main/resources/docker/gateway-entrypoint.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env 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 -e
+set -o pipefail
+
+./bin/knoxcli.sh create-master --master knox
+./bin/gateway.sh start
+
+# This is needed because gateway.sh starts in the background
+# Would be better for gateway.sh to have a foreground version
+tail -f ./logs/*
diff --git a/gateway-docker/src/main/resources/docker/ldap-entrypoint.sh b/gateway-docker/src/main/resources/docker/ldap-entrypoint.sh
new file mode 100755
index 0000000..8da1719
--- /dev/null
+++ b/gateway-docker/src/main/resources/docker/ldap-entrypoint.sh
@@ -0,0 +1,25 @@
+#!/usr/bin/env 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 -e
+set -o pipefail
+
+./bin/ldap.sh start
+
+# This is needed because ldap.sh starts in the background
+# Would be better for ldap.sh to have a foreground version
+tail -f ./logs/*
diff --git a/pom.xml b/pom.xml
index e8f6c96..7e9d30e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -128,6 +128,7 @@
<module>gateway-shell-release</module>
<module>gateway-test-release-utils</module>
<module>gateway-service-nifi</module>
+ <module>gateway-docker</module>
</modules>
<properties>
@@ -163,6 +164,7 @@
<curator.version>4.1.0</curator.version>
<curator-test.version>2.13.0</curator-test.version>
<dependency-check-maven.version>4.0.2</dependency-check-maven.version>
+ <dockerfile-maven-plugin.version>1.4.10</dockerfile-maven-plugin.version>
<easymock.version>4.0.2</easymock.version>
<eclipselink.version>2.7.4</eclipselink.version>
<ehcache.version>2.6.11</ehcache.version>