Skip to content

Commit

Permalink
Polish docker composition scripts
Browse files Browse the repository at this point in the history
Now the default port is derived from the database type.
Also, PostgreSQL demo was cleaned up.
  • Loading branch information
mederly committed Sep 21, 2018
1 parent 178aa91 commit 09e3307
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 26 deletions.
16 changes: 4 additions & 12 deletions demo/postgresql/midpoint-additions-for-standalone-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@
#
# (in this directory)
#
# $ docker-compose up --build
# $ docker-compose up
#
# (in ../midpoint directory)
#
# $ docker-compose -f docker-compose.yml -f ../demo/postgresql/midpoint-additions-for-standalone-run.yml up --build
# $ docker-compose -f docker-compose.yml -f ../demo/postgresql/midpoint-additions-for-standalone-run.yml up midpoint-server
#
# It expects that PostgreSQL is started independently of midPoint. When executing the containers in this way, there are two compositions with the following containers:
#
# "midpoint"
#
# 1) midpoint-server
# 2) midpoint-data <-- this is the original MariaDB container; it will execute command of 'true' i.e. exiting just upon the startup
# - midpoint-server
#
# "postgresql"
#
# 1) postgresql
# - postgresql
#

version: "3.3"
Expand All @@ -28,18 +27,11 @@ services:
environment:
- REPO_DATABASE_TYPE=postgresql
- REPO_HOST=postgresql
- REPO_PORT=5432
- REPO_DATABASE=midpoint
- REPO_USER=midpoint
networks:
- postgresql_net

# effectively disable original MariaDB service
midpoint-data:
image: alpine:latest
command: "true"
entrypoint: "true"

networks:
postgresql_net:
external: true
11 changes: 1 addition & 10 deletions demo/postgresql/midpoint-additions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,19 @@
#
# (in ../midpoint directory)
#
# $ docker-compose -f docker-compose.yml -f ../demo/postgresql/midpoint-additions.yml up --build
# $ docker-compose -f docker-compose.yml -f ../demo/postgresql/midpoint-additions.yml up midpoint-server postgresql
#
# It expects that PostgreSQL is started as part of midPoint composition. So there will be three containers there:
#
# 1) midpoint-server
# 2) postgresql
# 3) midpoint-data <-- this is the original MariaDB container; it will execute command of 'true' i.e. exiting just upon the startup
#

version: "3.3"

services:
postgresql:
build: ../demo/postgresql/postgresql/
entrypoint: ["/docker-entrypoint.sh", "postgres"] # for some reasons this is needed for the correct initialization
environment:
- POSTGRES_PASSWORD=password
expose:
Expand All @@ -33,15 +31,8 @@ services:
environment:
- REPO_DATABASE_TYPE=postgresql
- REPO_HOST=postgresql
- REPO_PORT=5432
- REPO_DATABASE=midpoint
- REPO_USER=midpoint

# effectively disable original MariaDB service
midpoint-data:
image: alpine:latest
command: "true"
entrypoint: "true"

volumes:
postgresql_data:
2 changes: 1 addition & 1 deletion midpoint/.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ USERTOKEN=3.9-SNAPSHOT
REPO_DATABASE_TYPE=mariadb
REPO_JDBC_URL=default
REPO_HOST=midpoint-data
REPO_PORT=3306
REPO_PORT=default
REPO_DATABASE=midpoint
REPO_USER=root
REPO_PASSWORD_FILE=/run/secrets/m_database_password.txt
Expand Down
2 changes: 0 additions & 2 deletions midpoint/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ services:

midpoint-server:
build: ./midpoint-server/
depends_on:
- midpoint-data
expose:
- 443
ports:
Expand Down
2 changes: 1 addition & 1 deletion midpoint/midpoint-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ VOLUME ${MP_DIR}/var
# Repository parameters

ENV REPO_HOST midpoint-data
ENV REPO_PORT 3306
ENV REPO_PORT default
ENV REPO_USER root
ENV REPO_DATABASE midpoint
ENV REPO_JDBC_URL default
Expand Down
27 changes: 27 additions & 0 deletions midpoint/midpoint-server/container_files/mp-dir/repository-url
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
#!/bin/bash

function resolvePort() {
if [ $REPO_PORT == "default" ]; then
case $REPO_DATABASE_TYPE in
mariadb)
echo 3306
;;
mysql)
echo 3306
;;
oracle)
echo 1521
;;
postgresql)
echo 5432
;;
sqlserver)
echo 1433
;;
*)
echo "~~~~~ please supply JDBC port for your repository ~~~~~"
esac
else
echo $REPO_PORT
fi
}

if [ $REPO_JDBC_URL == "default" ]; then
REPO_PORT=$( resolvePort )
case $REPO_DATABASE_TYPE in
mariadb)
echo "jdbc:mariadb://$REPO_HOST:$REPO_PORT/$REPO_DATABASE?characterEncoding=utf8"
Expand Down

0 comments on commit 09e3307

Please sign in to comment.