<commit_before>#!/bin/bash
##############################################
# Bring up a docker container with ES + plugin
##############################################

# Ensure cleanup
rm -rf docker || true
mkdir docker || true

# Obtain the version to compose the zip file name
PLUGIN_VERSION=`grep plugin_version pom.xml | sed 's|</b>|-|g' | sed 's|<[^>]*>||g' |xargs`
ES_VERSION=`grep '<elasticsearch.version'  pom.xml | sed 's|</b>|-|g' | sed 's|<[^>]*>||g' |xargs`
VERSION=`echo "v$PLUGIN_VERSION es-v$ES_VERSION" |tr " " "_"`

# Dynamically generate docker file from template
cat Dockerfile.tpl |sed -e "s/\${VERSION}/$VERSION/" -e "s/\${PLUGIN_VERSION}/$PLUGIN_VERSION/" -e "s/\${ES_VERSION}/$ES_VERSION/" > docker/Dockerfile

#PLUGIN_ZIP=elasticsearch-readonlyrest-$VERSION.zip

# Populate the conf files with test yml
cp src/test/test_rules.yml docker/elasticsearch.yml
cp target/elasticsearch-readonlyrest-$VERSION.zip docker

# Build and launch docker container
cd docker && docker build -t readonlyrest:$VERSION .
docker run -d --net=host readonlyrest:$VERSION

# Cleanup
rm -rf docker

docker rm -f `docker ps |grep readonlyrest| awk '{print $1}'`
docker run -it  --net=host readonlyrest:$VERSION<commit_msg>custom configuration file accepted by docker test script<commit_after>#!/bin/bash
##############################################
# Bring up a docker container with ES + plugin
##############################################

# Ensure cleanup
rm -rf docker || true
mkdir docker || true

# Obtain the version to compose the zip file name
PLUGIN_VERSION=`grep plugin_version pom.xml | sed 's|</b>|-|g' | sed 's|<[^>]*>||g' |xargs`
ES_VERSION=`grep '<elasticsearch.version'  pom.xml | sed 's|</b>|-|g' | sed 's|<[^>]*>||g' |xargs`
VERSION=`echo "v$PLUGIN_VERSION es-v$ES_VERSION" |tr " " "_"`

# Dynamically generate docker file from template
cat Dockerfile.tpl |sed -e "s/\${VERSION}/$VERSION/" -e "s/\${PLUGIN_VERSION}/$PLUGIN_VERSION/" -e "s/\${ES_VERSION}/$ES_VERSION/" > docker/Dockerfile

#PLUGIN_ZIP=elasticsearch-readonlyrest-$VERSION.zip

if [ ! -z "$1" ]
then
 CONF_FILE="$1"
else
 CONF_FILE="src/test/test_rules.yml"
fi
echo ">> Using conf file $CONF_FILE"
cat $CONF_FILE

# Populate the conf files with test yml
cp $CONF_FILE docker/elasticsearch.yml

cp target/elasticsearch-readonlyrest-$VERSION.zip docker

# Build and launch docker container
cd docker && docker build -t readonlyrest:$VERSION .
docker run -d --net=host readonlyrest:$VERSION

# Cleanup
rm -rf docker

docker rm -f `docker ps |grep readonlyrest| awk '{print $1}'`
docker run -it  --net=host readonlyrest:$VERSION
{'fraction_non_alphanumeric': 0.21256223669092303, 'fraction_numerical': 0.0015319800842589046, 'mean_word_length': 5.248803827751196, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3444383', 'n_tokens_mistral': 914, 'n_tokens_neox': 846, 'n_words': 245}