Skip to content

Commit

Permalink
Add demonstration of a Docker secret use
Browse files Browse the repository at this point in the history
Docker secret is used to pass a repository (MariaDB) password to midPoint.
  • Loading branch information
mederly committed Aug 9, 2018
1 parent 3bc3fb2 commit f68ee23
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
51 changes: 51 additions & 0 deletions mariadb-secret/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# Just a demonstration of how to flexibly use MariaDB running in a separate container, receiving password as a Docker secret.
# It requires v3.9devel-274-g1b9943e or later.
#
# Features:
# - see docker-compose.yml
#
# Limitations (will be resolved):
# - mariadb uses default database of 'registry' and default user of 'root'
# - JDBC password is present exclusively as a Docker secret: it would be better to have it switchable between secret and a plaintext value
# (probably requiring more elaborate working with -D... switches)
#
# Building: (assumes midpoint-3.9-SNAPSHOT-dist.tar.gz is present in the current directory)
#
# (build tier/shib-sp-java beforehand)
# docker build -t midpoint .
# docker stack deploy -c docker-compose.yml mp
#

FROM tier/shib-sp-java

MAINTAINER info@evolveum.com

ARG MP_VERSION=3.9-SNAPSHOT
ARG MP_DIST_FILE=midpoint-${MP_VERSION}-dist.tar.gz

ENV MP_DIR /opt/midpoint
ENV REPO_HOST mariadb
ENV REPO_PORT 3306
ENV REPO_USER root
ENV REPO_PASSWORD_FILE /run/secrets/repo-password

RUN mkdir -p ${MP_DIR}/var

COPY ${MP_DIST_FILE} ${MP_DIR}

RUN echo 'Extracting midPoint archive...' \
&& tar xzf ${MP_DIR}/midpoint-${MP_VERSION}-dist.tar.gz -C ${MP_DIR} --strip-components=1

VOLUME ${MP_DIR}/var

CMD java -Xmx2048M -Xms2048M -Dfile.encoding=UTF8 \
-Dmidpoint.home=$MP_DIR/var \
-Dmidpoint.repository.database=mariadb \
-Dmidpoint.repository.jdbcUsername=$REPO_USER \
-Dmidpoint.repository.jdbcPasswordFile=$REPO_PASSWORD_FILE \
-Dmidpoint.repository.jdbcUrl=jdbc:mariadb://$REPO_HOST:$REPO_PORT/registry?characterEncoding=utf8 \
-Dmidpoint.repository.hibernateHbm2ddl=none \
-Dmidpoint.repository.missingSchemaAction=create \
-Dmidpoint.repository.initializationFailTimeout=60000 \
-jar $MP_DIR/lib/midpoint.war
64 changes: 64 additions & 0 deletions mariadb-secret/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#
# Composition of midPoint and TIER MariaDB containers.
#
# MariaDB serves as a repository for midPoint.
#
# Features:
# - a separate volume for repository data (MySQL database directory), so it persists between creation/removal cycle of this stack
# - a separate volume for midPoint home directory, containing config.xml, logs, generated encryption keys, and so on
# - MariaDB password is presented to midPoint as a Docker secret
#

version: "3.1"
services:

mariadb:
image: tier/mariadb:mariadb10
deploy:
restart_policy:
condition: none
volumes:
- repo-db-data:/var/lib/mysqlmounted
networks:
- webnet
secrets:
- repo-password

mariadbadminer:
image: adminer
deploy:
restart_policy:
condition: none
depends_on:
- mariadb
ports:
- 18080:8080
networks:
- webnet

midpoint:
image: midpoint
deploy:
restart_policy:
condition: none
depends_on:
- mariadb
ports:
- 8080:8080
volumes:
- midpoint-home:/opt/midpoint/var # change this if MP_DIR changes
networks:
- webnet
secrets:
- repo-password

networks:
webnet:

volumes:
repo-db-data:
midpoint-home:

secrets:
repo-password:
file: repo-password.txt
1 change: 1 addition & 0 deletions mariadb-secret/repo-password.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
123321
27 changes: 27 additions & 0 deletions shib-sp-java/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# An image that derives from shib-sp and contains a Java implementation.
#
# PRELIMINARY VERSION
#
# TODO:
# - provide TIER-approved Java here
#

FROM tier/shib-sp

ARG maintainer=tier
ARG imagename=siteadmin-sp
ARG version=1.0

MAINTAINER $maintainer
LABEL Vendor="Internet2"
LABEL ImageType="SP"
LABEL ImageName=$imagename
LABEL ImageOS=centos7
LABEL Version=$version

LABEL Build docker build --rm --tag $maintainer/$imagename .

# TODO switch to other appropriate Java implementation

RUN yum -y install java-1.8.0-openjdk

0 comments on commit f68ee23

Please sign in to comment.