Skip to content

Commit

Permalink
feat(worker): add new module azkarra-worker
Browse files Browse the repository at this point in the history
- add scripts to build Docker image for azkarra-worker
- cleanup maven pom.xml for log4j2 dependencies
  • Loading branch information
fhussonnois committed Dec 12, 2019
1 parent a3e5525 commit 25f9083
Show file tree
Hide file tree
Showing 14 changed files with 575 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .dockerignore
@@ -0,0 +1,20 @@
/azkarra-*
*.iml
build-deploy-site.sh
checkstyle
.circleci
CONTRIBUTING.md
docs
generate-deploy-apidocs.sh
.git
.gitattributes
.gitignore
.gitmodules
.idea
images
LICENSE
Makefile
pom.xml
README.md
site
target
51 changes: 51 additions & 0 deletions Dockerfile
@@ -0,0 +1,51 @@
# Copyright 2019 StreamThoughts.
#
# 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.
#
# Azkarra Streams Worker
# VERSION 0.5.0
FROM azul/zulu-openjdk:13

ARG azkarraVersion
ARG azkarraBranch
ARG azkarraCommit

ENV AZKARRA_HOME="/usr/local/azkarra" \
AZKARRA_VERSION="${azkarraVersion}" \
AZKARRA_COMMIT="${azkarraCommit}" \
AZKARRA_BRANCH="${azkarraBranch}"

RUN mkdir -p ${AZKARRA_HOME} \
mkdir -p ${AZKARRA_HOME}/share/java/azkarra-worker

# Copy dependencies
COPY ./docker-build/dependencies/ ${AZKARRA_HOME}/share/java/azkarra-worker

# Copy resources
COPY ./docker-entrypoint.sh /
COPY ./docker-build/resources/ ${AZKARRA_HOME}/

# Copy classes
COPY ./docker-build/classes/ ${AZKARRA_HOME}/share/java/azkarra-worker

LABEL io.streamthoughts.docker.name="azkarra-streams" \
io.streamthoughts.docker.version=$AZKARRA_VERSION \
io.streamthoughts.docker.branch=$AZKARRA_VERSION \
io.streamthoughts.docker.commit=$AZKARRA_VERSION

EXPOSE 8080

ENTRYPOINT ["/docker-entrypoint.sh"]
48 changes: 48 additions & 0 deletions Makefile
@@ -0,0 +1,48 @@
# Makefile used to build docker images for Azkarra

AZKARRA_VERSION := $(shell mvn org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
GIT_COMMIT := $(shell git rev-parse --short HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)

REPOSITORY = streamthoughts
IMAGE = azkarra-streams-worker
DIST_DIR = ./azkarra-worker/target/distribution/azkarra-worker-${AZKARRA_VERSION}

.SILENT:

all: build-images clean-build

clean-containers:
echo "Cleaning containers \n========================================== ";

clean-images:
echo "Cleaning images \n========================================== ";
for image in `docker images -qf "label=io.streamthoughts.docker.name"`; do \
echo "Removing image $${image} \n==========================================\n " ; \
docker rmi -f $${image} || exit 1 ; \
done

clean-build:
echo "Cleaning build directory \n========================================== ";
rm -rf ./docker-build;

build-images:
echo "Building image \n========================================== ";
echo "AZKARRA_VERSION="$(AZKARRA_VERSION)
echo "GIT_COMMIT="$(GIT_COMMIT)
echo "GIT_BRANCH="$(GIT_BRANCH)
echo "==========================================\n "
mkdir -p ./docker-build/classes && mkdir -p ./docker-build/dependencies && mkdir -p ./docker-build/resources;
mvn clean package && \
cp -r ${DIST_DIR}/bin ./docker-build/resources/ && \
cp -r ${DIST_DIR}/etc ./docker-build/resources/ && \
find ${DIST_DIR}/share/java/ -type f -regextype posix-egrep -not -iregex '^.*(?-worker)/(?azkarra-).*\.jar' -print0 | xargs -0 cp -t ./docker-build/dependencies && \
find ${DIST_DIR}/share/java/ -type f -regextype posix-egrep -iregex '^.*(?-worker)/(?azkarra-).*\.jar' -print0 | xargs -0 cp -t ./docker-build/classes && \
docker build \
--build-arg azkarraVersion=${AZKARRA_VERSION} \
--build-arg azkarraCommit=${GIT_COMMIT} \
--build-arg azkarraBranch=${GIT_BRANCH} \
-t ${REPOSITORY}/${IMAGE}:latest . || exit 1 ;
docker tag ${REPOSITORY}/${IMAGE}:latest ${REPOSITORY}/azkarra-streams:${AZKARRA_VERSION} || exit 1 ;

clean: clean-containers clean-images clean-build
6 changes: 0 additions & 6 deletions azkarra-examples/pom.xml
Expand Up @@ -49,7 +49,6 @@
<properties>
<checkstyle.config.location>${project.parent.basedir}</checkstyle.config.location>
<kafka.streams.version>2.3.0</kafka.streams.version>
<log4j.version>1.7.28</log4j.version>
<junit.version>4.12</junit.version>
</properties>

Expand Down Expand Up @@ -90,30 +89,25 @@
<version>${project.version}</version>
</dependency>


<!-- START dependencies for logging -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.28</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.12.1</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.12.1</version>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<version>2.12.1</version>
</dependency>
<!-- END dependencies for logging -->

Expand Down
11 changes: 11 additions & 0 deletions azkarra-worker/config/azkarra.conf
@@ -0,0 +1,11 @@
azkarra {
context {
streams {
bootstrap.servers = "localhost:9092"
default.key.serde = "org.apache.kafka.common.serialization.Serdes$StringSerde"
default.value.serde = "org.apache.kafka.common.serialization.Serdes$StringSerde"
}

enable.wait.for.topics = true
}
}
46 changes: 46 additions & 0 deletions azkarra-worker/config/log4j2.xml
@@ -0,0 +1,46 @@
<!--
Copyright 2019 StreamThoughts.
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.
-->
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
<RollingFile
name="RollingFile"
fileName="${sys:log4j.logsDir}/azkarra-worker.log"
filePattern="${sys:log4j.logsDir}/azkarra-worker.%i.log.gz"
ignoreExceptions="false">
<PatternLayout>
<Pattern>%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n</Pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="100MB" />
</Policies>
<DefaultRolloverStrategy max="5" />
</RollingFile>
</Appenders>
<Loggers>
<Logger name="org.apache.kafka" level="INFO"/>
<Logger name="io.streamthoughts" level="INFO"/>
<Root level="error">
<AppenderRef ref="RollingFile"/>
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
146 changes: 146 additions & 0 deletions azkarra-worker/pom.xml
@@ -0,0 +1,146 @@
<!--
Copyright 2019 StreamThoughts.
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>
<artifactId>azkarra-streams-reactor</artifactId>
<groupId>io.streamthoughts</groupId>
<version>0.5-SNAPSHOT</version>
</parent>

<artifactId>azkarra-worker</artifactId>
<packaging>jar</packaging>

<name>Azkarra Streams Worker</name>
<description>Standalone Azkarra Streams application</description>

<properties>
<checkstyle.config.location>${project.parent.basedir}</checkstyle.config.location>
</properties>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>false</addClasspath>
<mainClass>io.streamthoughts.azkarra.AzkarraWorker</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>src/assembly/package.xml</descriptor>
<descriptor>src/assembly/development.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>./target/distribution</outputDirectory>
<finalName>${project.artifactId}-${project.version}</finalName>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
<execution>
<id>test-make-assembly</id>
<phase>pre-integration-test</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-streams</artifactId>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>io.streamthoughts</groupId>
<artifactId>azkarra-streams</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- START dependencies for logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>runtime</scope>
</dependency>
<!-- END dependencies for logging -->
</dependencies>
</project>

0 comments on commit 25f9083

Please sign in to comment.