Skip to content

Commit

Permalink
unified deployment and data persistance (#122)
Browse files Browse the repository at this point in the history
* unified deployment for linux and windows

* persistent volume updates

* updating info related to kubernetes deployment
  • Loading branch information
ankicabarisic authored Feb 5, 2025
1 parent c3457ce commit aee32f0
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 57 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ docker pull activeeon/sal:dev

* Open [docker-compose.yaml](https://github.com/ow2-proactive/scheduling-abstraction-layer/blob/master/docker/docker-compose.yaml)

* Setup connection to the ProActive scheduler (line 43-45)
* Setup connection to the ProActive scheduler

```bash
sal:
Expand All @@ -108,7 +108,7 @@ sal:
PWS_PASSWORD: <CHANGE_ME>
```

* Setup which SAL image will be used (line 19):
* Setup which SAL image will be used:

```bash
sal:
Expand All @@ -117,7 +117,7 @@ image: activeeon/sal:test
```
NOTE: It is possible to generate automatically an image from the `.war` file generated in section 2.1.1. In this case the image tag (e.g. test) should not exist in DockerHub repository.

* Setup database PASSWORD (line 9, 13 & 47):
* Setup database PASSWORD :
```bash
environment:
MYSQL_ROOT_PASSWORD: PASSWORD
Expand All @@ -131,16 +131,25 @@ environment:
test: [ "CMD", "mariadb-admin" , "ping", "-h", "localhost", "--password=PASSWORD" ]
```

* Setup SAL ports (line 29-33):
* Setup SAL ports :
```bash
sal:
ports:
- "8088:8080" # sal service ports
- "9001:9001" # sal-pda service ports for debugging
```
* In a case you are running SAL on Windows change the Dockerfile to be used (line 25):

* In a case you do not want to use the deployment with persistent volume comment following:
```bash
# Comment this if you do not want to attach a volume for persistent data storage:
volumes:
- mariadb_data:/var/lib/mysql
```

```bash
dockerfile: ./docker/Dockerfile.win
#Comment this part if you do not want to include volume for peristant data storage
volumes:
mariadb_data: {}
```

NOTE: In a case of committing improvements to the SAL project, you will need to keep your local changes to the `docker-compose.yaml` untracked. Use the following command:
Expand Down
32 changes: 0 additions & 32 deletions docker/Dockerfile.win

This file was deleted.

15 changes: 7 additions & 8 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,24 @@ To automate the deployment of the docker compose of SAL you create the following
```bash
#!/bin/bash


cd <SAL_REPO_HOME_DIR>

./gradlew spotlessApply clean build --refresh-dependencies

cd <DOCKER_SAL_DIR>

rm -f ./artefacts/scheduling-abstraction-layer-13.1.0-SNAPSHOT.war

cp <SAL_REPO_HOME_DIR>/sal-service/build/libs/scheduling-abstraction-layer-13.1.0-SNAPSHOT.war ./artefacts

docker-compose down

docker build -t activeeon/sal:test -f ./Dockerfile --no-cache .

docker-compose up
docker-compose up --build


```
> NOTE: Please change `<SAL_REPO_HOME_DIR>` and `<DOCKER_SAL_DIR>` to the correct ones. In case SAL is built on Windows, use `./Dockerfile.win` instead of `./Dockerfile`.
Each time the code is modified in `<SAL_REPO_HOME_DIR>`, you can run this script and it will automatically launch a new container with the changes included.

# Kubernetes deployment

Example of deployment script for kubernetes without persistent volume can be found under ./kubernetes/sal.yaml

The example of deployment with persistent volume can be found at: https://github.com/eu-nebulous/helm-charts/tree/main/charts/nebulous-sal
19 changes: 12 additions & 7 deletions docker/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
database:
image: mariadb #optionaly set specific version e.g. mariadb:10.7
image: mariadb:latest #optionaly set specific version e.g. mariadb:10.7
ports:
- "3307:3306"
networks:
Expand All @@ -9,19 +9,20 @@ services:
MYSQL_ROOT_PASSWORD: PASSWORD
MYSQL_DATABASE: proactive
container_name: myComposeMariaDB
# Comment this if you do not want to attach a volume for persistent data storage:
volumes:
- mariadb_data:/var/lib/mysql
healthcheck:
test: [ "CMD", "mariadb-admin" , "ping", "-h", "localhost", "--password=PASSWORD" ]
interval: 5s
interval: 10s
timeout: 5s
retries: 5
start_period: 60s
sal:
#Set up image to be used for SAL from https://hub.docker.com/r/activeeon/sal/tags
image: activeeon/sal:test
build:
context: ..
#Set up Dockerfile to be used:
#Dockerfile is used for Jenkins image creation
#Dockerfile.win to be used for local build on Windows
dockerfile: ./docker/Dockerfile
depends_on:
database:
Expand All @@ -37,6 +38,7 @@ services:
- db-tier
volumes:
- ./scripts:/usr/local/tomcat/scripts
- ./wait_for_db.sh:/usr/local/tomcat/bin/wait_for_db.sh
environment:
PROPERTIES_FILENAME: sal
#Set up connection to ProActive server (PWS)
Expand All @@ -52,7 +54,10 @@ services:
DB_PLATFORM: org.hibernate.dialect.MariaDB53Dialect
JPDA_ADDRESS: 9001
JPDA_TRANSPORT: dt_socket
entrypoint: [ "/bin/sh", "-c", "if [ -f /usr/local/tomcat/bin/wait_for_db.sh ]; then /usr/local/tomcat/bin/wait_for_db.sh; fi && catalina.sh run" ]
container_name: myComposeSAL
networks:
# The presence of these objects is sufficient to define them
db-tier: {}
db-tier: {}
#Comment this part if you do not want to include volume for peristant data storage
volumes:
mariadb_data: {}
File renamed without changes.
9 changes: 5 additions & 4 deletions docker/wait_for_db.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/usr/bin/env bash

# Loop until the MariaDB port is listening
while ! nc -z $DB_HOSTNAME $DB_PORT; do
echo "Port $DB_PORT is not yet listening, waiting..."
echo "Waiting for MariaDB to be ready..."

until nc -z "$DB_HOSTNAME" "$DB_PORT"; do
echo "MariaDB is not ready yet..."
sleep 5
done

echo "Port $DB_PORT is now listening!"
echo "MariaDB is ready!"

0 comments on commit aee32f0

Please sign in to comment.