Skip to content

Commit

Permalink
Add deploy script for core development
Browse files Browse the repository at this point in the history
  • Loading branch information
urubens committed Dec 21, 2018
1 parent 5f1e4dc commit b192632
Show file tree
Hide file tree
Showing 2 changed files with 220 additions and 1 deletion.
219 changes: 219 additions & 0 deletions dev_core_start_deploy.sh.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
#!/bin/bash

#
# Copyright (c) 2009-2018. Authors: see NOTICE file.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Create server SSH keys if needed
SERVER_SSHKEYS_FILE="$SERVER_SSHKEYS_PATH/id_rsa"
if [ ! -e $SERVER_SSHKEYS_FILE ]
then
apt-get install -y ssh-keygen
ssh-keygen -t rsa -N "" -C $CORE_URL -f $SERVER_SSHKEYS_FILE
fi


# ----- MEMCACHED -----
docker create --name memcached \
--restart=unless-stopped \
$MEMCACHED_NAMESPACE/memcached:$MEMCACHED_VERSION > /dev/null

docker cp $PWD/configs/memcached/memcached.conf memcached:/etc/memcached.conf
docker start memcached


# ----- RABBITMQ -----
docker create --name rabbitmq \
-p 5672:5672 -p 15672:15672 \
-e RABBITMQ_PASS=$RABBITMQ_PASSWORD \
--restart=unless-stopped \
$RABBITMQ_NAMESPACE/rabbitmq:$RABBITMQ_VERSION > /dev/null

docker start rabbitmq


# ----- POSTGRESQL ------
docker volume create --name postgis_data > /dev/null
docker run -d -m 8g -p 5432:5432 --name postgresql -v postgis_data:/var/lib/postgresql \
--restart=unless-stopped \
$POSTGIS_NAMESPACE/postgis:$POSTGIS_VERSION > /dev/null


# ----- MONGODB -----
docker volume create --name mongodb_data > /dev/null
docker run -d -p 27017:27017 -p 28017:28017 --name mongodb -v mongodb_data:/data/db \
--restart=unless-stopped \
$MONGODB_NAMESPACE/mongodb:$MONGODB_VERSION > /dev/null


# ----- BACKUP POSTGRESQL -----
if [ $BACKUP_BOOL = true ]
then
# create backup docker
docker run -d --name backup_postgis --link postgresql:db -v $BACKUP_PATH/postgis:/backup --restart=unless-stopped \
-e SENDER_EMAIL=$SENDER_EMAIL \
-e SENDER_EMAIL_PASS=$SENDER_EMAIL_PASS \
-e SENDER_EMAIL_SMTP_HOST=$SENDER_EMAIL_SMTP_HOST \
-e SENDER_EMAIL_SMTP_PORT=$SENDER_EMAIL_SMTP_PORT \
-e RECEIVER_EMAIL=$RECEIVER_EMAIL \
-e SGBD='postgres' \
-e DATABASE='docker' \
-e USER='docker' \
-e PASSWD='docker' \
$BACKUP_NAMESPACE/backup:$BACKUP_VERSION > /dev/null
fi


# ----- BACKUP MONGODB -----
if [ $BACKUP_BOOL = true ]
then
docker run -d --name backup_mongo --link mongodb:db -v $BACKUP_PATH/mongo:/backup --restart=unless-stopped \
-e SGBD='mongodb' \
-e SENDER_EMAIL=$SENDER_EMAIL \
-e SENDER_EMAIL_PASS=$SENDER_EMAIL_PASS \
-e SENDER_EMAIL_SMTP_HOST=$SENDER_EMAIL_SMTP_HOST \
-e SENDER_EMAIL_SMTP_PORT=$SENDER_EMAIL_SMTP_PORT \
-e RECEIVER_EMAIL=$RECEIVER_EMAIL \
$BACKUP_NAMESPACE/backup:$BACKUP_VERSION > /dev/null
fi

# ----- RETRIEVAL -----
docker create --name retrieval \
-v $RETRIEVAL_PATH:/data/thumb \
-e RETRIEVAL_ENGINE=$RETRIEVAL_ENGINE \
-e RETRIEVAL_PASSWORD=$RETRIEVAL_PASSWORD \
--restart=unless-stopped \
$RETRIEVAL_NAMESPACE/retrieval:$RETRIEVAL_VERSION > /dev/null

docker cp $PWD/hosts/retrieval/addHosts.sh retrieval:/tmp/addHosts.sh
docker start retrieval


# ----- IIP JP2 -----
docker create --name iipJP2 \
--link memcached:memcached \
-v $IMS_STORAGE_PATH:$IMS_STORAGE_PATH \
--privileged \
-e NB_IIP_PROCESS=$NB_IIP_PROCESS \
--restart=unless-stopped \
$IIPJP2_NAMESPACE/iip-jp2000:$IIPJP2_VERSION > /dev/null

docker cp $PWD/configs/iipJP2/nginx.conf.sample iipJP2:/tmp/nginx.conf.sample
docker start iipJP2


# ----- IIP CYTO -----
docker create --name iipCyto \
--link memcached:memcached \
-v $IMS_STORAGE_PATH:$IMS_STORAGE_PATH \
--privileged \
-e NB_IIP_PROCESS=$NB_IIP_PROCESS \
--restart=unless-stopped \
$IIPCYTO_NAMESPACE/iip-cyto:$IIPCYTO_VERSION > /dev/null

docker cp $PWD/configs/iipCyto/nginx.conf.sample iipCyto:/tmp/nginx.conf.sample
docker cp $PWD/configs/iipCyto/iip-configuration.sh iipCyto:/tmp/iip-configuration.sh
docker start iipCyto


# ----- BIOFORMAT -----
docker create --name bioformat \
-v $IMS_STORAGE_PATH:$IMS_STORAGE_PATH \
-e BIOFORMAT_PORT=$BIOFORMAT_PORT \
--restart=unless-stopped \
$BIOFORMAT_NAMESPACE/bioformat:$BIOFORMAT_VERSION > /dev/null

docker start bioformat


# ----- IMS -----
docker create --name ims \
--link bioformat:bioformat \
-e IMS_STORAGE_PATH=$IMS_STORAGE_PATH \
-e FAST_DATA_PATH=$FAST_DATA_PATH \
-v $IMS_STORAGE_PATH:$IMS_STORAGE_PATH \
-v $IMS_BUFFER_PATH:/tmp/uploaded \
-v $FAST_DATA_PATH:$FAST_DATA_PATH \
--restart=unless-stopped \
$IMS_NAMESPACE/ims:$IMS_VERSION > /dev/null

docker cp $PWD/configs/ims/imageserverconfig.properties ims:/usr/share/tomcat7/.grails/imageserverconfig.properties
docker cp $PWD/hosts/ims/addHosts.sh ims:/tmp/addHosts.sh
docker start ims


# ----- IRIS -----
docker volume create --name iris_data > /dev/null
docker create --name iris \
-v iris_data:/var/lib/tomcat7/db \
--restart=unless-stopped \
$IRIS_NAMESPACE/iris:$IRIS_VERSION > /dev/null

docker cp $PWD/configs/iris/iris-config.groovy iris:/usr/share/tomcat7/.grails/iris-config.groovy
docker cp $PWD/configs/iris/iris-production-config.groovy iris:/usr/share/tomcat7/.grails/iris-production-config.groovy
docker cp $PWD/hosts/iris/addHosts.sh iris:/tmp/addHosts.sh
docker start iris


# ----- NGINX -----
docker create --name nginx \
--link iris:iris \
--link ims:ims \
--link retrieval:retrieval \
--link iipCyto:iipCyto \
--link iipJP2:iipJP2 \
-v $IMS_BUFFER_PATH:/tmp/uploaded \
-p 80:80 \
--restart=unless-stopped \
$NGINX_NAMESPACE/nginx:$NGINX_VERSION > /dev/null

docker cp $PWD/configs/nginx/nginxDevCore.conf nginx:/usr/local/nginx/conf/nginx.conf
docker start nginx


# ----- SLURM -----
docker volume create --name slurm_data > /dev/null
docker create --name slurm -t -h cytomine-slurm \
--privileged \
-v slurm_data:/var/lib/mysql \
-v /etc/localtime:/etc/localtime \
-v $SERVER_SSHKEYS_PATH:$SERVER_SSHKEYS_PATH \
-v $SOFTWARE_DOCKER_IMAGES_PATH:$SOFTWARE_DOCKER_IMAGES_PATH \
-e SERVER_SSHKEYS_FILE=$SERVER_SSHKEYS_FILE \
-p 10022:22 \
--restart=unless-stopped \
$SLURM_NAMESPACE/slurm:$SLURM_VERSION > /dev/null

docker cp $PWD/hosts/slurm/addHosts.sh slurm:/tmp/addHosts.sh
docker start slurm


# ----- SOFTWARE ROUTER -----
docker create --name software_router \
--link rabbitmq:rabbitmq \
--link slurm:slurm \
--privileged \
-v $SOFTWARE_CODE_PATH:$SOFTWARE_CODE_PATH \
-v $SOFTWARE_DOCKER_IMAGES_PATH:$SOFTWARE_DOCKER_IMAGES_PATH \
-v $JOBS_PATH:$JOBS_PATH \
-v $SERVER_SSHKEYS_PATH:$SERVER_SSHKEYS_PATH \
--restart=unless-stopped \
-p 22 \
$SOFTWAREROUTER_NAMESPACE/software_router:$SOFTWAREROUTER_VERSION > /dev/null

docker cp $PWD/hosts/software_router/addHosts.sh software_router:/tmp/addHosts.sh
docker cp $PWD/configs/software_router/config.groovy software_router:/opt/config.groovy
docker cp $PWD/configs/software_router/log4j.properties software_router:/opt/log4j.properties
docker start software_router
2 changes: 1 addition & 1 deletion init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
FILES=(configs/core/cytomineconfig.groovy configs/ims/imageserverconfig.properties configs/iipCyto/nginx.conf.sample configs/iipCyto/iip-configuration.sh.sample configs/iipJP2/nginx.conf.sample configs/iris/iris-config.groovy configs/iris/iris-production-config.groovy configs/nginx/nginx.conf configs/nginx/nginxDevCore.conf configs/nginx/nginxDevIMS.conf configs/software_router/config.groovy start_deploy.sh hosts/core/addHosts.sh hosts/ims/addHosts.sh hosts/retrieval/addHosts.sh hosts/iris/addHosts.sh hosts/software_router/addHosts.sh hosts/slurm/addHosts.sh)
FILES=(configs/core/cytomineconfig.groovy configs/ims/imageserverconfig.properties configs/iipCyto/nginx.conf.sample configs/iipCyto/iip-configuration.sh configs/iipJP2/nginx.conf.sample configs/iris/iris-config.groovy configs/iris/iris-production-config.groovy configs/nginx/nginx.conf configs/nginx/nginxDevCore.conf configs/nginx/nginxDevIMS.conf configs/software_router/config.groovy start_deploy.sh dev_core_start_deploy.sh hosts/core/addHosts.sh hosts/ims/addHosts.sh hosts/retrieval/addHosts.sh hosts/iris/addHosts.sh hosts/software_router/addHosts.sh hosts/slurm/addHosts.sh)

#get all the config values.
. ./configuration.sh
Expand Down

0 comments on commit b192632

Please sign in to comment.