From 7ce80f9f12199a4a9201d63dae4b390d992b0d4b Mon Sep 17 00:00:00 2001 From: yohan <783b8c87@scimetis.net> Date: Wed, 26 Feb 2020 17:33:44 +0100 Subject: [PATCH] Moved image building from docker-compose to startup script. Added mounting volume with openstack. --- docker-compose.yml | 8 ++------ start_or_update.sh | 22 ++++++++++++++++++++-- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 9258105..14b59d5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: elasticsearch: image: elasticsearch:$VERSION_ELASTICSEARCH container_name: elasticsearch - build: "https://git.scimetis.net/yohan/docker-elasticsearch.git" + #build: "https://git.scimetis.net/yohan/docker-elasticsearch.git" environment: - discovery.type=single-node - "ES_JAVA_OPTS=-Xms512m -Xmx512m" @@ -16,12 +16,8 @@ services: networks: - reverse-proxy volumes: - - elasticsearch_data:/usr/share/elasticsearch/data + - /mnt/volumes/elasticsearch_data/data:/usr/share/elasticsearch/data networks: reverse-proxy: external: true - -volumes: - elasticsearch_data: - external: true diff --git a/start_or_update.sh b/start_or_update.sh index d798266..eed8a3e 100755 --- a/start_or_update.sh +++ b/start_or_update.sh @@ -1,5 +1,23 @@ #!/bin/bash # --force-recreate is used to recreate container when crontab file has changed +source ~/openrc.sh +INSTANCE=$(/home/yohan/env_py3/bin/openstack server show -c id --format value $(hostname)) +mkdir -p /mnt/volumes/elasticsearch_data +if ! mountpoint -q /mnt/volumes/elasticsearch_data +then + VOLUME_ID=$(/home/yohan/env_py3/bin/openstack volume show elasticsearch_data -c id --format value) + test -e /dev/disk/by-id/*${VOLUME_ID:0:20} || nova volume-attach $INSTANCE $VOLUME_ID auto + sleep 3 + sudo mount /dev/disk/by-id/*${VOLUME_ID:0:20} /mnt/volumes/elasticsearch_data +fi + unset VERSION_ELASTICSEARCH -VERSION_ELASTICSEARCH=$(git ls-remote https://git.scimetis.net/yohan/docker-elasticsearch.git| head -1 | cut -f 1|cut -c -10) \ - sudo -E bash -c 'docker-compose up -d --force-recreate' +export VERSION_ELASTICSEARCH=$(git ls-remote https://git.scimetis.net/yohan/docker-elasticsearch.git| head -1 | cut -f 1|cut -c -10) + +mkdir -p ~/build +git clone https://git.scimetis.net/yohan/docker-elasticsearch.git ~/build/docker-elasticsearch +sudo docker build -t elasticsearch:$VERSION_ELASTICSEARCH ~/build/docker-elasticsearch + +sudo -E bash -c 'docker-compose up -d --force-recreate' + +rm -rf ~/build