Skip to content

Commit

Permalink
Set classpath of ditto docker images to ditto_home in effort to enabl…
Browse files Browse the repository at this point in the history
…e extending the images

Fix the configuration for SnapshotAdapter extension

Signed-off-by: David Schwilk <david.schwilk@bosch.io>
  • Loading branch information
DerSchwilk committed Jul 18, 2022
1 parent 8c85dfc commit 383602e
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 20 deletions.
14 changes: 8 additions & 6 deletions build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# Array of the services to build Docker images for.
# The pattern is MODULE_NAME:IMAGE_NAME as both can differ from each other.
SERVICES=(
"gateway:gateway"
"policies:policies"
"things:things"
"thingsearch:things-search"
"connectivity:connectivity"
"gateway:gateway:org.eclipse.ditto.gateway.service.starter.GatewayService"
"policies:policies:org.eclipse.ditto.policies.service.starter.PoliciesService"
"things:things:org.eclipse.ditto.things.service.starter.ThingsService"
"thingsearch:things-search:org.eclipse.ditto.thingsearch.service.starter.SearchService"
"connectivity:connectivity:org.eclipse.ditto.connectivity.service.ConnectivityService"
)
: "${HTTP_PROXY_LOCAL:=$HTTP_PROXY}"
: "${HTTPS_PROXY_LOCAL:=$HTTPS_PROXY}"
Expand All @@ -51,7 +51,8 @@ build_docker_image() {
module_name_base=$(echo "$1" | awk -F ":" '{ print $1 }')
module_name=$(printf "ditto-%s" "$module_name_base")
image_tag=$(printf "${CONTAINER_REGISTRY}/ditto-%s" "$(echo "$1" | awk -F ":" '{ print $2 }')")
jvm_args=$(echo "$1" | awk -F ":" '{ print $3 }')
jvm_args=$(echo "$1" | awk -F ":" '{ print $4 }')
main_class=$(echo "$1" | awk -F ":" '{ print $3 }')
printf "\nBuilding Docker image <%s> for service module <%s> with jvm_args <%s>\n" \
"$image_tag" \
"$module_name" \
Expand All @@ -64,6 +65,7 @@ build_docker_image() {
--build-arg SERVICE_STARTER="$module_name"-service \
--build-arg SERVICE_VERSION=$SERVICE_VERSION \
--build-arg JVM_CMD_ARGS="$jvm_args" \
--build-arg MAIN_CLASS="$main_class" \
-t "$image_tag":$IMAGE_VERSION \
"$SCRIPTDIR"

Expand Down
7 changes: 5 additions & 2 deletions dockerfile-release
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ ARG MAVEN_REPO=https://repo.eclipse.org/service/local/artifact/maven/content
ARG SERVICE_STARTER
ARG SERVICE_VERSION
ARG JVM_CMD_ARGS=""
ARG MAIN_CLASS

ENV HTTP_PORT=8080 \
HOSTING_ENVIRONMENT=Docker \
DITTO_HOME=/opt/ditto \
DITTO_LOGS=/var/log/ditto \
JVM_CMD_ARGS_ENV=${JVM_CMD_ARGS}
JVM_CMD_ARGS_ENV=${JVM_CMD_ARGS}\
MAIN_CLASS_ENV=${MAIN_CLASS} \
CLASSPATH=/opt/ditto/*

# Http port
EXPOSE 8080
Expand All @@ -45,4 +48,4 @@ RUN set -x \
USER ditto
WORKDIR $DITTO_HOME
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["sh", "-c", "java -jar ${JVM_CMD_ARGS_ENV} /opt/ditto/starter.jar"]
CMD ["sh", "-c", "java ${JVM_CMD_ARGS_ENV} ${MAIN_CLASS_ENV}"]
7 changes: 5 additions & 2 deletions dockerfile-snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ ARG TARGET_DIR
ARG SERVICE_STARTER
ARG SERVICE_VERSION
ARG JVM_CMD_ARGS=""
ARG MAIN_CLASS

ENV HTTP_PORT=8080 \
HOSTING_ENVIRONMENT=Docker \
DITTO_HOME=/opt/ditto \
DITTO_LOGS=/var/log/ditto \
JVM_CMD_ARGS_ENV=${JVM_CMD_ARGS}
JVM_CMD_ARGS_ENV=${JVM_CMD_ARGS} \
MAIN_CLASS_ENV=${MAIN_CLASS} \
CLASSPATH=/opt/ditto/*

# Http port
EXPOSE 8080
Expand All @@ -41,6 +44,6 @@ RUN set -x \
USER ditto
WORKDIR $DITTO_HOME
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["sh", "-c", "java -jar ${JVM_CMD_ARGS_ENV} /opt/ditto/starter.jar"]
CMD ["sh", "-c", "java ${JVM_CMD_ARGS_ENV} ${MAIN_CLASS_ENV}"]

COPY ${TARGET_DIR}/${SERVICE_STARTER}-${SERVICE_VERSION}-allinone.jar $DITTO_HOME
7 changes: 5 additions & 2 deletions dockerfile-snapshot-arm64
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@ ARG TARGET_DIR
ARG SERVICE_STARTER
ARG SERVICE_VERSION
ARG JVM_CMD_ARGS=""
ARG MAIN_CLASS

ENV HTTP_PORT=8080 \
HOSTING_ENVIRONMENT=Docker \
DITTO_HOME=/opt/ditto \
DITTO_LOGS=/var/log/ditto \
JVM_CMD_ARGS_ENV=${JVM_CMD_ARGS}
JVM_CMD_ARGS_ENV=${JVM_CMD_ARGS}\
MAIN_CLASS_ENV=${MAIN_CLASS} \
CLASSPATH=/opt/ditto/*

# Http port
EXPOSE 8080
Expand All @@ -41,6 +44,6 @@ RUN set -x \
USER ditto
WORKDIR $DITTO_HOME
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["sh", "-c", "java -jar ${JVM_CMD_ARGS_ENV} /opt/ditto/starter.jar"]
CMD ["sh", "-c", "java ${JVM_CMD_ARGS_ENV} ${MAIN_CLASS_ENV}"]

COPY ${TARGET_DIR}/${SERVICE_STARTER}-${SERVICE_VERSION}-allinone.jar $DITTO_HOME
8 changes: 4 additions & 4 deletions policies/service/src/main/resources/policies.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ ditto {
}
}

extensions.snapshot-adapter = {
extension-class = "org.eclipse.ditto.policies.service.persistence.serializer.PolicyMongoSnapshotAdapter"
}

mongodb {
database = "policies"
database = ${?MONGO_DB_DATABASE}
Expand All @@ -26,10 +30,6 @@ ditto {

policies {

snapshot-adapter = {
extension-class = "org.eclipse.ditto.policies.service.persistence.serializer.PolicyMongoSnapshotAdapter"
}

policy {
# the configuration to which duration the "expiry" of a Policy Subject should be rounded up.
# For example:
Expand Down
8 changes: 4 additions & 4 deletions things/service/src/main/resources/things.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ ditto {
}
}

extensions.snapshot-adapter = {
extension-class = "org.eclipse.ditto.things.service.persistence.serializer.ThingMongoSnapshotAdapter"
}

mongodb {
database = "things"
database = ${?MONGO_DB_DATABASE}
Expand All @@ -27,10 +31,6 @@ ditto {

things {

snapshot-adapter = {
extension-class = "org.eclipse.ditto.things.service.persistence.serializer.ThingMongoSnapshotAdapter"
}

# Logs for all incoming messages minimal information to enable message tracing throughout the system
log-incoming-messages = true
log-incoming-messages = ${?LOG_INCOMING_MESSAGES}
Expand Down

0 comments on commit 383602e

Please sign in to comment.