deploy script and elastic script changes

This commit is contained in:
Alexandros Mandilaras 2024-05-16 13:33:48 +03:00
parent baa49851b4
commit 9441f0f326
3 changed files with 56 additions and 29 deletions

View File

@ -26,19 +26,16 @@ docker-compose pull
chmod 744 ./elk/elasticsearch/index_init.sh
recreate_directories() {
echo "Resetting postgres and elasticsearch..."
if [[ $1 == "-r" ]]; then
echo "Resetting PostgreSQL and Elasticsearch storage..."
sudo rm -rf ./storage/postgres/data
mkdir -p ./storage/postgres/data
sudo rm -rf ./storage/elasticsearch
mkdir -p ./storage/elasticsearch
}
if [[ $1 == "-r" ]]; then
recreate_directories
fi
echo "Deploying Elasticsearch Container"
docker-compose up -d opencdmp.elasticsearch
function loading_icon() {
@ -61,7 +58,7 @@ function loading_icon() {
printf " \b\n"
}
loading_icon 45 "Waiting for Elasticsearch to Startup!"
loading_icon 60 "Waiting for Elasticsearch to Startup!"
docker exec opencdmp.elasticsearch /usr/share/elasticsearch/config/index_init.sh
@ -73,6 +70,8 @@ loading_icon 20 "Waiting for PostgreSQL to Initialize!"
docker-compose up -d opencdmp.keycloak
loading_icon 60 "Waiting for Keycloak to Startup!"
loading_icon 90 "Waiting for Keycloak to Startup!"
docker-compose up -d
loading_icon 60 "Waiting for the Backend to Startup!"

View File

@ -1,14 +1,20 @@
services:
############################## PROXY ########################################
opencdmp.proxy:
container_name: opencdmp.proxy
image: nginx:${PROXY_TAG}
depends_on:
- opencdmp.frontend
- opencdmp.backend
- opencdmp.notification
- opencdmp.annotation
# - opencdmp.keycloak
opencdmp.frontend:
condition: service_started
opencdmp.backend:
condition: service_started
opencdmp.notification:
condition: service_started
opencdmp.annotation:
condition: service_started
opencdmp.keycloak:
condition: service_started
############################## OPENDMP APP #################################
@ -16,27 +22,41 @@ services:
container_name: opencdmp.frontend
image: ${DOCKER_REGISTRY}open-dmp-webapp:${MAIN_APP_TAG}
depends_on:
- opencdmp.backend
- opencdmp.notification
- opencdmp.annotation
opencdmp.backend:
condition: service_started
opencdmp.notification:
condition: service_started
opencdmp.annotation:
condition: service_started
opencdmp.backend:
container_name: opencdmp.backend
image: ${DOCKER_REGISTRY}open-dmp-api:${MAIN_APP_TAG}
depends_on:
- opencdmp.postgres
opencdmp.postgres:
condition: service_started
opencdmp.keycloak:
condition: service_started
opencdmp.notification:
container_name: opencdmp.notification
image: ${DOCKER_REGISTRY}open-dmp-notification-api:${NOTIFICATION_APP_TAG}
depends_on:
- opencdmp.postgres
opencdmp.postgres:
condition: service_started
opencdmp.keycloak:
condition: service_started
opencdmp.annotation:
container_name: opencdmp.annotation
image: ${DOCKER_REGISTRY}open-dmp-annotation-api:${ANNOTATION_APP_TAG}
depends_on:
- opencdmp.postgres
opencdmp.postgres:
condition: service_started
opencdmp.keycloak:
condition: service_started
opencdmp.backend:
condition: service_started
# # ############################## FILE-TRANSFORMERS #######################################
@ -44,20 +64,23 @@ services:
container_name: opencdmp.file.transformer.docx
image: ${DOCKER_REGISTRY}file-transformation-docx-api:${DOCX_APP_TAG}
depends_on:
- opencdmp.backend
opencdmp.backend:
condition: service_started
opencdmp.file.transformer.rdajson:
container_name: opencdmp.file.transformer.rdajson
image: ${DOCKER_REGISTRY}file-transformation-rda-json-api:${JSON_APP_TAG}
depends_on:
- opencdmp.backend
opencdmp.backend:
condition: service_started
# ################################ ZENODO ###############################################
opencdmp.zenodo:
container_name: opencdmp.zenodo
image: ${DOCKER_REGISTRY}repository-deposit-zenodo:${ZENODO_APP_TAG}
depends_on:
- opencdmp.backend
opencdmp.backend:
condition: service_started
############################## POSTGRES 16 ############################################
opencdmp.postgres:

View File

@ -1,5 +1,5 @@
#!/bin/bash
echo "Elasticsearch is now available. Proceeding with initialization..."
set -e
echo "Creating Elasticsearch indexes, roles, and users..."
@ -17,7 +17,7 @@ curl -XPUT "http://localhost:9200/opencdmp-plans-test" -u elastic:elastic -H 'Co
"date_added": { "type": "date" }
}
}
}'
}' || { echo "Failed to create the 'plans' index"; exit 1; }
# Command to create the "descriptions" index
curl -XPUT "http://localhost:9200/opencdmp-descriptions-test" -u elastic:elastic -H 'Content-Type: application/json' -d '{
@ -32,8 +32,9 @@ curl -XPUT "http://localhost:9200/opencdmp-descriptions-test" -u elastic:elastic
"language": { "type": "keyword" }
}
}
}'
}' || { echo "Failed to create the 'descriptions' index"; exit 1; }
# Command to create the role
curl -XPOST "localhost:9200/_security/role/opencdmp-api-test" -u elastic:elastic -H 'Content-Type: application/json' -d '{
"indices": [
{
@ -41,12 +42,16 @@ curl -XPOST "localhost:9200/_security/role/opencdmp-api-test" -u elastic:elastic
"privileges": [ "all" ]
}
]
}'
}' || { echo "Failed to create the role"; exit 1; }
# Command to create the user
curl -XPOST "localhost:9200/_security/user/opencdmp-api-test?pretty" -u elastic:elastic -H 'Content-Type: application/json' -d '
{
"password" : "opencdmp",
"roles" : [ "opencdmp-api-test" ]
}'
}' || { echo "Failed to create the user"; exit 1; }
elasticsearch-plugin install analysis-icu
# Install the analysis-icu plugin
elasticsearch-plugin install analysis-icu || { echo "Failed to install the analysis-icu plugin"; exit 1; }
echo "Initialization complete."