Commit 814f3ba4 authored by dgasull's avatar dgasull

Added utility scripts to register model and get stubs

parent bf50ad71
FROM bscdataclay/client:2.1
LABEL maintainer dataClay team <support-dataclay@bsc.es>
# Prepare environment
ENV ELASTIC_MODEL_HOME=/elastic
WORKDIR ${ELASTIC_MODEL_HOME}
ENV DATACLAYCLIENTCONFIG=${ELASTIC_MODEL_HOME}/cfgfiles/client.properties
ENV DATACLAYGLOBALCONFIG=${ELASTIC_MODEL_HOME}/cfgfiles/global.properties
ENV DATACLAYSESSIONCONFIG=${ELASTIC_MODEL_HOME}/cfgfiles/session.properties
ENV NAMESPACE=ElasticNS
ENV USER=ElasticUser
ENV PASS=ElasticPass
ENV DATASET=ElasticDS
ENV STUBSPATH=${ELASTIC_MODEL_HOME}/stubs
ENV STUBS_JAR=${ELASTIC_MODEL_HOME}/stubs.jar
ENV MODELBINPATH=${ELASTIC_MODEL_HOME}/model/target/classes
# If we want to run demo again, argument must be modified
ARG CACHEBUST=1
# Copy files
COPY ./model ${ELASTIC_MODEL_HOME}/model
COPY ./cfgfiles ${ELASTIC_MODEL_HOME}/cfgfiles
RUN cp ${ELASTIC_MODEL_HOME}/cfgfiles/log4j2.xml ${DATACLAY_LOG_CONFIG}
# Wait for dataclay to be alive (max retries 10 and 5 seconds per retry)
RUN dataclaycmd WaitForDataClayToBeAlive 10 5
# Register account
RUN dataclaycmd NewAccount ${USER} ${PASS}
# Register datacontract
RUN dataclaycmd NewDataContract ${USER} ${PASS} ${DATASET} ${USER}
# Register model
RUN cd ${ELASTIC_MODEL_HOME}/model && mvn package
RUN dataclaycmd NewModel ${USER} ${PASS} ${NAMESPACE} ${MODELBINPATH} java
# Get stubs
RUN mkdir -p ${STUBSPATH}
RUN dataclaycmd GetStubs ${USER} ${PASS} ${NAMESPACE} ${STUBSPATH}
# Package stubs
RUN jar cvf ${STUBS_JAR} -C ${STUBSPATH} .
# Run
ENTRYPOINT ["Nothing to do here"]
......@@ -15,6 +15,14 @@ Some useful scripts can be found here.
Start dataClay before running our demo docker application.
##### REGISTER MODEL (`register_model.sh`)
Register model located in `model` folder into started dataClay instance at host and ports specified in `cfgfiles/client.properties`. This script uses `Dockerfile` to register the model.
##### GET STUBS (`get_stubs.sh`)
Get stubs of your registered model. Make sure you registered your model first.
##### STOP DATACLAY (`stop_dataclay.sh`)
Do a graceful stop of dataClay.
......
Account=ElasticUser
Password=ElasticPass
DataSets=ElasticDS
DataSetForStore=ElasticDS
StubsClasspath=./stubs
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
grn=$'\e[1;32m'
blu=$'\e[1;34m'
red=$'\e[1;91m'
end=$'\e[0m'
function printError {
echo "${red}======== $1 ========${end}"
}
function printMsg {
echo "${blu}======== $1 ========${end}"
}
printMsg "Get stubs"
rm -rf $PWD/stubs
mkdir -p $PWD/stubs/
ID=$(docker create dataclay-elastic-model)
docker cp $ID:/elastic/stubs $PWD
docker rm $ID
echo "$blu
Stubs stored at $PWD/stubs/ directory
Congratulations! Now you can use stubs.jar and $PWD/cfgfiles/session.properties in your application.
Remember to modify StubsClasspath variable in session.properties file. $end
"
\ No newline at end of file
#!/bin/bash
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
grn=$'\e[1;32m'
blu=$'\e[1;34m'
red=$'\e[1;91m'
end=$'\e[0m'
function printError {
echo "${red}======== $1 ========${end}"
}
function printMsg {
echo "${blu}======== $1 ========${end}"
}
printMsg "Registering model"
docker build --network=dataclay_default \
--build-arg CACHEBUST=$(date +%s) \
-t dataclay-elastic-model .
printMsg "Model successfully registered!"
\ No newline at end of file
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