Skip to content

Commit

Permalink
Remove local swarm cluster management from the deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jbernal0019 committed Apr 26, 2021
1 parent 2e89fcf commit 743e985
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 33 deletions.
48 changes: 33 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,9 @@
![License][license-badge]
![Last Commit][last-commit-badge]

Back end for ChRIS Store. This is a Django-MySQL project that houses descriptions of ChRIS plugin-apps and workflows for registering to a ChRIS CUBE instance.
Back end for the ChRIS store. This is a Django-MySQL project that houses descriptions of ChRIS plugin-apps and workflows for registering to a ChRIS CUBE instance.

## ChRIS Store development and testing

### TL;DR

If you read nothing else on this page, and just want to get an instance of the ChRIS store backend services up and
running with no mess, no fuss:

```bash
git clone https://github.com/FNNDSC/ChRIS_store
cd ChRIS_store
./make.sh down ; ./make.sh up
```

The resulting instance uses the default Django development server and therefore is not suitable for production.
## ChRIS store development, testing and deployment

### Abstract

Expand All @@ -35,31 +22,62 @@ This page describes how to quickly get the set of services comprising the backen

Consult this page https://docs.docker.com/engine/install/linux-postinstall/

### TL;DR

If you read nothing else on this page, and just want to get an instance of the ChRIS store backend services up and
running with no mess, no fuss:

```bash
git clone https://github.com/FNNDSC/ChRIS_store
cd ChRIS_store
./make.sh down ; ./make.sh up
```

The resulting instance uses the default Django development server and therefore is not suitable for production.

### Production deployment

#### To get the production system up:

Start a local Docker Swarm cluster if not already started:

```bash
docker swarm init --advertise-addr 127.0.0.1
```

Fetch source code:

```bash
git clone https://github.com/FNNDSC/ChRIS_store
cd ChRIS_store
mkdir secrets
```

Now copy all the required secret configuration files into the secrets directory, please take a look at
[this](https://github.com/FNNDSC/ChRIS_store/wiki/ChRIS-store-backend-production-services-secret-configuration-files)
wiki page to learn more about these files

Deploy ChRIS store backend containers:

```bash
./docker-deploy.sh up
```

#### To tear down:

Remove ChRIS store backend containers:

```bash
cd ChRIS_store
./docker-deploy.sh down
```

Remove the local Docker Swarm cluster if desired:

```bash
docker swarm leave --force
```


### Development

Expand Down
2 changes: 2 additions & 0 deletions docker-compose_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ services:
context: .
args:
ENVIRONMENT: local
stdin_open: true # docker run -i
tty: true # docker run -t
command: python manage.py runserver 0.0.0.0:8010
volumes:
- ./store_backend:/home/localuser/store_backend:z
Expand Down
29 changes: 18 additions & 11 deletions docker-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,28 @@ declare -i STEP=0

if [[ "$1" == 'up' ]]; then

title -d 1 "Stopping and restarting docker swarm cluster... "
docker swarm leave --force
docker swarm init --advertise-addr 127.0.0.1
windowBottom

title -d 1 "Starting containerized production environment using " " ./docker-compose.yml"
docker pull mysql:5
docker pull fnndsc/docker-swift-onlyone
docker pull fnndsc/chris_store
title -d 1 "Starting containerized production environment on using " " ./docker-compose.yml"
echo ""
echo "docker stack deploy -c docker-compose.yml chris_store_stack"
docker stack deploy -c docker-compose.yml chris_store_stack
windowBottom

title -d 1 "Waiting until chris store stack containers are running on swarm"
for i in {1..30}; do
sleep 5
chris_store=$(docker ps -f name=chris_store.1. -q)
if [ -n "$chris_store" ]; then
echo "Success: chris store container is up"
break
fi
done
if [ -z "$chris_store" ]; then
echo "Error: couldn't start chris store container"
exit 1
fi
windowBottom

title -d 1 "Waiting until ChRIS store is ready to accept connections..."
chris_store=$(docker ps -f ancestor=fnndsc/chris_store -f name=chris_store.1. -q)
docker exec $chris_store sh -c 'while ! curl -sSf http://localhost:8010/api/v1/users/ 2> /dev/null; do sleep 5; done;'
windowBottom

Expand All @@ -70,13 +76,14 @@ if [[ "$1" == 'down' ]]; then
title -d 1 "Destroying containerized production environment" "from ./docker-compose.yml"
echo
docker stack rm chris_store_stack
docker swarm leave --force
sleep 10
echo
printf "Do you want to also remove persistent volumes?"
read -p " [y/n] " -n 1 -r
echo
echo
if [[ $REPLY =~ ^[Yy]$ ]] ; then
sleep 10
docker volume rm chris_store_stack_chris_store_db_data
docker volume rm chris_store_stack_swift_storage
fi
Expand Down
14 changes: 7 additions & 7 deletions make.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ G_SYNOPSIS="
NAME
docker-make.sh
make.sh
SYNOPSIS
docker-make.sh [up|down]
make.sh [up|down]
ARGS
Expand All @@ -17,7 +17,7 @@ G_SYNOPSIS="
DESCRIPTION
docker-make.sh script will depending on the argument fire up or tear down the
make.sh script will depending on the argument fire up or tear down the
Chris store development environment.
"
Expand Down Expand Up @@ -125,10 +125,10 @@ if [[ "$1" == 'up' ]]; then
docker-compose -f docker-compose_dev.yml exec chris_store_dev python pipelines/services/manager.py add "${PIPELINE_NAME}" cubeadmin "${PLUGIN_TREE}" --unlock
windowBottom

title -d 1 "Restarting ChRIS store's Django development server" "in interactive mode..."
docker-compose -f docker-compose_dev.yml stop chris_store_dev
docker-compose -f docker-compose_dev.yml rm -f chris_store_dev
docker-compose -f docker-compose_dev.yml run --service-ports chris_store_dev
title -d 1 "Restarting ChRIS store's Django development server..."
docker-compose -f docker-compose_dev.yml restart chris_store_dev
chris_store_dev=$(docker ps -f name=chris_store_dev_1 -q)
docker attach --detach-keys ctrl-c $chris_store_dev
echo ""
windowBottom
fi
Expand Down

0 comments on commit 743e985

Please sign in to comment.