content: FROM registry.access.redhat.com/ubi9/openjdk-21-runtime
  
  # Add git commit label must be specified at build time using --build-arg GIT_COMMIT=dadadadadad
  ARG GIT_COMMIT=unknown
  
  LABEL git-commit=$GIT_COMMIT
  
  USER root
  ENV JAVA_TOOL_OPTIONS ${JAVA_TOOL_OPTIONS}
  
  ENV TZ ${TZ:-Europe/Amsterdam}
  ENV OR_ADMIN_PASSWORD ${OR_ADMIN_PASSWORD:-secret}
  ENV OR_SETUP_TYPE ${OR_SETUP_TYPE}
  ENV OR_SSL_PORT ${OR_SSL_PORT:--1}
  ENV OR_HOSTNAME ${OR_HOSTNAME:-localhost}
  ENV OR_EMAIL_HOST ${OR_EMAIL_HOST}
  ENV OR_EMAIL_USER ${OR_EMAIL_USER}
  ENV OR_EMAIL_PASSWORD ${OR_EMAIL_PASSWORD}
  ENV OR_EMAIL_PORT ${OR_EMAIL_PORT:-587}
  ENV OR_EMAIL_TLS ${OR_EMAIL_TLS:-true}
  ENV OR_EMAIL_PROTOCOL ${OR_EMAIL_PROTOCOL:-smtp}
  ENV OR_EMAIL_FROM ${OR_EMAIL_FROM}
  ENV OR_EMAIL_ADMIN ${OR_EMAIL_ADMIN}
  ENV OR_EMAIL_X_HEADERS ${OR_EMAIL_X_HEADERS}
  ENV OR_FIREBASE_CONFIG_FILE ${OR_FIREBASE_CONFIG_FILE:-/deployment/manager/fcm.json}
  ENV OR_DEV_MODE ${OR_DEV_MODE:-false}
  ENV OR_SETUP_RUN_ON_RESTART ${OR_SETUP_RUN_ON_RESTART:-false}
  ENV OR_WEBSERVER_LISTEN_HOST ${OR_WEBSERVER_LISTEN_HOST:-0.0.0.0}
  ENV OR_DB_VENDOR ${OR_DB_VENDOR:-postgres}
  ENV OR_DB_HOST ${OR_DB_HOST:-postgresql}
  ENV OR_DB_PORT ${OR_DB_PORT:-5432}
  ENV OR_DB_NAME ${OR_DB_NAME:-openremote}
  ENV OR_DB_SCHEMA ${OR_DB_SCHEMA:-openremote}
  ENV OR_DB_USER ${OR_DB_USER:-postgres}
  ENV OR_DB_PASSWORD ${OR_DB_PASSWORD:-postgres}
  ENV OR_DB_MIN_POOL_SIZE ${OR_DB_MIN_POOL_SIZE:-5}
  ENV OR_DB_MAX_POOL_SIZE ${OR_DB_MAX_POOL_SIZE:-20}
  ENV OR_DB_CONNECTION_TIMEOUT_SECONDS ${OR_DB_CONNECTION_TIMEOUT_SECONDS:-300}
  ENV OR_DB_FLYWAY_OUT_OF_ORDER ${OR_DB_FLYWAY_OUT_OF_ORDER}
  ENV OR_KEYCLOAK_HOST ${OR_KEYCLOAK_HOST:-keycloak}
  ENV OR_KEYCLOAK_PORT ${OR_KEYCLOAK_PORT:-8080}
  ENV OR_KEYCLOAK_GRANT_FILE ${OR_KEYCLOAK_GRANT_FILE:-/deployment/manager/keycloak.json}
  ENV OR_APP_DOCROOT ${OR_APP_DOCROOT:-/opt/web}
  ENV OR_CUSTOM_APP_DOCROOT ${OR_CUSTOM_APP_DOCROOT:-/deployment/manager/app}
  ENV OR_PROVISIONING_DOCROOT ${OR_PROVISIONING_DOCROOT:-/deployment/manager/provisioning}
  ENV OR_ROOT_REDIRECT_PATH ${OR_ROOT_REDIRECT_PATH:-/manager}
  ENV OR_LOGGING_CONFIG_FILE ${OR_LOGGING_CONFIG_FILE}
  ENV OR_MAP_TILES_PATH ${OR_MAP_TILES_PATH:-/deployment.local/mapdata/mapdata.mbtiles}
  ENV OR_MAP_SETTINGS_PATH ${OR_MAP_SETTINGS_PATH:-/deployment/map/mapsettings.json}
  ENV OR_MAP_TILESERVER_HOST ${OR_MAP_TILESERVER_HOST}
  ENV OR_MAP_TILESERVER_PORT ${OR_MAP_TILESERVER_PORT:-8082}
  ENV OR_MAP_TILESERVER_REQUEST_TIMEOUT ${OR_MAP_TILESERVER_REQUEST_TIMEOUT:-10000}
  ENV OR_IDENTITY_PROVIDER ${OR_IDENTITY_PROVIDER:-keycloak}
  ENV OR_IDENTITY_SESSION_MAX_MINUTES ${OR_IDENTITY_SESSION_MAX_MINUTES:-1440}
  ENV OR_IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES ${OR_IDENTITY_SESSION_OFFLINE_TIMEOUT_MINUTES:-2628000}
  ENV OR_ATTRIBUTE_EVENT_THREADS ${OR_ATTRIBUTE_EVENT_THREADS}
  ENV OR_STORAGE_DIR ${OR_STORAGE_DIR:-/storage}
  ENV OR_GATEWAY_TUNNEL_LOCALHOST_REWRITE ${OR_GATEWAY_TUNNEL_LOCALHOST_REWRITE:-172.17.0.1}
  ENV OR_JAVA_OPTS ${OR_JAVA_OPTS:--Xms500m -Xmx2g \
      -XX:NativeMemoryTracking=summary \
      -Xlog:all=warning:stdout:uptime,level,tags \
      -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/dump.hprof}
  
  # OpenMetrics _created series breaks cloudwatch prometheus scraper
  ENV PROMETHEUS_DISABLE_CREATED_SERIES ${PROMETHEUS_DISABLE_CREATED_SERIES:-true}
  
  RUN mkdir -p /deployment/manager/extensions
  RUN mkdir -p /storage/logs
  
  WORKDIR /opt/app
  ADD ./balena-deployment/image /deployment
  
  ADD ./manager-build/lib /opt/app/lib
  ADD ./manager-build/web /opt/web
  ADD ./manager-build/map /opt/map
  
  EXPOSE 8080
  EXPOSE 1883
  
  HEALTHCHECK --interval=3s --timeout=60s --start-period=30s --retries=120 CMD curl --fail --silent http://localhost:8080 || exit 1
  ENTRYPOINT java $OR_JAVA_OPTS -cp /opt/app/lib/*:/deployment/manager/extensions/* org.openremote.manager.Main
  