This is an automated email from the ASF dual-hosted git repository.
shuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/unomi.git
The following commit(s) were added to refs/heads/master by this push:
new e21ed81 UNOMI-334 Docker - Maven integration - Change project
structure to generate a filtered project in target/filtered-docker - Added
documentation on how to use docker images - Simplified docker image environment
variables
e21ed81 is described below
commit e21ed81b6774aa6d4205d4e428e98dac2722d759
Author: Serge Huber <[email protected]>
AuthorDate: Mon May 4 22:01:01 2020 +0200
UNOMI-334 Docker - Maven integration
- Change project structure to generate a filtered project in
target/filtered-docker
- Added documentation on how to use docker images
- Simplified docker image environment variables
---
docker/README.md | 45 ++++++++++++++++++++++---
docker/pom.xml | 42 +++++++++++++++++++++--
docker/{ => src/main/docker}/Dockerfile | 7 ++--
docker/{ => src/main/docker}/docker-compose.yml | 5 ++-
docker/{ => src/main/docker}/entrypoint.sh | 4 +--
5 files changed, 86 insertions(+), 17 deletions(-)
diff --git a/docker/README.md b/docker/README.md
index 8e8201c..c8f41fb 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -14,20 +14,55 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-# Building Docker images
+
+# Building Docker image
-You can build the docker image provided in this directory by using the
following command:
+You must build the docker image provided in this directory by using the
following command:
```
mvn clean install
```
-# Unomi Docker Image
+This project will also generate Docker standalone project files in
`target/filtered-docker` as well as position the
+required Unomi tarball.
-## Running Unomi
+# Using Unomi Docker Image
+
+## Launching docker-compose using Maven project
Unomi requires ElasticSearch so it is recommended to run Unomi and
ElasticSearch using docker-compose:
+
```
mvn docker:start
```
-You will need to wait while Docker builds the containers and they boot up (ES
will take a minute or two). Once they are up you can check that the Unomi
services are available by visiting http://localhost:8181 in a web browser.
+
+You will need to wait while Docker builds the containers and they boot up (ES
will take a minute or two). Once they are
+up you can check that the Unomi services are available by visiting
http://localhost:8181 in a web browser.
+
+## Manually launching ElasticSearch & Unomi docker images
+
+If you want to run it without docker-compose you should then make sure you
setup the following environments properly.
+
+For ElasticSearch:
+
+ docker pull docker.elastic.co/elasticsearch/elasticsearch:7.4.2
+ docker network create unomi
+ docker run --name elasticsearch --net unomi -p 9200:9200 -p 9300:9300 -e
"discovery.type=single-node" -e cluster.name=contextElasticSearch
docker.elastic.co/elasticsearch/elasticsearch:7.4.2
+
+For Unomi:
+
+ docker pull apache/unomi:1.5.0-SNAPSHOT
+ docker run --name unomi --net unomi -p 8181:8181 -p 9443:9443 -p 8102:8102
-e UNOMI_ELASTICSEARCH_ADDRESSES=elasticsearch:9200 apache/unomi:1.5.0-SNAPSHOT
+
+## Using a host OS ElasticSearch installation (only supported on macOS &
Windows)
+
+ docker run --name unomi -p 8181:8181 -p 9443:9443 -p 8102:8102 -e
UNOMI_ELASTICSEARCH_ADDRESSES=host.docker.internal:9200
apache/unomi:1.5.0-SNAPSHOT
+
+Note: Linux doesn't support the host.docker.internal DNS lookup method yet, it
should be available in an upcoming version of Docker. See
https://github.com/docker/for-linux/issues/264
+
+# Using docker build tools
+
+If you want to rebuild the images or use docker compose directly, you must
still first use `mvn clean install` to generate
+the filtered project in `target/filtered-docker`.
+
+You can then use `docker-compose up` to start the project
diff --git a/docker/pom.xml b/docker/pom.xml
index db3f877..9267f1e 100644
--- a/docker/pom.xml
+++ b/docker/pom.xml
@@ -53,6 +53,7 @@
<goal>copy</goal>
</goals>
<configuration>
+
<outputDirectory>${project.build.directory}/filtered-docker</outputDirectory>
<artifactItems>
<artifactItem>
<groupId>org.apache.unomi</groupId>
@@ -66,6 +67,42 @@
</executions>
</plugin>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter-dockerfiles</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <configuration>
+ <resources>
+ <!-- # Filtered Resources -->
+ <resource>
+
<directory>${project.basedir}/src/main/docker</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>Dockerfile</include>
+ <include>docker-compose.yml</include>
+ </includes>
+ </resource>
+ <!-- # Unfiltered Resources -->
+ <resource>
+
<directory>${project.basedir}/src/main/docker</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>Dockerfile</exclude>
+ <exclude>docker-compose.yml</exclude>
+ </excludes>
+ </resource>
+ </resources>
+
<outputDirectory>${project.build.directory}/filtered-docker</outputDirectory>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.33.0</version>
@@ -76,10 +113,9 @@
<name>apache/unomi:${project.version}</name>
<external>
<type>compose</type>
- <basedir>${basedir}</basedir>
- <composeFile>docker-compose.yml</composeFile>
+
<basedir>${project.build.directory}/filtered-docker</basedir>
+
<composeFile>${project.build.directory}/filtered-docker/docker-compose.yml</composeFile>
</external>
-
</image>
</images>
</configuration>
diff --git a/docker/Dockerfile b/docker/src/main/docker/Dockerfile
similarity index 89%
rename from docker/Dockerfile
rename to docker/src/main/docker/Dockerfile
index 30fa75f..da18bd7 100644
--- a/docker/Dockerfile
+++ b/docker/src/main/docker/Dockerfile
@@ -23,19 +23,18 @@ ENV PATH $PATH:$UNOMI_HOME/bin
ENV KARAF_OPTS "-Dunomi.autoStart=true"
-ENV ELASTICSEARCH_HOST localhost
-ENV ELASTICSEARCH_PORT 9200
+ENV UNOMI_ELASTICSEARCH_ADDRESSES=localhost:9200
ENV UNOMI_VERSION "${project.version}"
WORKDIR $UNOMI_HOME
-ADD target/dependency/unomi-${UNOMI_VERSION}.tar.gz ./
+ADD unomi-${UNOMI_VERSION}.tar.gz ./
RUN mv unomi-*/* . \
&& rm -rf unomi-*
-COPY ./entrypoint.sh ./entrypoint.sh
+COPY entrypoint.sh ./entrypoint.sh
EXPOSE 9443
EXPOSE 8181
diff --git a/docker/docker-compose.yml
b/docker/src/main/docker/docker-compose.yml
similarity index 95%
rename from docker/docker-compose.yml
rename to docker/src/main/docker/docker-compose.yml
index a7b2247..e650d88 100644
--- a/docker/docker-compose.yml
+++ b/docker/src/main/docker/docker-compose.yml
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
-version: '2.2'
+version: '2.4'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.2
@@ -31,10 +31,9 @@ services:
unomi:
build: .
+ image: apache/unomi:${project.version}
container_name: unomi
environment:
- - ELASTICSEARCH_HOST=elasticsearch
- - ELASTICSEARCH_PORT=9200
- UNOMI_ELASTICSEARCH_ADDRESSES=elasticsearch:9200
ports:
- 8181:8181
diff --git a/docker/entrypoint.sh b/docker/src/main/docker/entrypoint.sh
similarity index 87%
rename from docker/entrypoint.sh
rename to docker/src/main/docker/entrypoint.sh
index 6d28692..80f5ee0 100755
--- a/docker/entrypoint.sh
+++ b/docker/src/main/docker/entrypoint.sh
@@ -18,10 +18,10 @@
################################################################################
# Wait for heathy ElasticSearch
# next wait for ES status to turn to Green
-health_check="$(curl -fsSL
"$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cat/health?h=status")"
+health_check="$(curl -fsSL
"$UNOMI_ELASTICSEARCH_ADDRESSES/_cat/health?h=status")"
until ([ "$health_check" = 'yellow' ] || [ "$health_check" = 'green' ]); do
- health_check="$(curl -fsSL
"$ELASTICSEARCH_HOST:$ELASTICSEARCH_PORT/_cat/health?h=status")"
+ health_check="$(curl -fsSL
"$UNOMI_ELASTICSEARCH_ADDRESSES/_cat/health?h=status")"
>&2 echo "Elastic Search is not yet available - waiting (health
check=$health_check)..."
sleep 1
done