diff --git a/open-metadata-resources/open-metadata-deployment/docker/egeria/Dockerfile.selfbuild b/open-metadata-resources/open-metadata-deployment/docker/egeria/Dockerfile.selfbuild new file mode 100644 index 00000000000..aa2304fb4a2 --- /dev/null +++ b/open-metadata-resources/open-metadata-deployment/docker/egeria/Dockerfile.selfbuild @@ -0,0 +1,113 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright Contributors to the Egeria project. + +# Usage: docker run -d -p 9443:9443 odpi/egeria +# +# All dynamic data is stored under /deployments/data, so map a volume or k8s pvc to this +# to persist egeria configuration, local graph repo etc ie +# docker run -v source=egeria-data,target=/deployments/data odpi/egeria:latest +# +# See readme in source tree or on docker hub for more info + +# This is a self-build variation of the standard egeria Dockerfile - it will +# build egeria within the container, and then configure it for subsequent execution + +# Based on RedHat UBI image. +# https://catalog.redhat.com/software/containers/ubi9/openjdk-17-runtime/61ee7d45384a3eb331996bee + + +# NOTE: Build args differ from the standard Dockerfile, as we need to get the right code to build from github + +ARG buildimg=registry.access.redhat.com/ubi9/openjdk-17 +ARG runimg=registry.access.redhat.com/ubi9/openjdk-17 + + + +FROM $buildimg as build + +# Defaults to 'main' but could be 'egeria-release-4.0' or a commit id like '969fde1042fc4fda70961f979c4634159466e081' +ARG srcref=main +# Defaults to egeria repo - but could be a different fork if needed +ARG srcurl=https://github.com/odpi/egeria +# this should not be needed, and must match the source, but we'll use for now +ARG version=4.1-SNAPSHOT +# Replace build parms if needed +ARG buildparms="build -x test -x javadoc --no-build-cache" +# Can optionally specify build time so that we tag the image appropriately +ARG now="" + +ENV version ${version} +ENV srcurl ${srcurl} +ENV srcref ${srcref} +ENV now ${now} + +# We need to install git -- and will continue the build as root - since this isn't runtime + +USER root +RUN microdnf install -y git + +# Building egeria is simple - clone & run the gradle wrapper. Then we can copy the files over + +RUN cd /root && git clone $srcurl egeria -b $srcref && cd egeria && ./gradlew $buildparms + +# This can be switched to the runtime image for a smaller footprint image +# However the JDK debugging tools will be lost, which are helpful in monitoring & undersanding performance/resource issues +#FROM registry.access.redhat.com/ubi9/openjdk-17-runtime + +FROM $runimg + +# Defaults to 'main' but could be 'egeria-release-4.0' or a commit id like '969fde1042fc4fda70961f979c4634159466e081' +ARG srcref=main +# Defaults to egeria repo - but could be a different fork if needed +ARG srcurl=https://github.com/odpi/egeria +# this should not be needed, and must match the source, but we'll use for now +ARG version=4.1-SNAPSHOT +# Replace build parms if needed +ARG buildparms="build -x test -x javadoc" +# Can optionally specify build time so that we tag the image appropriately +ARG now="" + +ENV version ${version} +ENV srcurl ${srcurl} +ENV srcref ${srcref} +ENV now ${now} + +# Labels from https://github.com/opencontainers/image-spec/blob/master/annotations.md#pre-defined-annotation-keys (with additions prefixed ext) +# Dates & commit refs are incomplete and only approximate if set/in terms of tags +LABEL org.opencontainers.image.vendor = "LF AI&Data" \ + org.opencontainers.image.title = "Egeria" \ + org.opencontainers.image.description = "Common image for core ODPi Egeria runtime. Based on RedHat UBI 8 openjdk-17 image" \ + org.opencontainers.image.url = "https://egeria-project/org/" \ + org.opencontainers.image.source = "$srcurl" \ + org.opencontainers.image.authors = "Egeria" \ + org.opencontainers.image.revision = "$srcref" \ + org.opencontainers.image.licenses = "Apache-2.0" \ + org.opencontainers.image.created = "$now" \ + org.opencontainers.image.version = "$srcref" \ + org.opencontainers.image.documentation = "https://egeria-project.org" \ + org.opencontainers.image.ext.docker.cmd = "docker run -d -p 9443:9443 odpi/egeria" \ + org.opencontainers.image.ext.docker.cmd.devel = "docker run -d -p 9443:9443 -p 5005:5005 -e JAVA_DEBUG=true odpi/egeria" \ + org.opencontainers.image.ext.docker.debug = "docker exec -it $CONTAINER /bin/sh" \ + org.opencontainers.image.ext.docker.params = "JAVA_DEBUG=set to true to enable JVM debugging" + +# Copy egeria distribution +COPY --from=build /root/egeria/open-metadata-distribution/open-metadata-assemblies/build/unpacked/egeria-$version-distribution.tar.gz /deployments + +# Expose port 8080 (default) for client access, and allow for 5005 being used for remote java debug +EXPOSE 9443 5005 + +# By default, we run the server chassis +ENV JAVA_APP_JAR=server/server-chassis-spring-${version}.jar + +# This is used with regular class loader, ie any client code etc +# ENV JAVA_LIBDIR=/deployments/lib + +# This is used when running a spring app such as the server chassis (default) +# Extend this accordingly via the environment, or within a new Dockerfile as needed +ENV LOADER_PATH=/deployments/server/lib + +# Joloka will be removed shortly. For now disable to avoid errors +ENV AB_JOLOKIA_OFF=true + +# See issue 3740 - we leave the metaspace size as unlimited - jvm default +ENV JAVA_OPTS_APPEND="-XX:MaxMetaspaceSize=1g" diff --git a/open-metadata-resources/open-metadata-deployment/docker/egeria/README.md b/open-metadata-resources/open-metadata-deployment/docker/egeria/README.md index 40241ff470a..ee1dc6ccaf8 100644 --- a/open-metadata-resources/open-metadata-deployment/docker/egeria/README.md +++ b/open-metadata-resources/open-metadata-deployment/docker/egeria/README.md @@ -17,15 +17,55 @@ value from data whilst ensuring it is properly governed. * [Github](https://github.com/odpi/egeria) * [Slack discussions](https://slack.lfai.foundation) -## Image: egeria +## About the egeria image This *nix based image contains all the required runtime artifacts for egeria - for example the main server chassis, the user interface, required dependencies etc. Specifically it contains the full [egeria assembly](https://github.com/odpi/egeria/blob/main/open-metadata-distribution/open-metadata-assemblies/src/main/assemblies/egeria-omag.xml) -## Usage +## Building the egeria image -It's recommended you use the Egeria tutorials to get started. Below are some examples of using the image standalone. Refer to the main Egeria docs for further information +This step is optional - and only required if you want to build your own image. + +There are two options + +### Standard dockerfile + +This is the Dockerfile we use to publish the official images. It works by utilizing an existing unpacked egeria assembly, which is an output of a full egeria build. + +To use this + * Run a full egeria build with `./gradlew build` from the project root + * Run `mkdir -p open-metadata-resources/open-metadata-deployment/docker/egeria/build/assembly && cp -r open-metadata-distribution/open-metadata-assemblies/build/unpacked/egeria-4.1-SNAPSHOT-distribution.tar.gz/. open-metadata-resources/open-metadata-deployment/docker/egeria/build/assembly` - replacing the version label as appropriate + * Run `docker build -t egeria:myversion -f Dockerfile .` in this directory to create the image + + +### Self-build dockerfile + +This dockerfile will also build egeria itself - so no seperate steps are needed. Simply run the dockerfile directly and it will extract egeria source & build it within the container. + +Run `docker build -t egeria:myversion -f Dockerfile.selfbuild .` + +### Build arguments + +The following additional arguments are allowed + + +|parameter| regular | selfbuild | default | description | +|--|---------|--|--|--| +| runimg | No | Yes | registry.access.redhat.com/ubi9/openjdk-17 | Container image used for building egeria | +| buildimg | No |Yes | registry.access.redhat.com/ubi9/openjdk-17 | Container image used for runtime ie launching egeria | +| version | Yes | Yes | 4.1-SNAPSHOT | Version string - must be correct so that the right jar file gets launched. Do not rely on default | +| srcurl | No | Yes | https://github.com/odpi/egeria | Specifies url of github repo to clone | +| srcref | No | Yes | main | Specifies branch, or tag of code within the repo +| buildparms | No | Yes | build -x test -x javadoc | Gradle invocation to build egeria | +| now | No | Yes | | timestamp - purely used as additional metadata to describe the image | + + +## Running the egeria image + +It's recommended you use the Egeria tutorials to get started. Below are some examples of using the image standalone. Refer to the main Egeria docs for further information. + +These instructions should work whether you built your own image, or used the image directly from quay.io or docker.io - _though you will need to use the correct tag in the commands below_ (odpi/egeria:latest will default to the latest egeria release on Docker Hub) ### Launch a container running the latest version of egeria in the background (version 2.0 and above) @@ -146,6 +186,16 @@ $ docker inspect --format='{{range $k, $v := .ContainerConfig.Labels}} {{- print org.opencontainers.image.vendor = "= ODPi org.opencontainers.image.title = Egeria org.opencontainers.image.description = Common image for core ODPi Egeria runtime. org.opencontainers.image.url = https://egeria.odpi.org/ org.opencontainers.image.source = https://github.com/odpi/egeria org.opencontainers.image.authors = ODPi Egeria org.opencontainers.image.revision = 2e8b97d org.opencontainers.image.licenses = Apache-2.0 org.opencontainers.image.created = 2020-03-25T12:03:52+0000 org.opencontainers.image.version = 1.6-SNAPSHOT org.opencontainers.image.documentation = https://egeria.odpi.org/open-metadata-resources/open-metadata-deployment/docker/egeria/ org.opencontainers.image.ext.vcs-date = 2020-03-25T11:46:50+0000 org.opencontainers.image.ext.docker.cmd = docker run -d -p 8080:8080 odpi/egeria org.opencontainers.image.ext.docker.cmd.devel = docker run -d -p 8080:8080 -p 5005:5005 -e JAVA_DEBUG=true odpi/egeria org.opencontainers.image.ext.docker.debug = docker exec -it /bin/sh org.opencontainers.image.ext.docker.params = JAVA_DEBUG=set to true to enable JVM debugging" ``` +### Runtime parameters + +Additional parameters can be specified at runtime by setting in the environment ie `-e VAR=VALUE` + +| Variable | Default | Description | +| -- |-------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------| +| JAVA_OPTS | | Passes only these options to the java command used to launch egeria | +| JAVA_OPTS_APPEND | -XX:MaxMetaspaceSize=1g | Similar to JAVA_OPTS but appends to any options already set in image | +| JAVA_APP_JAR | server/server-chassis-spring-${version}.jar | Launches a different jar file -- use with caution as this must exist in the egeria assembly | +| LOADER_PATH | /deployments/server/lib | Specifies a comma seperated list of directories to load additional libraries from ie adding to CLASSPATH used by spring classloader | ### Extending the image to include additional libraries, such as connectors