# Building the docker image

## Dockerfile

The Dockerfile can be found in the root folder of the project.

## Available Environment Variables


| property name                          | description                                                                                                                                                                       | values                                                                   |
|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| DB_TYPE                                | type of the db enginge.                                                                                                                                                           | mysql, h2                                                                |
| DB_URL                                 | jdbc url of the db                                                                                                                                                                | "jdbc:mysql://ucs-intranet-db-author:3306/magnolia"                      |
| DB_USER                                | username for the db                                                                                                                                                               | root                                                                     |
| DB_PASSWORD                            | password for the db                                                                                                                                                               | root                                                                     |
| CATALINA_OPTS_APPEND                   | Java options form tomcat                                                                                                                                                          | "-Xms512M -Xmx2048M "                                                    | 
| JAVA_OPTS                              | addition java options for application                                                                                                                                             | "-agentlib:jdwp=transport=dt_socket,address=*:54455,server=y,suspend=n"  |
| MAGNOLIA_UPDATE_AUTO                   | set the property 'magnolia.update.auto' in magnolia.properties                                                                                                                    | ${MAGNOLIA_UPDATE_AUTO}                                                  |
| MAGNOLIA_AUTHORINSTANCE_URL            | public accessible url of the author instance                                                                                                                                      | http://author.ucsintranet.at                                             |
| MAGNOLIA_UCSWEBSITE_AUTHORINSTANCE_URL | public accessible url of the author instance of the UCS website                                                                                                                   | http://author.ucsintranet.at                                             |
| MAGNOLIA_PUBLICINSTANCE_URL            | public accessible url of the public instance                                                                                                                                      | http://public.ucsintranet.at                                             |
| MAGNOLIA_PROFILE                       | the magnolia profile to use   (see: https://docs.magnolia-cms.com/product-docs/6.2/releases/release-notes-for-magnolia-cms-6.2.2/#_profile_based_configuration_of_property_files) | magnoliaAuthor, magnoliaPublic                                           |
| KEYCLOAK_REALM                         | the keycloak realm to use                                                                                                                                                         | magnolia                                                                 |
| KEYCLOAK_CLIENT_ID_AUTHOR              | the author keycloak client id                                                                                                                                                     | author.ucsintranet                                                       |
| KEYCLOAK_CLIENT_ID_PUBLIC              | the author keycloak client id                                                                                                                                                     | author.ucsintranet                                                       |
| KEYCLOAK_AUTH_URL                      | <TBD>                                                                                                                                                                             | ${KEYCLOAK_AUTH_URL}                                                     |
| KEYCLOAK_SSL_REQUIRED                  | <TBD>                                                                                                                                                                             | external                                                                 |
| KEYCLOAK_CREDENTIALS_SECRET_AUTHOR     | author keycloak secret                                                                                                                                                            |                                                                          |
| KEYCLOAK_CREDENTIALS_SECRET_PUBLIC     | public keycloak secret                                                                                                                                                            |                                                                          |

## About the image

The image is based on the cli provided by magnolia ( a.k.a mgnl).
To get more information about the mgnl cli tool, please visit the [mgnl documentation](https://docs.magnolia-cms.com/magnolia-cli/4.x/)

The project generated by the mgnl tool, already includes the author and public instances!
Be sure, that in production you restrict the access to the author instance, and to the admin components

The image is set up so, that it uses the folder "/magnolia/light-modules" as resources dir.
While build the image, the <PROJECT_ROOT>/magnolia/modules will be copied in to the image as "/magnolia/light-modules".
For development, the <PROJECT_ROOT>/magnolia/modules can be mounted, so the changes in the lightmodules are "live/instant"

## Building & pushing the image

The easiest way to build and pusht the image is, to run the next commands
```bash
   npm run docker:build
```

```bash
   npm run docker:push
```

For more details, pls examine the package.json file, and the scripts in docker/magnolia/scripts folder
