diff --git a/image-opensim/config/config-standalone-sql/docker-compose-external-config.yml b/image-opensim/config/config-standalone-sql/docker-compose-external-config.yml new file mode 100644 index 0000000..62b1d12 --- /dev/null +++ b/image-opensim/config/config-standalone-sql/docker-compose-external-config.yml @@ -0,0 +1,45 @@ + +version: '3' + +services: + + dbservice: + # MySql version 8 requires a bunch of new security stuff. Stay with v5. + # image: mysql:5 + image: mariadb:latest + environment: + MYSQL_ROOT_PASSWORD: + # Parameters added to invocation. + # Default is to flush after every operation which slows Docker image down. + # This flushes log once a second. + command: --innodb_flush_log_at_trx_commit=2 --sync_binlog=0 + volumes: + # NOTE: you must create this directory before starting the simulator + # This mysql data directory can be placed anywhere + - ~/opensim-sql-data:/var/lib/mysql + # restart: always + + opensim: + depends_on: + - dbservice + image: opensim-opensim + + environment: + CONFIG_NAME: + CONFIGKEY: + EXTERNAL_HOSTNAME: + + volumes: + - ./config:/home/opensim/opensim/bin/config + + ports: + - 8002:8002/tcp + - 8002:8002/udp + - 9000:9000/tcp + - 9000:9000/udp + - 9010:9010/tcp + - 9010:9010/udp + links: + - dbservice:dbservice + + # restart: always diff --git a/image-opensim/config/config-standalone-sql/docker-compose.yml b/image-opensim/config/config-standalone-sql/docker-compose.yml index 62b1d12..80a18b9 100644 --- a/image-opensim/config/config-standalone-sql/docker-compose.yml +++ b/image-opensim/config/config-standalone-sql/docker-compose.yml @@ -29,8 +29,9 @@ services: CONFIGKEY: EXTERNAL_HOSTNAME: - volumes: - - ./config:/home/opensim/opensim/bin/config + # If the configuration is outside the container. + # volumes: + # - ./config:/home/opensim/opensim/bin/config ports: - 8002:8002/tcp diff --git a/image-opensim/config/config-standalone/docker-compose-external-config.yml b/image-opensim/config/config-standalone/docker-compose-external-config.yml new file mode 100644 index 0000000..211c79e --- /dev/null +++ b/image-opensim/config/config-standalone/docker-compose-external-config.yml @@ -0,0 +1,24 @@ +version: '3' + +services: + opensim: + + image: opensim-opensim + + environment: + - CONFIGKEY + - CONFIG_NAME + - EXTERNAL_HOSTNAME + + volumes: + - ./config:/home/opensim/opensim/bin/config + + ports: + - 8002:8002/tcp + - 8002:8002/udp + - 9000:9000/tcp + - 9000:9000/udp + - 9010:9010/tcp + - 9010:9010/udp + + # restart: always diff --git a/image-opensim/config/config-standalone/docker-compose.yml b/image-opensim/config/config-standalone/docker-compose.yml index 211c79e..b53b46b 100644 --- a/image-opensim/config/config-standalone/docker-compose.yml +++ b/image-opensim/config/config-standalone/docker-compose.yml @@ -10,8 +10,9 @@ services: - CONFIG_NAME - EXTERNAL_HOSTNAME - volumes: - - ./config:/home/opensim/opensim/bin/config + # If the configuration is outside of the container + # volumes: + # - ./config:/home/opensim/opensim/bin/config ports: - 8002:8002/tcp diff --git a/image-opensim/config/scripts/initializeDb.sh b/image-opensim/config/scripts/initializeDb.sh index 8ebdb7e..18b8d64 100755 --- a/image-opensim/config/scripts/initializeDb.sh +++ b/image-opensim/config/scripts/initializeDb.sh @@ -23,7 +23,7 @@ if [[ ! -z "$MYSQL_ROOT_PASSWORD" ]] ; then done SQLCMDS=/tmp/mymy$$ - SQLOPTIONS=tmp/mymyoptions$$ + SQLOPTIONS=/tmp/mymyoptions$$ rm -f "$SQLCMDS" rm -f "$SQLOPTIONS" diff --git a/image-opensim/config/scripts/updateConfigFiles.sh b/image-opensim/config/scripts/updateConfigFiles.sh index 39802d6..8c27384 100755 --- a/image-opensim/config/scripts/updateConfigFiles.sh +++ b/image-opensim/config/scripts/updateConfigFiles.sh @@ -7,7 +7,7 @@ OPENSIMBIN=${OPENSIMBIN:-/home/opensim/opensim/bin} # For this image, CONFIG_NAME is the configuration being used CONFIG_NAME=${CONFIG_NAME:-standalone} -CONFIGDIR=${OPENSIMBIN}/config/${CONFIG_NAME} +CONFIGDIR=${OPENSIMBIN}/config/config-${CONFIG_NAME} cd "$CONFIGDIR" source ../scripts/setEnvironment.sh diff --git a/image-opensim/run-opensim.sh b/image-opensim/run-opensim.sh index ed37493..2f38887 100755 --- a/image-opensim/run-opensim.sh +++ b/image-opensim/run-opensim.sh @@ -10,6 +10,13 @@ # CONFIG_NAME=nameOfRunConfiguration (default 'standalone' of not supplied) # EXTERNAL_HOSTNAME=IPorDNSnameForSimulator +# If this environment variable is defined, the configuration files are updated with +# configuration values in the container (at container runtime). Otherwise, the +# configuration files are updated with values external to the container (in the +# filesystem of the invoker and the internal directory 'bin/config/ is mounted +# as the local 'config' directory. +# export OS_DOCKER_CONTAINER_CONFIG="yes" + BASE=$(pwd) if [[ -z "$EXTERNAL_HOSTNAME" ]] ; then @@ -25,14 +32,23 @@ export CONFIG_NAME=${CONFIG_NAME:-standalone} # This export fakes out the environment setup script to look for files in # build environment rather than in run environment. export OPENSIMBIN=$BASE -source config/scripts/setEnvironment.sh -unset OPENSIMBIN + +# if configuration files are external to the container, run the configuration +if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then + echo "opensim-docker: running configuration file initialization" + config/scripts/updateConfigFiles.sh +else + echo "opensim-docker: delaying configuration file initialization to configuration start" + # Just set the configuration variables into the environment + source config/scripts/setEnvironment.sh +fi # Use the generic docker-compose file or the one specific to the configuration if it exists cd "$BASE" -COMPOSEFILE=./docker-compose.yml -if [[ -e "config/config-${CONFIG_NAME}/docker-compose.yml" ]] ; then - COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose.yml" +COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose.yml" +if [[ -z "$OS_DOCKER_CONTAINER_CONFIG" ]] ; then + # if using external configuration, include docker-compose with the mount + COMPOSEFILE="config/config-${CONFIG_NAME}/docker-compose-external-config.yml" fi # Local directory for storage of sql persistant data (so region