Last active
December 13, 2022 08:39
-
-
Save daniellindau/79d1b6a36041251299278a86f28f637e to your computer and use it in GitHub Desktop.
Run Curity containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
NAME=curity | |
REPO=curity.azurecr.io/curity | |
IMAGE_NAME=idsvr | |
TAG=latest | |
ADMIN_PASSWORD=Password1 | |
ADMIN=true | |
DOCKER_ARGS= | |
DRY_RUN=false | |
function print_usage { | |
echo "Utility to run docker container based on the Curity Identity Server docker hub image. https://hub.docker.com/r/curity/idsvr/ | |
Usage: $(basename $0) <args> | |
Optional parameters: | |
--name, -n Name of container. Default $NAME | |
--tag, -t Tag of curity image. Default $TAG | |
--password, -p Initial admin password. Default $ADMIN_PASSWORD | |
--runtime, -r Start the container as a runtime node. | |
--log-config, -l Use alternate log configuration. Argument must be absolute path. | |
--log-folder, -f Output logs on host machine. Argument must be absolute path. | |
--initial-config-file, -c Instead of installing new container, use this configuration file | |
--daemonize, -d Create daemonized container. Default container will start with --rm -ti | |
--environment, -e Add an environment variable. Ex '-e LOGGING_LEVEL=DEBUG' | |
--plugin Mount a folder as a plugin | |
--dry-run Dont run docker command, just output the result and quit. | |
--help, -h Print this message | |
" | |
} | |
while (( "$#" )); do | |
ARG=${2:-} | |
case "$1" in | |
--name|-n) | |
NAME=$2 | |
shift | |
;; | |
--tag|-t) | |
TAG=$2 | |
shift | |
;; | |
--password|-p) | |
ADMIN_PASSWORD=$2 | |
shift | |
;; | |
--log-config|-l) | |
DOCKER_ARGS="$DOCKER_ARGS -v $2:/opt/idsvr/etc/log4j2.xml" | |
shift | |
;; | |
--log-folder|-f) | |
DOCKER_ARGS="$DOCKER_ARGS -v $2:/opt/idsvr/var/log" | |
shift | |
;; | |
--initial-config-file|-c) | |
INITIAL_CONFIG=$2 | |
shift | |
;; | |
--daemonize|-d) | |
TTY_OPTS="-d" | |
shift | |
;; | |
--environment|-e) | |
DOCKER_ARGS="$DOCKER_ARGS -e $2" | |
shift | |
;; | |
--plugin) | |
absolute_path=$(cd $2 && pwd) | |
dir_name=$(basename $absolute_path) | |
DOCKER_ARGS="$DOCKER_ARGS -v $absolute_path:/opt/idsvr/usr/share/plugins/$dir_name" | |
shift | |
;; | |
--dry-run) | |
DRY_RUN=true | |
;; | |
--runtime|-r) | |
ADMIN=false | |
;; | |
--repo) | |
REPO=$2 | |
shift | |
;; | |
--image-name) | |
IMAGE_NAME=$2 | |
shift | |
;; | |
--rt-port) | |
RUNTIME_PORT=$2 | |
shift | |
;; | |
--help|-h) | |
print_usage | |
exit 1 | |
esac | |
shift | |
done | |
if [ -z $INITIAL_CONFIG ]; then | |
DOCKER_ARGS="$DOCKER_ARGS -e PASSWORD=$ADMIN_PASSWORD" | |
else | |
DOCKER_ARGS="$DOCKER_ARGS -v $INITIAL_CONFIG:/opt/idsvr/etc/init/conf.xml" | |
fi | |
if [ "$ADMIN" = true ]; then | |
FORWARD_ADMIN_PORT="-p 6749:6749" | |
else | |
FORWARD_ADMIN_PORT= | |
fi | |
IMAGE="$REPO/$IMAGE_NAME:$TAG" | |
TTY_OPTS=${TTY_OPTS:="--rm -ti"} | |
DOCKER_ARGS="$TTY_OPTS $DOCKER_ARGS -e ADMIN=$ADMIN --name $NAME -p 4465:4465 -p ${RUNTIME_PORT:=8443}:8443 $FORWARD_ADMIN_PORT $IMAGE" | |
DOCKER_COMMAND="docker run $DOCKER_ARGS" | |
if [ "$DRY_RUN" = true ]; then | |
echo "$DOCKER_COMMAND" | |
exit 0 | |
fi | |
docker pull $IMAGE | |
$DOCKER_COMMAND |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment