Commit 7df46782 authored by Unai's avatar Unai 🇵🇲

Dockerfile and Compose YML added to automatize deployment

parent b47e2544
#FROM openjdk:8-jre-slim
FROM maven:3.6.1-jdk-8-alpine
WORKDIR /root
ADD ./src /root/nfrtool-comms/src
ADD ./pom.xml /root/nfrtool-comms/pom.xml
ADD ./files /root/nfrtool-comms/files
ADD entrypoint.sh /entrypoint.sh
RUN apk add --no-cache --update tini && \
chmod +x /entrypoint.sh && \
/bin/sh -c "mvn -f /root/nfrtool-comms/ dependency:go-offline || true"
ENTRYPOINT ["/sbin/tini", "--", "/entrypoint.sh", "java", "-jar", "/root/nfrtool.jar"]
#!/bin/sh
set -e
# set -x
CONTRACT_ID_FILE=${DC_SHARED_VOLUME}/${NAMESPACE}_contractid
export DATACLAY_JAR="${DC_VOL_PATH}/dataclay.jar"
export CLASSPATH="${CLASSPATH}:${DATACLAY_JAR}"
export PATH="${PATH}:${DC_VOL_PATH}/entrypoints"
########################### create cfgfiles ###########################
mkdir -p "${DC_CONFIG_PATH}"
printf "HOST=%s\nTCPPORT=%d" "${LOGICMODULE_HOST}" "${LOGICMODULE_PORT_TCP}" > "${DC_CONFIG_PATH}/client.properties"
echo "Account=${USER}
Password=${PASS}
DataSets=${DATASET}
DataSetForStore=${DATASET}
StubsClasspath=${STUBSPATH}" > "${DC_CONFIG_PATH}/session.properties"
######################################################
# Wait for dataclay to be alive (max retries 10 and 5 seconds per retry)
dataclaycmd WaitForDataClayToBeAlive 10 5
# Wait for contract id in shared volume
while [ ! -f "${CONTRACT_ID_FILE}" ]; do echo "Waiting for contract ID at ${CONTRACT_ID_FILE}..."; sleep 5; done
# Get stubs
mkdir -p "${STUBSPATH}"
dataclaycmd GetStubs "${USER}" "${PASS}" "${NAMESPACE}" "${STUBSPATH}"
# Encapsulate stubs into JAR, then install
cd "${STUBSPATH}"
jar cf stubs.jar es/bsc/compss/nfr/model
mvn install:install-file -Dfile=stubs.jar -DgroupId=es.bsc.compss -DartifactId=nfrtool-dataclay-stubs -Dversion=2.0 -Dpackaging=jar -DcreateChecksum=true
cd -
mvn -f /root/nfrtool-comms/ clean package -DskipTests
cp /root/nfrtool-comms/target/nfrtool.jar /root/
# Execute command
exec "$@"
......@@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.UUID;
import java.util.function.Function;
......@@ -56,7 +57,8 @@ public class ResourceManagerCommsTask extends ResourceManager implements MqttCal
}
private void initializeMqttClient() throws MqttException {
final String broker = "tcp://localhost:1883";
final String broker = Optional.ofNullable(System.getenv("MQTT_BROKER_URL"))
.orElse("tcp://localhost:1883");
final String clientId = UUID.randomUUID().toString();
final MqttConnectOptions connectOptions = new MqttConnectOptions();
......
version: '3.5'
services:
logicmodule:
image: "bscdataclay/logicmodule:alpine"
command: "${COMMAND_OPTS}"
ports:
- "11034:11034"
environment:
- LOGICMODULE_PORT_TCP=11034
- LOGICMODULE_HOST=logicmodule
- DATACLAY_ADMIN_USER=admin
- DATACLAY_ADMIN_PASSWORD=admin
stop_grace_period: 5m
healthcheck:
interval: 5s
retries: 10
test: ["CMD-SHELL", "/home/dataclayusr/dataclay/health/health_check.sh"]
dsjava:
image: "bscdataclay/dsjava:alpine"
command: "${COMMAND_OPTS}"
ports:
- "2127:2127"
depends_on:
- logicmodule
environment:
- DATASERVICE_NAME=DS1
- DATASERVICE_JAVA_PORT_TCP=2127
- LOGICMODULE_PORT_TCP=11034
- LOGICMODULE_HOST=logicmodule
# - DATASERVICE_HOST=dsjava
stop_grace_period: 5m
healthcheck:
interval: 5s
retries: 10
test: ["CMD-SHELL", "/home/dataclayusr/dataclay/health/health_check.sh"]
dcinitializer:
image: "elasticeuh2020/dataclay-initializer:1.6"
depends_on:
- logicmodule
volumes:
- dataclay-init:/srv/dataclay/shared
- ./model/model/:/model/
environment:
- LOGICMODULE_PORT_TCP=11034
- LOGICMODULE_HOST=logicmodule
- USER=ElasticUser
- PASS=ElasticPass
- DATASET=ElasticDS
- JAVA_MODELS_PATH=/model
- JAVA_NAMESPACES=ElasticNS
healthcheck:
interval: 5s
retries: 10
test: [ "CMD-SHELL", "/dataclay-initializer/health_check.sh" ]
dataclay-cmd:
image: "bscdataclay/client:2.5.dev"
tty: true
stdin_open: true
entrypoint: "sh"
volumes:
- dataclay-cli:/home/dataclayusr/dataclay/
mosquitto:
image: "eclipse-mosquitto"
ports:
- "1883:1883"
nfrtool-comms:
image: "nfrtool-comms"
build: ./app
network_mode: host
depends_on:
- dataclay-cmd
- dcinitializer
- mosquitto
volumes:
- dataclay-init:/srv/dataclay/shared:ro
- dataclay-cli:/root/dataclay:ro
environment:
- DC_VOL_PATH=/root/dataclay
- DC_SHARED_VOLUME=/srv/dataclay/shared
- USER=ElasticUser
- PASS=ElasticPass
- DATASET=ElasticDS
- NAMESPACE=ElasticNS
- STUBSPATH=/root/stubs
- DC_CONFIG_PATH=/root/cfgfiles
- LOGICMODULE_HOST=localhost
- LOGICMODULE_PORT_TCP=11034
- MQTT_BROKER_URL=tcp://localhost:1883
restart: on-failure
volumes:
dataclay-init:
driver: local
dataclay-cli:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment