diff --git a/README.md b/README.md index aa558e4..9b104dd 100644 --- a/README.md +++ b/README.md @@ -26,11 +26,12 @@ Grouper is an enterprise access management system designed for the highly distri ![logo](https://www.internet2.edu/media/medialibrary/2013/10/15/image_grouper_logowordmark_bw.png) # How to use this image -This image provides support for each of the Grouper components/roles: Grouper Daemon/Loader, Grouper UI, and Grouper Web Services. + +This image provides support for each of the Grouper components/roles: Grouper Daemon/Loader, Grouper UI, Grouper Web Services, and Grouper SCIM Server. ## Starting each role -While TIER recommends/supports using Docker Swarm for orchestrating the Grouper environment, these containers can be run directly. Both examples are shown below. It should be noted that these examples will not run independently, but required additional configuration components to be provided before each container will start as expected. +While TIER recommends/supports using Docker Swarm for orchestrating the Grouper environment, these containers can be run directly (or with other orchestration products). Both examples are shown below. It should be noted that these examples will not run independently, but required additional configuration to be provided before each container will start as expected. ### Daemon/Loader @@ -46,6 +47,20 @@ Run the Grouper Daemon/Loader as a standalone container. $ docker run --detach --name grouper-daemon tier/grouper:latest daemon ``` +### SCIM Server + +Runs the Grouper SCIM Server as a service. + +```console +$ docker service create --detach --publish 9443:443 --name grouper-ws tier/grouper:latest scim +``` + +Runs the Grouper Web Services in a standalone container. + +```console +$ docker run --detach --publish 9443:443 --name grouper-daemon tier/grouper:latest scim +``` + ### UI Runs the Grouper UI as a service. @@ -76,7 +91,7 @@ $ docker run --detach --publish 8443:443 --name grouper-daemon tier/grouper:late ### UI and Web Services -This good when first starting to work with Grouper, but when scaling Grouper UI or Web Services it is advisable to use the individual roles noted above. +> This method is good when first starting to work with Grouper, but when scaling Grouper UI or Web Services it is advisable to use the individual roles noted above. Runs the Grouper UI and Web Services as a combined service. (You should really run these as individual roles to take advantage of Docker service replicas.) @@ -101,10 +116,12 @@ $ docker run -it --rm tier/grouper:latest bin/gsh # Configuration ## Grouper Configurations + There are several things that are required for this image to successfully start. At a minimum, the `grouper.hibernate.properties` and `subject.properties` (or the old `sources.xml` equivalent) files need to be customized and available to the container at start-up. ## Web Apps Configuration -If starting the container to serve the Grouper UI or Grouper Web Services components, a TLS key and cert(s) need to be applied to those containers. + +If starting the container to serve the Grouper UI, Grouper Web Services, Grouper SCIM Server components, a TLS key and cert(s) need to be applied to those containers. The Grouper UI also requires some basic Shibboleth SP configuration. The `/etc/shibboleth/shibboleth2.xml` file should be modified to set: - an entityId for the SP @@ -112,42 +129,43 @@ The Grouper UI also requires some basic Shibboleth SP configuration. The `/etc/s - set the SP's encryption keys - the identity attribute of the subject to be passed to Grouper -If encrpytion keys are defined in the `shibboleth2.xml` file, then the key/cert should be provided as well. The `attribute-map.xml` file has most of the common identity attributes pre-configured, but it (and other Shibbolrth SP files) can be overlaid/replaced as necessary. +If encryption keys are defined in the `shibboleth2.xml` file, then the key/cert files should be provided as well. The `attribute-map.xml` file has most of the common identity attributes pre-configured, but it (and other Shibboleth SP files) can be overlaid/replaced as necessary. ## General Configuration Mechanism -There are three primary ways to provide the Grouper and additional configuration to the container: Docker Config/Secrets, customized images, and bind mounts. Depending upon your needs you may use a combination of two or three of these options. + +There are three primary ways to provide Grouper and additional configuration files to the container: Docker Config/Secrets, customized images, and bind mounts. Depending upon your needs you may use a combination of two or three of these options. ### Secrets/Configs -Docker Config and Docker Secrets is Docker's way of providing configurations files to a container. The primary difference between the Config and Secrets functionality is that Secrets is designed to protect resrouces that sensitive files. +Docker Config and Docker Secrets are Docker's way of providing configurations files to a container at runtime. The primary difference between the Config and Secrets functionality is that Secrets is designed to protect resources/files that are sensitive. -This image will make any secrets (containing a period in the secret name) available to the appropriate Grouper component's conf directory (i.e. `/conf` or `WEB-INF/classes`). These file will supercede any in the underlying image. +This container will make any secrets with secret names prepended with `grouper_` available to the appropriate Grouper component's conf directory (i.e. `/conf` or `WEB-INF/classes`). Any secrets with secret names starting with `shib_` will be available in the Shibboleth SP `/etc/shibboleth/` directory. Any secrets with secret names starting with `httpd_` will be available to `/etc/httpd/conf.d` directory. Finally, if a secret with the name of `host-key.pem` will be mapped to the httpd TLS cert used by Grouper UI, Grouper WS, and Grouper SCIM Server containers. These files will supercede any found in the underlying image. -Secrets can be managed using the `docker secret` command: `docker secret create grouper.hibernate.properties ./grouper.hibernate.properties`. This will securely store the file in the swarm. Secrets can then be assigned to the service `docker service create -d --name daemon --secret grouper.hibernate.properties --secret sources.xml tier/grouper daemon`. +Secrets can be managed using the `docker secret` command: `docker secret create grouper_grouper.hibernate.properties ./grouper.hibernate.properties`. This will securely store the file in the swarm. Secrets can then be assigned to the service `docker service create -d --name daemon --secret grouper_grouper.hibernate.properties --secret grouper_sources.xml tier/grouper daemon`. > `docker run` does not support secrets; Bind mounts need to be used instead. ### Bind Mounts -Bind mounts can be used to connect files on the Docker host into the container. When not running in swarm mode, the secrets are supported, so we can use a bind mount to provide the container with the configuration files. +Bind mounts can be used to connect files/folders on the Docker host into the container's file system. Unless running in swarm mode, the secrets are not supported, so we can use a bind mount to provide the container with the configuration files. ``` docker run --detach --name daemon \ - --mount type=bind,src=$(pwd)/grouper.hibernate.properties,dst=/run/secrets/grouper.hibernate.properties \ - --mount type=bind,src=$(pwd)/sources.xml,dst=/run/secrets/sources.xml \ + --mount type=bind,src=$(pwd)/grouper.hibernate.properties,dst=/run/secrets/grouper_grouper.hibernate.properties \ + --mount type=bind,src=$(pwd)/sources.xml,dst=/run/secrets/grouper_sources.xml \ tier/grouper daemon ``` ### Customized Images -Deployers will undoubtedly want to add in their files to the container; things like addtional jar files defining Grouper Hooks, or things like own images, css files, anything. This can be accomplished by building custom images. **Deployers should NOT use this method to store sensitive configuration files.** +Deployers will undoubtedly want to add in their files to the container. Things like additional jar files defining Grouper Hooks, or things like images and css files. This can be accomplished by building custom images. **Deployers should NOT use this method to store sensitive configuration files.** To add a favicon to the Grouper UI, we use the tier/grouper images as a base and `COPY` our local `favicon.ico` into the image. While we are at it, we define this image as a UI image by specifying the default commnd (i.e `CMD`) of `ui`. ```Dockerfile FROM tier/grouper:latest -COPY favicon.ico /opt/grouper/grouper.ui/dist/grouper/ +COPY favicon.ico /opt/grouper/grouper.ui/ CMD ui ``` @@ -161,33 +179,52 @@ docker build --tag=org/grouper-ui . This image can now be used locally or pushed to an organization's Docker repository. -## Memory Limits -(TODO) +## Environment Variables + +Deployers can set runtime variables to both the Grouper Shell and Loader/Daemon and to Tomcat/Tomcat EE using environment variables. These can be set using the `docker run` and `docker service creates`'s `--env` paramater. + +### Grouper Shell/Loader + +The following environment variables are used by the Grouper Shell/Loader: +- MEM_START: corresponds to the java's `-Xms`. +- MEM_MAX: corresponds to java's `-Xmx`. + +### Tomcat/TomEE +Amongst others variables defined in the `catalina.sh`, the following variables would like be useful for deployers: +- CATALINA_OPTS: Java runtime options to only be used by Tomcat itself. # File System Endpoints -Significant directories and files that deployers should be aware of. + +Here is a list of significant directories and files that deployers should be aware of. - `/opt/grouper/conf/`: a common directory to place non-sensitive config files that will be placed into the appropriate location for each Grouper component at container start-up. - `/opt/grouper/lib/`: a common directory to place additional jar files that will be placed into the appropriate location for each Grouper component at container start-up. - +- `/opt/grouper/grouper.apiBinary/`: location to overlay Grouper GSH or Daemon/Loader files. +`/opt/grouper/grouper.scim/`: location for overlaying Grouper SCIM Server web application files (expanded `grouper-ws-scim.war`). +- `/opt/grouper/grouper.ui/`: location for overlaying Grouper UI web application files (expanded `grouper.war`). +- `/opt/grouper/grouper.ws/`: location for overlaying Grouper Web Services web application files (expanded `grouper-ws.war`). - `/etc/httpd/conf.d/ssl-enabled.conf`: Can be overlaid to change the TLS settings when running Grouper UI or Web Servicse. - `/etc/shibboleth/`: location to overlay the Shibboleth SP configuration files used by the image. -- `/opt/grouper/grouper.apiBinary/`: location to overlay Grouper GSH or Daemon/Loader files. -- `/opt/grouper/grouper.ui/dist/grouper/`: location to overlay Grouper UI web application files. -- `/opt/grouper/grouper.ws/dist/grouper-ws/`: location to overlay Grouper Web Services web application files. +- `/opt/tomcat/`: used to run Grouper UI and Grouper WS +- `/opt/tomee/`: used to run the Grouper SCIM Server. +- `/var/run/`: location where Docker Secrets are mounted into the container. Secrets starting with `grouper_`, `shib_`, and `httpd_` have special meaning. See `Secrets/Configs` above. -To examine baseline image files, one might run `docker run --name=temp -it tier/grouper bash` and browse through these endpoints. While the container is running one may copy files out of the image/container using something like `docker cp temp:/opt/grouper/grouper.api/conf/grouper.properties .`, which will copy the `grouper.properties` to the host's present working directory. These files can then be edited and applied via the mechanisms outlined above. +To examine baseline image files, one might run `docker run --name=temp -it tier/grouper bash` and browse through these file system endpoints. While the container is running one may copy files out of the image/container using something like `docker cp containerId:/opt/grouper/grouper.api/conf/grouper.properties .`, which will copy the `grouper.properties` to the Docker client's present working directory. These files can then be edited and applied via the mechanisms outlined above. # Provisioning a Grouper Database -(TODO) + +Using standard methods, create a MariaDb Server and an empty Grouper database. Create a database user with privileges to create and populate schema objects. Set the appropriate database connection properties in `grouper.hibernate.properties`. Be sure to the user created with schema manipulation privileges as the db user. + +Next populate the database by using the following command. ``` -docker run --rm \ - --mount type=bind,src=$(pwd)/grouper.hibernate.properties,dst=/run/secrets/grouper.hibernate.properties \ +docker run -it --rm \ + --mount type=bind,src=$(pwd)/grouper.hibernate.properties,dst=/run/secrets/grouper_grouper.hibernate.properties \ tier/grouper gsh -registry -check -runscript -noprompt ``` +Note: a less privileged database user maybe used when running the typical Grouper roles. This user need SELECT, INSERT, UPDATE, and DELETE privileges on the schema objects. # License diff --git a/container_files/usr-local-bin/library.sh b/container_files/usr-local-bin/library.sh index fafc6e2..d8b1dd9 100644 --- a/container_files/usr-local-bin/library.sh +++ b/container_files/usr-local-bin/library.sh @@ -29,8 +29,8 @@ prepDaemon() { fi } -prepUI() { - local dest=/opt/grouper/grouper.ui/WEB-INF +prepSCIM() { + local dest=/opt/grouper/grouper.scim/WEB-INF linkGrouperSecrets $dest/classes if [ -d "/opt/grouper/conf" ]; then @@ -40,11 +40,11 @@ prepUI() { cp /opt/grouper/lib/* $dest/lib/ fi - cp /opt/tier-support/grouper.xml /opt/tomcat/conf/Catalina/localhost/ + cp /opt/tier-support/grouper-ws-scim.xml /opt/tomee/conf/Catalina/localhost/ } -prepSCIM() { - local dest=/opt/grouper/grouper.scim/WEB-INF +prepUI() { + local dest=/opt/grouper/grouper.ui/WEB-INF linkGrouperSecrets $dest/classes if [ -d "/opt/grouper/conf" ]; then @@ -54,7 +54,7 @@ prepSCIM() { cp /opt/grouper/lib/* $dest/lib/ fi - cp /opt/tier-support/grouper-ws-scim.xml /opt/tomee/conf/Catalina/localhost/ + cp /opt/tier-support/grouper.xml /opt/tomcat/conf/Catalina/localhost/ } prepWS() {