diff --git a/.github/workflows/build-and-deploy-images.yaml b/.github/workflows/build-and-deploy-images.yaml new file mode 100644 index 0000000..35330fb --- /dev/null +++ b/.github/workflows/build-and-deploy-images.yaml @@ -0,0 +1,57 @@ +name: Build production images + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - dockerfiles/** + +concurrency: build-images + +jobs: + list-versions: + runs-on: ubuntu-latest + outputs: + versions: ${{ steps.versions.outputs.versions }} + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Read version slugs from releases.yaml + id: versions + run: echo "versions=$(yq -o=json -I=0 '[.versions[].slug]' releases.yaml)" >> "$GITHUB_OUTPUT" + + build-images: + needs: list-versions + runs-on: ubuntu-latest + environment: dockerhub + strategy: + fail-fast: false + matrix: + oie_version: ${{ fromJSON(needs.list-versions.outputs.versions) }} + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v4 + + - name: Set up Docker Compose + uses: docker/setup-compose-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v4 + with: + username: ${{ vars.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build images + working-directory: dockerfiles/${{ matrix.oie_version }} + run: | + docker compose --progress plain build --build-arg CREATED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ") --push + docker image ls diff --git a/.github/workflows/deploy-image.yaml b/.github/workflows/deploy-image.yaml deleted file mode 100644 index 2af9e6b..0000000 --- a/.github/workflows/deploy-image.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: Build production images - -on: - workflow_dispatch: - push: - branches: - - main - -jobs: - build-images: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Set up Docker Compose - uses: docker/setup-compose-action@v1 - - - name: Build images - working-directory: deploy - run: | - docker compose --progress plain build --build-arg CREATED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ") - docker image ls - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Push images to Docker hub - run: docker image push --all-tags openintegrationengine/engine diff --git a/README.md b/README.md index 6af5e3d..80a75f8 100644 --- a/README.md +++ b/README.md @@ -27,53 +27,72 @@ - 🌐 **Website**: [openintegrationengine.org](https://openintegrationengine.org) - 💬 **Discord**: [Join our server](https://discord.gg/azdehW2Zrx) -- 📂 **GitHub Repo**: [github.com/OpenIntegrationEngine/engine](https://github.com/OpenIntegrationEngine/engine) +- 📂 **GitHub Repo**: [OpenIntegrationEngine/engine](https://github.com/OpenIntegrationEngine/engine) #### How to file issues: -https://github.com/OpenIntegrationEngine/engine/issues +Issues regarding the Open Integration Engine software are tracked on the [Open Integration Engine GitHub repository](https://github.com/OpenIntegrationEngine/engine/issues), +whereas issues regarding the Docker images are tracked on the [engine-docker GitHub repository](https://github.com/OpenIntegrationEngine/engine-docker/issues). Please do your best to include the following information in your issue: * The exact commit hash of the code you are using * The commands you executed to build or run the image * The output of the command you executed (Hint: add `--progress=plain` to your `docker` command to see the full output) -* Use [Markdown](https://guides.github.com/features/mastering-markdown/) to format your issue text, ESPECIALLY if you are including code snippets or command output. This will make it easier for us to read and understand your issue. +* Use [Markdown](https://guides.github.com/features/mastering-markdown/) to format your issue text, **especially** if +you're including code snippets or command output. This will make it easier for us to read and understand your issue. ------------ # What is Open Integration Engine [↑](#top) -An open-source message integration engine focused on healthcare. For more information please visit [openintegrationengine.org](https://openintegrationengine.org). +An open-source message integration engine focused on healthcare. For more information, please visit +[openintegrationengine.org](https://openintegrationengine.org). -OpenIntegrationEngine is a community-driven project that continues the legacy of Mirth Connect, providing a flexible, open platform for managing healthcare interfaces. It supports a wide range of -healthcare standards and protocols, enabling seamless integration between disparate systems. +OpenIntegrationEngine is a community-driven project that continues the legacy of Mirth Connect, providing a flexible, +open platform for managing healthcare interfaces. It supports a wide range of healthcare standards and protocols, +enabling seamless integration between disparate systems. -OpenIntegrationEngine is designed to be vendor-neutral, allowing healthcare organizations to connect their systems without being locked into proprietary solutions. It offers a user-friendly interface -for building, deploying, and managing interfaces, along with powerful features for real-time monitoring and alerting. +OpenIntegrationEngine is designed to be vendor-neutral, allowing healthcare organizations to connect their systems +without being locked into proprietary solutions. It offers a user-friendly interface for building, deploying, and +managing interfaces, along with powerful features for real-time monitoring and alerting. ------------ # Supported Images [↑](#top) -All Open Integration Engine releases are packaged into the four following images: +All Open Integration Engine releases are packaged into the following images: -- `latest`, `latest-alpine`, `latest-alpine-jre` - - `4.5.2-tp.1-alpine`, `4.5.2-tp.1-alpine-jre` -- `latest-alpine-jdk` - - `4.5.2-tp.1-alpine-jdk` -- `latest-ubuntu`, `latest-ubuntu-jre` - - `4.5.2-tp.1-ubuntu`, `4.5.2-tp.1-ubuntu-jre` -- `latest-ubuntu-jdk` - - `4.5.2-tp.1-ubuntu-jdk` +### Version 4.6.0 _(latest)_ +- **Alpine**: `4.6.0-alpine-jre` (also `4.6.0-alpine`), `4.6.0-alpine-jdk` +- **Ubuntu**: `4.6.0-ubuntu-jre` (also `4.6.0-ubuntu`), `4.6.0-ubuntu-jdk` + +### Version 4.5.2 +- **Alpine**: `4.5.2-alpine-jre` (also `4.5.2-alpine`), `4.5.2-alpine-jdk` +- **Ubuntu**: `4.5.2-ubuntu-jre` (also `4.5.2-ubuntu`), `4.5.2-ubuntu-jdk` + +--- +### Floating Tags + +- **Default**: + - `latest` → `4.6.0-alpine-jre` +- **Distro Only**: + - `latest-alpine` → `4.6.0-alpine-jre` + - `latest-ubuntu` → `4.6.0-ubuntu-jre` +- **Distro + JVM**: + - `latest-alpine-jre` → `4.6.0-alpine-jre` + - `latest-alpine-jdk` → `4.6.0-alpine-jdk` + - `latest-ubuntu-jre` → `4.6.0-ubuntu-jre` + - `latest-ubuntu-jdk` → `4.6.0-ubuntu-jdk` ------------ # Supported Architectures [↑](#top) -Docker images for OIE 4.5.2 and later versions support both `linux/amd64` and `linux/arm64` architectures. As an example, to pull the latest `linux/arm64` image, use the command +Docker images for OIE 4.5.2 and later versions support both `linux/amd64` and `linux/arm64` architectures. As an +example, to pull the latest `linux/arm64` image, use the command ``` docker pull --platform linux/arm64 openintegrationengine/engine:latest ``` @@ -86,14 +105,15 @@ docker pull --platform linux/arm64 openintegrationengine/engine:latest ## Start an OpenIntegrationEngine instance [↑](#top) -Quickly start OpenIntegration using embedded Derby database and all configuration defaults. At a minimum you will likely want to use the `-p` option to expose the 8443 port so that you can log in with -the Administrator GUI or CLI: +Quickly start OpenIntegrationEngine using embedded Derby database and all configuration defaults. At a minimum you will +likely want to use the `-p` option to expose the 8443 port so that you can log in with the Administrator GUI or CLI: ```bash docker run -p 8443:8443 openintegrationengine/engine ``` -You can also use the `--name` option to give your container a unique name, and the `-d` option to detach the container and run it in the background: +You can also use the `--name` option to give your container a unique name, and the `-d` option to detach the container +and run it in the background: ```bash docker run --name myengine -d -p 8443:8443 openintegrationengine/engine @@ -118,7 +138,8 @@ Look at the [Environment Variables](#environment-variables) section for more ava ## Using [`docker stack deploy`](https://docs.docker.com/engine/reference/commandline/stack_deploy/) or [`docker compose`](https://github.com/docker/compose) [↑](#top) -With `docker stack` or `docker compose` you can easily set up and launch multiple related containers. For example, you might want to launch both Engine *and* a PostgreSQL database to run alongside it. +With `docker stack` or `docker compose` you can easily set up and launch multiple related containers. For example, +you might want to launch both Engine *and* a PostgreSQL database to run alongside it. ```bash docker compose -f stack.yml up @@ -162,7 +183,8 @@ services: ## Environment Variables [↑](#top) -You can use environment variables to configure the [mirth.properties](https://github.com/openintegrationengine/engine/blob/development/server/conf/mirth.properties) file or to add custom JVM options. +You can use environment variables to configure the [mirth.properties](https://github.com/openintegrationengine/engine/blob/development/server/conf/mirth.properties) +file or to add custom JVM options. ### Setting Environment Variables @@ -172,7 +194,8 @@ To set environment variables, use the `-e` option for each variable on the comma docker run -e DATABASE='derby' -p 8443:8443 openintegrationengine/engine ``` -You can also use a separate file containing all of your environment variables using the `--env-file` option. For example let's say you create a file **myenvfile.txt**: +You can also use a separate file containing all of your environment variables using the `--env-file` option. For example, +let's say you create a file **myenvfile.txt**: ```bash DATABASE=postgres @@ -215,12 +238,14 @@ The JDBC URL to use when connecting to the database. For example: #### `DATABASE_USERNAME` -The username to use when connecting to the database. If you don't want to use an environment variable to store sensitive information like this, look at the [Using Docker Secrets](#using-docker-secrets) section below. +The username to use when connecting to the database. If you don't want to use an environment variable to store sensitive +information like this, look at the [Using Docker Secrets](#using-docker-secrets) section below. #### `DATABASE_PASSWORD` -The password to use when connecting to the database. If you don't want to use an environment variable to store sensitive information like this, look at the [Using Docker Secrets](#using-docker-secrets) section below. +The password to use when connecting to the database. If you don't want to use an environment variable to store sensitive +information like this, look at the [Using Docker Secrets](#using-docker-secrets) section below. #### `DATABASE_MAX_CONNECTIONS` @@ -230,23 +255,27 @@ The maximum number of connections to use for the internal messaging engine conne #### `DATABASE_MAX_RETRY` -On startup, if a database connection cannot be made for any reason, Engine will wait and attempt again this number of times. By default, will retry 2 times (so 3 total attempts). +On startup, if a database connection cannot be made for any reason, Engine will wait and attempt again this number of +times. By default, will retry twice (so three total attempts). #### `DATABASE_RETRY_WAIT` -The amount of time (in milliseconds) to wait between database connection attempts. By default, will wait 10 seconds between attempts. +The amount of time (in milliseconds) to wait between database connection attempts. By default, will wait 10 seconds +between attempts. #### `KEYSTORE_STOREPASS` -The password for the keystore file itself. If you don't want to use an environment variable to store sensitive information like this, look at the [Using Docker Secrets](#using-docker-secrets) section below. +The password for the keystore file itself. If you don't want to use an environment variable to store sensitive +information like this, look at the [Using Docker Secrets](#using-docker-secrets) section below. #### `KEYSTORE_KEYPASS` -The password for the keys within the keystore, including the server certificate and the secret encryption key. If you don't want to use an environment variable to store sensitive information like this, -look at the [Using Docker Secrets](#using-docker-secrets) section below. +The password for the keys within the keystore, including the server certificate and the secret encryption key. If you +don't want to use an environment variable to store sensitive information like this, look at the +[Using Docker Secrets](#using-docker-secrets) section below. #### `KEYSTORE_TYPE` @@ -256,27 +285,31 @@ The type of keystore. #### `SESSION_STORE` -If set to true, the web server sessions are stored in the database. This can be useful in situations where you have multiple Engine servers (connecting to the same database) clustered behind a load -balancer. +If set to true, the web server sessions are stored in the database. This can be useful in situations where you have +multiple Engine servers (connecting to the same database) clustered behind a load balancer. #### `VMOPTIONS` -A comma-separated list of JVM command-line options to place in the `.vmoptions` file. For example to set the max heap size: +A comma-separated list of JVM command-line options to place in the `.vmoptions` file. For example, to set the max heap +size: -* -Xmx512m +* `-Xmx512m` #### `DELAY` -This tells the entrypoint script to wait for a certain amount of time (in seconds). The entrypoint script will automatically use a command-line SQL client to check connectivity and wait until the -database is up before starting Engine, but only when using PostgreSQL or MySQL. If you are using Oracle or SQL Server and the database is being started up at the same time as Engine, you may want -to use this option to tell Engine to wait a bit to allow the database time to startup. +This tells the entrypoint script to wait for a certain amount of time (in seconds). The entrypoint script will +automatically use a command-line SQL client to check connectivity and wait until the database is up before starting +Engine, but only when using PostgreSQL or MySQL. If you are using Oracle or SQL Server and the database is being started +up at the same time as Engine, you may want to use this option to tell Engine to wait a bit to allow the database time to +start up. #### `KEYSTORE_DOWNLOAD` -A URL location of a Engine keystore file. This file will be downloaded into the container and Engine will use it as its keystore. +A URL location of an Engine keystore file. This file will be downloaded into the container, and Engine will use it as +its keystore. #### `EXTENSIONS_DOWNLOAD` @@ -286,26 +319,30 @@ A URL location of a zip file containing Engine extension zip files. The extensio #### `CUSTOM_JARS_DOWNLOAD` -A URL location of a zip file containing JAR files. The JAR files will be installed into the `server-launcher-lib` folder on the Engine server, so they will be added to the server's classpath. +A URL location of a zip file containing JAR files. The JAR files will be installed into the `server-launcher-lib` folder +on the Engine server, so they will be added to the server's classpath. #### `ALLOW_INSECURE` -Allow insecure SSL connections when downloading files during startup. This applies to keystore downloads, plugin downloads, and server library downloads. By default, insecure connections are disabled, -but you can enable this option by setting `ALLOW_INSECURE=true`. +Allow insecure SSL connections when downloading files during startup. This applies to keystore downloads, plugin +downloads, and server library downloads. By default, insecure connections are disabled, but you can enable this option +by setting `ALLOW_INSECURE=true`. #### `SERVER_ID` -Set the `server.id` to a specific value. Use this to preserve or set the server ID across restarts and deployments. Using the env-var is preferred over storing `appdata` persistently +Set the `server.id` to a specific value. Use this to preserve or set the server ID across restarts and deployments. +Using the env-var is preferred over storing `appdata` persistently ------------ ### Other mirth.properties options [↑](#top) -Other options in the mirth.properties file can also be changed. Any environment variable starting with the `_MP_` prefix will set the corresponding value in mirth.properties. Replace `.` with a single -underscore `_` and `-` with two underscores `__`. +Other options in the `mirth.properties` file can also be changed. Any environment variable starting with the `_MP_` +prefix will set the corresponding value in mirth.properties. Replace `.` with a single underscore `_` and `-` with two +underscores `__`. Examples: @@ -326,8 +363,8 @@ Examples: ## Using Docker Secrets [↑](#top) -For sensitive information such as the database/keystore credentials, instead of supplying them as environment variables you can use a [Docker Secret](https://docs.docker.com/engine/swarm/secrets/). -There are two secret names this image supports: +For sensitive information such as the database/keystore credentials, instead of supplying them as environment variables, +you can use a [Docker Secret](https://docs.docker.com/engine/swarm/secrets/). There are two secret names this image supports: ##### mirth_properties @@ -341,7 +378,8 @@ If present, any JVM options in this secret will be appended onto the mcserver.vm Secrets are supported with [Docker Swarm](https://docs.docker.com/engine/swarm/secrets/), but you can also use them with [`docker compose`](#using-docker-compose). -For example let's say you wanted to set `keystore.storepass` and `keystore.keypass` in a secure way. You could create a new file, **secret.properties**: +For example, let's say you wanted to set `keystore.storepass` and `keystore.keypass` in a secure way. You could create +a new file, **secret.properties**: ```bash keystore.storepass=changeme @@ -367,9 +405,11 @@ secrets: file: /local/path/to/secret.properties ``` -The **secrets** section at the bottom specifies the local file location for each secret. Change `/local/path/to/secret.properties` to the correct local path and filename. +The **secrets** section at the bottom specifies the local file location for each secret. Change +`/local/path/to/secret.properties` to the correct local path and filename. -Inside the configuration for the Engine container there is also a **secrets** section that lists the secrets you want to include for that container. +Inside the configuration for the Engine container, there is also a **secrets** section that lists the secrets you want +to include for that container. ------------ @@ -379,16 +419,17 @@ Inside the configuration for the Engine container there is also a **secrets** se #### The appdata folder [↑](#top) -The application data directory (appdata) stores configuration files and temporary data created by Engine after starting up. This usually includes the keystore file and the `server.id` file that stores -your server ID. If you are launching Engine as part of a stack/swarm, it's possible the container filesystem is already being preserved. But if not, you may want to consider mounting a **volume** to -preserve the appdata folder. +The application data directory (appdata) stores configuration files and temporary data created by Engine after starting +up. This usually includes the keystore file and the `server.id` file that stores your server ID. If you are launching +Engine as part of a stack/swarm, it's possible the container filesystem is already being preserved. But if not, you may +want to consider mounting a **volume** to preserve the appdata folder. ```bash docker run -v /local/path/to/appdata:/opt/engine/appdata -p 8443:8443 openintegrationengine/engine ``` -The `-v` option makes a local directory from your filesystem available to the Docker container. Create a folder on your local filesystem, then change the `/local/path/to/appdata` part in the example -above to the correct local path. +The `-v` option makes a local directory from your filesystem available to the Docker container. Create a folder on your +local filesystem, then change the `/local/path/to/appdata` part in the example above to the correct local path. You can also configure volumes as part of your `compose.yaml`: @@ -405,14 +446,16 @@ services: #### Additional extensions [↑](#top) -The entrypoint script will automatically look for any `.zip` files in the `/opt/engine/custom-extensions` folder and unzip them into the extensions folder before Engine starts up. -So to launch Engine with any additional extensions not included in the base application, do this: +The entrypoint script will automatically look for any `.zip` files in the `/opt/engine/custom-extensions` folder and +unzip them into the extensions folder before Engine starts up. So to launch Engine with any additional extensions not +included in the base application, do this: ```bash -docker run -v /local/path/to/custom-extensions:/opt/engine/custom-extensions -p 8443:8443 openintegrationengine/engine:latest-ubuntu-jre +docker run -v /path/to/custom-extensions:/opt/engine/custom-extensions -p 8443:8443 openintegrationengine/engine:latest-ubuntu-jre ``` -Create a folder on your local filesystem containing the ZIP files for your additional extensions. Then change the `/local/path/to/custom-extensions` part in the example above to the correct local path. +Create a folder in your local filesystem containing the ZIP files for your additional extensions. Then change the +`/path/to/custom-extensions` part in the example above to the correct local path. As with the appdata example, you can also configure this volume as part of your `compose.yaml`. @@ -420,8 +463,9 @@ As with the appdata example, you can also configure this volume as part of your ## Known Limitations -Currently, only the Debian flavored images support the newest authentication scheme in MySQL 8. All others (the Alpine based images) will need the following to force the MySQL database container to -start using the old authentication scheme: +Currently, only the Ubuntu-based images support the newest authentication scheme in MySQL 8. All others +(the Alpine-based images) will need the following to force the MySQL database container to start using the old +authentication scheme: ```yaml command: --default-authentication-plugin=mysql_native_password @@ -441,7 +485,8 @@ Example: ## Building images -To build the full set of four images (`ubuntu-jre`, `ubuntu-jdk`, `alpine-jre`, and `alpine-jdk`) run the following command in the `deploy/` directory: +To build the full set of four images (`ubuntu-jre`, `ubuntu-jdk`, `alpine-jre`, and `alpine-jdk`) run the following +command in the `dockerfiles//` directory: ```sh docker compose build --build-arg CREATED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ") ``` @@ -451,5 +496,5 @@ docker compose build --build-arg CREATED_AT=$(date -u +"%Y-%m-%dT%H:%M:%SZ") # License [↑](#top) -The Dockerfiles, entrypoint script, and any other files used to build these Docker images are Copyright © NextGen Healthcare and OpenIntegrationEngine contributors. -They are licensed under the [Mozilla Public License 2.0](https://www.mozilla.org/en-US/MPL/2.0/). +The Dockerfiles, entrypoint script, and any other files used to build these Docker images are Copyright © NextGen +Healthcare and OpenIntegrationEngine contributors. They are licensed under the [Mozilla Public License 2.0](https://www.mozilla.org/en-US/MPL/2.0/). diff --git a/deploy/.dockerignore b/deploy/.dockerignore deleted file mode 100644 index 864179f..0000000 --- a/deploy/.dockerignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!entrypoint.sh diff --git a/deploy/.env b/deploy/.env deleted file mode 100644 index 5284572..0000000 --- a/deploy/.env +++ /dev/null @@ -1,8 +0,0 @@ -UBUNTU_JRE_TAG=17.0.15_6-jre-noble -UBUNTU_JDK_TAG=17.0.15_6-jdk-noble - -ALPINE_JRE_TAG=17.0.15_6-jre-alpine -ALPINE_JDK_TAG=17.0.15_6-jdk-alpine - -OIE_RELEASE_VERSION=4.5.2-tp.1 -OIE_RELEASE_URL=https://github.com/OpenIntegrationEngine/engine/releases/download/v4.5.2-tp.1/oie_unix_4_5_2.tar.gz diff --git a/deploy/Dockerfile b/deploy/Dockerfile deleted file mode 100644 index cceff2b..0000000 --- a/deploy/Dockerfile +++ /dev/null @@ -1,112 +0,0 @@ -# syntax=docker/dockerfile:1 - -ARG BASE_IMAGE_TAG - -ARG OIE_RELEASE_VERSION - -ARG UID=14285 -ARG GID=14285 - -FROM alpine:3.21.3 AS downloader - -ARG UID -ARG GID -ARG OIE_RELEASE_URL - -WORKDIR /opt - -# Download Open Integration Engine release -RUN apk add --no-cache curl \ - && curl -L \ - -o /opt/engine.tar.gz \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - ${OIE_RELEASE_URL}\ - && tar xzf engine.tar.gz \ - && mv /opt/oie /opt/engine \ - && mkdir -p /opt/engine/appdata - -WORKDIR /opt/engine -COPY --chmod=755 entrypoint.sh /opt/engine/entrypoint.sh - -RUN rm -rf cli-lib manager-lib \ - && rm mirth-cli-launcher.jar oiecommand - -RUN chown -R ${UID}:${GID} /opt/engine - - -########################################## -# Alpine based Images -########################################## -FROM eclipse-temurin:$BASE_IMAGE_TAG AS alpine - -ARG UID -ARG GID -ARG OIE_RELEASE_VERSION -ARG CREATED_AT - -# Add OCI best-practice labels https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys -LABEL "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ - "org.opencontainers.image.created"="${CREATED_AT?:}" \ - "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ - "org.opencontainers.image.licenses"="MPL-2.0" \ - "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ - "org.opencontainers.image.title"="Open Integration Engine" \ - "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ - "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ - "org.opencontainers.image.version"="${OIE_RELEASE_VERSION?:}" - -COPY --from=downloader /opt/engine /opt/engine - -RUN apk add --no-cache bash unzip \ - && adduser -D -H -u $UID engine engine - -VOLUME /opt/engine/appdata -VOLUME /opt/engine/custom-extensions - -WORKDIR /opt/engine -EXPOSE 8443 -USER engine - -ENTRYPOINT ["./entrypoint.sh"] -CMD ["./oieserver"] - -########################################## -# Ubuntu based Images -########################################## -FROM eclipse-temurin:$BASE_IMAGE_TAG AS ubuntu - -ARG UID -ARG GID -ARG OIE_RELEASE_VERSION -ARG CREATED_AT - -# Add OCI best-practice labels https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys -LABEL "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ - "org.opencontainers.image.created"="${CREATED_AT?:}" \ - "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ - "org.opencontainers.image.licenses"="MPL-2.0" \ - "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ - "org.opencontainers.image.title"="Open Integration Engine" \ - "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ - "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ - "org.opencontainers.image.version"="${OIE_RELEASE_VERSION?:}" - -COPY --from=downloader /opt/engine /opt/engine - -RUN apt-get update \ - && apt-get install -y unzip \ - && rm -rf /var/lib/apt/lists/* \ - && groupadd --gid ${GID} engine \ - && useradd -u ${UID} -g ${GID} -M engine - -VOLUME /opt/engine/appdata -VOLUME /opt/engine/custom-extensions - -WORKDIR /opt/engine -EXPOSE 8443 -USER engine - -ENTRYPOINT ["./entrypoint.sh"] -CMD ["./oieserver"] - diff --git a/deploy/compose.yaml b/deploy/compose.yaml deleted file mode 100644 index aa3e6f9..0000000 --- a/deploy/compose.yaml +++ /dev/null @@ -1,69 +0,0 @@ -name: open-integration-engine - -services: - ubuntu-jdk: - image: openintegrationengine/engine - build: - dockerfile: Dockerfile - target: ubuntu - context: . - args: - BASE_IMAGE_TAG: ${UBUNTU_JDK_TAG:?} - OIE_RELEASE_VERSION: ${OIE_RELEASE_VERSION:?} - OIE_RELEASE_URL: ${OIE_RELEASE_URL:?} - platforms: &platforms - - linux/amd64 -# - linux/arm64 - tags: - - openintegrationengine/engine:latest-ubuntu-jdk - - openintegrationengine/engine:${OIE_RELEASE_VERSION?:}-ubuntu-jdk - - ubuntu-jre: - image: openintegrationengine/engine - build: - dockerfile: Dockerfile - target: ubuntu - context: . - args: - BASE_IMAGE_TAG: ${UBUNTU_JRE_TAG:?} - OIE_RELEASE_VERSION: ${OIE_RELEASE_VERSION:?} - OIE_RELEASE_URL: ${OIE_RELEASE_URL:?} - platforms: *platforms - tags: - - openintegrationengine/engine:latest-ubuntu - - openintegrationengine/engine:latest-ubuntu-jre - - openintegrationengine/engine:${OIE_RELEASE_VERSION?:}-ubuntu - - openintegrationengine/engine:${OIE_RELEASE_VERSION?:}-ubuntu-jre - - alpine-jdk: - image: openintegrationengine/engine - build: - dockerfile: Dockerfile - target: alpine - context: . - args: - BASE_IMAGE_TAG: ${ALPINE_JDK_TAG:?} - OIE_RELEASE_VERSION: ${OIE_RELEASE_VERSION:?} - OIE_RELEASE_URL: ${OIE_RELEASE_URL:?} - platforms: *platforms - tags: - - openintegrationengine/engine:latest-alpine-jdk - - openintegrationengine/engine:${OIE_RELEASE_VERSION?:}-alpine-jre - - alpine-jre: - image: openintegrationengine/engine - build: - dockerfile: Dockerfile - target: alpine - context: . - args: - BASE_IMAGE_TAG: ${ALPINE_JRE_TAG:?} - OIE_RELEASE_VERSION: ${OIE_RELEASE_VERSION:?} - OIE_RELEASE_URL: ${OIE_RELEASE_URL:?} - platforms: *platforms - tags: - - openintegrationengine/engine:latest - - openintegrationengine/engine:latest-alpine - - openintegrationengine/engine:latest-alpine-jre - - openintegrationengine/engine:${OIE_RELEASE_VERSION?:}-alpine - - openintegrationengine/engine:${OIE_RELEASE_VERSION?:}-alpine-jre diff --git a/dockerfiles/4.5.2/Dockerfile b/dockerfiles/4.5.2/Dockerfile new file mode 100644 index 0000000..c8d7f6d --- /dev/null +++ b/dockerfiles/4.5.2/Dockerfile @@ -0,0 +1,158 @@ +# syntax=docker/dockerfile:1 + +################################################################ +# # +# WARNING: THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY # +# # +################################################################ + +ARG CREATED_AT + +FROM alpine:3.24.1 AS downloader + +WORKDIR /opt + +# Download Open Integration Engine release +RUN apk add --no-cache curl \ + && curl -L \ + -o /opt/engine.tar.gz \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://github.com/OpenIntegrationEngine/engine/releases/download/v4.5.2/oie_unix_4_5_2.tar.gz \ + && tar xzf engine.tar.gz \ + && mv /opt/oie /opt/engine \ + && mkdir -p /opt/engine/appdata + +WORKDIR /opt/engine +COPY --chmod=755 entrypoint.sh /opt/engine/entrypoint.sh + +RUN rm -rf cli-lib manager-lib \ + && rm mirth-cli-launcher.jar oiecommand + +FROM eclipse-temurin:17.0.20.1_1-jre-noble AS ubuntu-jre + +ARG CREATED_AT + +LABEL \ + "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ + "org.opencontainers.image.created"="${CREATED_AT?:}" \ + "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ + "org.opencontainers.image.licenses"="MPL-2.0" \ + "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ + "org.opencontainers.image.title"="Open Integration Engine" \ + "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ + "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ + "org.opencontainers.image.version"="4.5.2" + +COPY --from=downloader --chown=1000:1000 /opt/engine /opt/engine + +RUN apt-get update \ + && apt-get install -y unzip \ + && rm -rf /var/lib/apt/lists/* \ + && groupmod --new-name engine ubuntu \ + && usermod -l engine ubuntu \ + && usermod -G '' engine + +VOLUME /opt/engine/appdata +VOLUME /opt/engine/custom-extensions + +WORKDIR /opt/engine +EXPOSE 8443 +USER engine + +ENTRYPOINT ["./entrypoint.sh"] +CMD ["./oieserver"] + +FROM eclipse-temurin:17.0.20.1_1-jdk-noble AS ubuntu-jdk + +ARG CREATED_AT + +LABEL \ + "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ + "org.opencontainers.image.created"="${CREATED_AT?:}" \ + "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ + "org.opencontainers.image.licenses"="MPL-2.0" \ + "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ + "org.opencontainers.image.title"="Open Integration Engine" \ + "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ + "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ + "org.opencontainers.image.version"="4.5.2" + +COPY --from=downloader --chown=1000:1000 /opt/engine /opt/engine + +RUN apt-get update \ + && apt-get install -y unzip \ + && rm -rf /var/lib/apt/lists/* \ + && groupmod --new-name engine ubuntu \ + && usermod -l engine ubuntu \ + && usermod -G '' engine + +VOLUME /opt/engine/appdata +VOLUME /opt/engine/custom-extensions + +WORKDIR /opt/engine +EXPOSE 8443 +USER engine + +ENTRYPOINT ["./entrypoint.sh"] +CMD ["./oieserver"] + +FROM eclipse-temurin:17.0.20.1_1-jre-alpine AS alpine-jre + +ARG CREATED_AT + +LABEL \ + "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ + "org.opencontainers.image.created"="${CREATED_AT?:}" \ + "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ + "org.opencontainers.image.licenses"="MPL-2.0" \ + "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ + "org.opencontainers.image.title"="Open Integration Engine" \ + "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ + "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ + "org.opencontainers.image.version"="4.5.2" + +COPY --from=downloader --chown=1000:1000 /opt/engine /opt/engine + +RUN apk add --no-cache bash unzip \ + && adduser -D -H -u 1000 engine engine + +VOLUME /opt/engine/appdata +VOLUME /opt/engine/custom-extensions + +WORKDIR /opt/engine +EXPOSE 8443 +USER engine + +ENTRYPOINT ["./entrypoint.sh"] +CMD ["./oieserver"] + +FROM eclipse-temurin:17.0.20.1_1-jdk-alpine AS alpine-jdk + +ARG CREATED_AT + +LABEL \ + "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ + "org.opencontainers.image.created"="${CREATED_AT?:}" \ + "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ + "org.opencontainers.image.licenses"="MPL-2.0" \ + "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ + "org.opencontainers.image.title"="Open Integration Engine" \ + "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ + "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ + "org.opencontainers.image.version"="4.5.2" + +COPY --from=downloader --chown=1000:1000 /opt/engine /opt/engine + +RUN apk add --no-cache bash unzip \ + && adduser -D -H -u 1000 engine engine + +VOLUME /opt/engine/appdata +VOLUME /opt/engine/custom-extensions + +WORKDIR /opt/engine +EXPOSE 8443 +USER engine + +ENTRYPOINT ["./entrypoint.sh"] +CMD ["./oieserver"] diff --git a/dockerfiles/4.5.2/compose.yaml b/dockerfiles/4.5.2/compose.yaml new file mode 100644 index 0000000..d4280c5 --- /dev/null +++ b/dockerfiles/4.5.2/compose.yaml @@ -0,0 +1,54 @@ +################################################################ +# # +# WARNING: THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY # +# # +################################################################ + +name: open-integration-engine + +services: + ubuntu-jre: + image: openintegrationengine/engine + build: + target: ubuntu-jre + context: . + platforms: + - linux/amd64 + - linux/arm64 + tags: + - openintegrationengine/engine:4.5.2-ubuntu + - openintegrationengine/engine:4.5.2-ubuntu-jre + + ubuntu-jdk: + image: openintegrationengine/engine + build: + target: ubuntu-jdk + context: . + platforms: + - linux/amd64 + - linux/arm64 + tags: + - openintegrationengine/engine:4.5.2-ubuntu-jdk + + alpine-jre: + image: openintegrationengine/engine + build: + target: alpine-jre + context: . + platforms: + - linux/amd64 + - linux/arm64 + tags: + - openintegrationengine/engine:4.5.2-alpine + - openintegrationengine/engine:4.5.2-alpine-jre + + alpine-jdk: + image: openintegrationengine/engine + build: + target: alpine-jdk + context: . + platforms: + - linux/amd64 + - linux/arm64 + tags: + - openintegrationengine/engine:4.5.2-alpine-jdk diff --git a/deploy/entrypoint.sh b/dockerfiles/4.5.2/entrypoint.sh similarity index 100% rename from deploy/entrypoint.sh rename to dockerfiles/4.5.2/entrypoint.sh diff --git a/dockerfiles/4.6.0/Dockerfile b/dockerfiles/4.6.0/Dockerfile new file mode 100644 index 0000000..c8d3c10 --- /dev/null +++ b/dockerfiles/4.6.0/Dockerfile @@ -0,0 +1,158 @@ +# syntax=docker/dockerfile:1 + +################################################################ +# # +# WARNING: THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY # +# # +################################################################ + +ARG CREATED_AT + +FROM alpine:3.24.1 AS downloader + +WORKDIR /opt + +# Download Open Integration Engine release +RUN apk add --no-cache curl \ + && curl -L \ + -o /opt/engine.tar.gz \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://github.com/OpenIntegrationEngine/engine/releases/download/v4.6.0/oie_unix_4_6_0.tar.gz \ + && tar xzf engine.tar.gz \ + && mv /opt/oie /opt/engine \ + && mkdir -p /opt/engine/appdata + +WORKDIR /opt/engine +COPY --chmod=755 entrypoint.sh /opt/engine/entrypoint.sh + +RUN rm -rf cli-lib manager-lib \ + && rm mirth-cli-launcher.jar oiecommand + +FROM eclipse-temurin:21.0.11_10-jre-resolute AS ubuntu-jre + +ARG CREATED_AT + +LABEL \ + "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ + "org.opencontainers.image.created"="${CREATED_AT?:}" \ + "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ + "org.opencontainers.image.licenses"="MPL-2.0" \ + "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ + "org.opencontainers.image.title"="Open Integration Engine" \ + "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ + "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ + "org.opencontainers.image.version"="4.6.0" + +COPY --from=downloader --chown=1000:1000 /opt/engine /opt/engine + +RUN apt-get update \ + && apt-get install -y unzip \ + && rm -rf /var/lib/apt/lists/* \ + && groupmod --new-name engine ubuntu \ + && usermod -l engine ubuntu \ + && usermod -G '' engine + +VOLUME /opt/engine/appdata +VOLUME /opt/engine/custom-extensions + +WORKDIR /opt/engine +EXPOSE 8443 +USER engine + +ENTRYPOINT ["./entrypoint.sh"] +CMD ["./oieserver"] + +FROM eclipse-temurin:21.0.11_10-jdk-resolute AS ubuntu-jdk + +ARG CREATED_AT + +LABEL \ + "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ + "org.opencontainers.image.created"="${CREATED_AT?:}" \ + "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ + "org.opencontainers.image.licenses"="MPL-2.0" \ + "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ + "org.opencontainers.image.title"="Open Integration Engine" \ + "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ + "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ + "org.opencontainers.image.version"="4.6.0" + +COPY --from=downloader --chown=1000:1000 /opt/engine /opt/engine + +RUN apt-get update \ + && apt-get install -y unzip \ + && rm -rf /var/lib/apt/lists/* \ + && groupmod --new-name engine ubuntu \ + && usermod -l engine ubuntu \ + && usermod -G '' engine + +VOLUME /opt/engine/appdata +VOLUME /opt/engine/custom-extensions + +WORKDIR /opt/engine +EXPOSE 8443 +USER engine + +ENTRYPOINT ["./entrypoint.sh"] +CMD ["./oieserver"] + +FROM eclipse-temurin:21.0.11_10-jre-alpine AS alpine-jre + +ARG CREATED_AT + +LABEL \ + "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ + "org.opencontainers.image.created"="${CREATED_AT?:}" \ + "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ + "org.opencontainers.image.licenses"="MPL-2.0" \ + "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ + "org.opencontainers.image.title"="Open Integration Engine" \ + "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ + "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ + "org.opencontainers.image.version"="4.6.0" + +COPY --from=downloader --chown=1000:1000 /opt/engine /opt/engine + +RUN apk add --no-cache bash unzip \ + && adduser -D -H -u 1000 engine engine + +VOLUME /opt/engine/appdata +VOLUME /opt/engine/custom-extensions + +WORKDIR /opt/engine +EXPOSE 8443 +USER engine + +ENTRYPOINT ["./entrypoint.sh"] +CMD ["./oieserver"] + +FROM eclipse-temurin:21.0.11_10-jdk-alpine AS alpine-jdk + +ARG CREATED_AT + +LABEL \ + "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ + "org.opencontainers.image.created"="${CREATED_AT?:}" \ + "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ + "org.opencontainers.image.licenses"="MPL-2.0" \ + "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ + "org.opencontainers.image.title"="Open Integration Engine" \ + "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ + "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ + "org.opencontainers.image.version"="4.6.0" + +COPY --from=downloader --chown=1000:1000 /opt/engine /opt/engine + +RUN apk add --no-cache bash unzip \ + && adduser -D -H -u 1000 engine engine + +VOLUME /opt/engine/appdata +VOLUME /opt/engine/custom-extensions + +WORKDIR /opt/engine +EXPOSE 8443 +USER engine + +ENTRYPOINT ["./entrypoint.sh"] +CMD ["./oieserver"] diff --git a/dockerfiles/4.6.0/compose.yaml b/dockerfiles/4.6.0/compose.yaml new file mode 100644 index 0000000..b910bd8 --- /dev/null +++ b/dockerfiles/4.6.0/compose.yaml @@ -0,0 +1,61 @@ +################################################################ +# # +# WARNING: THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY # +# # +################################################################ + +name: open-integration-engine + +services: + ubuntu-jre: + image: openintegrationengine/engine + build: + target: ubuntu-jre + context: . + platforms: + - linux/amd64 + - linux/arm64 + tags: + - openintegrationengine/engine:4.6.0-ubuntu + - openintegrationengine/engine:4.6.0-ubuntu-jre + - openintegrationengine/engine:latest-ubuntu-jre + - openintegrationengine/engine:latest-ubuntu + + ubuntu-jdk: + image: openintegrationengine/engine + build: + target: ubuntu-jdk + context: . + platforms: + - linux/amd64 + - linux/arm64 + tags: + - openintegrationengine/engine:4.6.0-ubuntu-jdk + - openintegrationengine/engine:latest-ubuntu-jdk + + alpine-jre: + image: openintegrationengine/engine + build: + target: alpine-jre + context: . + platforms: + - linux/amd64 + - linux/arm64 + tags: + - openintegrationengine/engine:4.6.0-alpine + - openintegrationengine/engine:4.6.0-alpine-jre + - openintegrationengine/engine:latest-alpine-jre + - openintegrationengine/engine:latest-alpine + - openintegrationengine/engine:latest + + alpine-jdk: + image: openintegrationengine/engine + build: + target: alpine-jdk + context: . + platforms: + - linux/amd64 + - linux/arm64 + tags: + - openintegrationengine/engine:4.6.0-alpine-jdk + - openintegrationengine/engine:latest-alpine-jdk diff --git a/dockerfiles/4.6.0/entrypoint.sh b/dockerfiles/4.6.0/entrypoint.sh new file mode 100755 index 0000000..285d501 --- /dev/null +++ b/dockerfiles/4.6.0/entrypoint.sh @@ -0,0 +1,245 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2023 NextGen Healthcare +# SPDX-FileCopyrightText: 2025 Kaur Palang +# + +set -e + +APP_DIR=/opt/engine + +custom_extension_count=`ls -1 "$APP_DIR"/custom-extensions/*.zip 2>/dev/null | wc -l` +if [ $custom_extension_count != 0 ]; then + echo "Found ${custom_extension_count} custom extensions." + for extension in $(ls -1 "$APP_DIR"/custom-extensions/*.zip); do + unzip -o -q $extension -d "$APP_DIR/extensions" + done +fi + +# set storepass and keypass to 'changeme' so they aren't overwritten later +KEYSTORE_PASS=changeme +sed -i "s/^keystore\.storepass\s*=\s*.*\$/keystore.storepass = ${KEYSTORE_PASS//\//\\/}/" "$APP_DIR/conf/mirth.properties" +sed -i "s/^keystore\.keypass\s*=\s*.*\$/keystore.keypass = ${KEYSTORE_PASS//\//\\/}/" "$APP_DIR/conf/mirth.properties" + +# merge the environment variables into /opt/engine/conf/mirth.properties +# db type +if ! [ -z "${DATABASE+x}" ]; then + sed -i "s/^database\s*=\s*.*\$/database = ${DATABASE//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# db username +if ! [ -z "${DATABASE_USERNAME+x}" ]; then + sed -i "s/^database\.username\s*=\s*.*\$/database.username = ${DATABASE_USERNAME//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# db password +if ! [ -z "${DATABASE_PASSWORD+x}" ]; then + sed -i "s/^database\.password\s*=\s*.*\$/database.password = ${DATABASE_PASSWORD//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# db url +if ! [ -z "${DATABASE_URL+x}" ]; then + sed -i "s/^database\.url\s*=\s*.*\$/database.url = ${DATABASE_URL//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# database max connections +if ! [ -z "${DATABASE_MAX_CONNECTIONS+x}" ]; then + sed -i "s/^database\.max-connections\s*=\s*.*\$/database.max-connections = ${DATABASE_MAX_CONNECTIONS//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# database max retries +if ! [ -z "${DATABASE_MAX_RETRY+x}" ]; then + sed -i "s/^database\.connection\.maxretry\s*=\s*.*\$/database.connection.maxretry = ${DATABASE_MAX_RETRY//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# database retry wait time +if ! [ -z "${DATABASE_RETRY_WAIT+x}" ]; then + sed -i "s/^database\.connection\.retrywaitinmilliseconds\s*=\s*.*\$/database.connection.retrywaitinmilliseconds = ${DATABASE_RETRY_WAIT//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# keystore storepass +if ! [ -z "${KEYSTORE_STOREPASS+x}" ]; then + sed -i "s/^keystore\.storepass\s*=\s*.*\$/keystore.storepass = ${KEYSTORE_STOREPASS//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# keystore keypass +if ! [ -z "${KEYSTORE_KEYPASS+x}" ]; then + sed -i "s/^keystore\.keypass\s*=\s*.*\$/keystore.keypass = ${KEYSTORE_KEYPASS//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +if ! [ -z "${KEYSTORE_TYPE+x}" ]; then + sed -i "s/^keystore\.type\s*=\s*.*\$/keystore.type = ${KEYSTORE_TYPE//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# session store +if ! [ -z "${SESSION_STORE+x}" ]; then + LINE_COUNT=`grep "server.api.sessionstore" "$APP_DIR/conf/mirth.properties" | wc -l` + if [ $LINE_COUNT -lt 1 ]; then + echo -e "\nserver.api.sessionstore = ${SESSION_STORE//\//\\/}" >> "$APP_DIR/conf/mirth.properties" + else + sed -i "s/^server\.api\.sessionstore\s*=\s*.*\$/server.api.sessionstore = ${SESSION_STORE//\//\\/}/" "$APP_DIR/conf/mirth.properties" + fi +fi + +#server ID +if ! [ -z "${SERVER_ID+x}" ]; then + echo -e "server.id = ${SERVER_ID//\//\\/}" > "$APP_DIR/appdata/server.id" +fi + +# merge extra environment variables starting with _MP_ into mirth.properties +while read -r keyvalue; do + KEY="${keyvalue%%=*}" + VALUE="${keyvalue#*=}" + VALUE=$(tr -dc '\40-\176' <<< "$VALUE") + + if ! [ -z "${KEY}" ] && ! [ -z "${VALUE}" ] && ! [[ ${VALUE} =~ ^\ +$ ]]; then + + # filter for variables starting with "_MP_" + if [[ ${KEY} == _MP_* ]]; then + + # echo "found property ${KEY}=${VALUE}" + + # example: _MP_DATABASE_MAX__CONNECTIONS -> database.max-connections + + # remove _MP_ + # example: DATABASE_MAX__CONNECTIONS + ACTUAL_KEY=${KEY:4} + + # switch '__' to '-' + # example: DATABASE_MAX-CONNECTIONS + ACTUAL_KEY="${ACTUAL_KEY//__/-}" + + # switch '_' to '.' + # example: DATABASE.MAX-CONNECTIONS + ACTUAL_KEY="${ACTUAL_KEY//_/.}" + + # lower case + # example: database.max-connections + ACTUAL_KEY="${ACTUAL_KEY,,}" + + # if key does not exist in mirth.properties append it at bottom + LINE_COUNT=`grep "^${ACTUAL_KEY}" "$APP_DIR/conf/mirth.properties" | wc -l` + if [ $LINE_COUNT -lt 1 ]; then + # echo "key ${ACTUAL_KEY} not found in mirth.properties, appending. Value = ${VALUE}" + echo -e "\n${ACTUAL_KEY} = ${VALUE//\//\\/}" >> "$APP_DIR/conf/mirth.properties" + else # otherwise key exists, overwrite it + # echo "key ${ACTUAL_KEY} exists, overwriting. Value = ${VALUE}" + ESCAPED_KEY="${ACTUAL_KEY//./\\.}" + sed -i "s/^${ESCAPED_KEY}\s*=\s*.*\$/${ACTUAL_KEY} = ${VALUE//\//\\/}/" "$APP_DIR/conf/mirth.properties" + fi + fi + fi +done <<< "`printenv`" + +# merge vmoptions into /opt/engine/oieserver.vmoptions +if ! [ -z "${VMOPTIONS+x}" ]; then + PREV_IFS="$IFS" + IFS="," + read -ra vmoptions <<< "$VMOPTIONS" + IFS="$PREV_IFS" + + for vmoption in "${vmoptions[@]}" + do + echo "${vmoption}" >> "$APP_DIR/oieserver.vmoptions" + done +fi + +# merge the user's secret mirth.properties +# takes a whole mirth.properties file and merges line by line with /opt/engine/conf/mirth.properties +if [ -f /run/secrets/mirth_properties ]; then + + # add new line in case /opt/engine/conf/mirth.properties doesn't end with one + echo "" >> "$APP_DIR/conf/mirth.properties" + + while read -r keyvalue; do + KEY="${keyvalue%%=*}" + VALUE="${keyvalue#*=}" + + # remove leading and trailing white space + KEY="$(echo -e "${KEY}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + VALUE="$(echo -e "${VALUE}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + + if ! [ -z "${KEY}" ] && ! [ -z "${VALUE}" ] && ! [[ ${VALUE} =~ ^\ +$ ]]; then + # if key does not exist in mirth.properties append it at bottom + LINE_COUNT=`grep "^${KEY}" "$APP_DIR/conf/mirth.properties" | wc -l` + if [ $LINE_COUNT -lt 1 ]; then + # echo "key ${KEY} not found in mirth.properties, appending. Value = ${VALUE}" + echo -e "${KEY} = ${VALUE//\//\\/}" >> "$APP_DIR/conf/mirth.properties" + else # otherwise key exists, overwrite it + # echo "key ${KEY} exists, overwriting. Value = ${VALUE}" + ESCAPED_KEY="${KEY//./\\.}" + sed -i "s/^${ESCAPED_KEY}\s*=\s*.*\$/${KEY} = ${VALUE//\//\\/}/" "$APP_DIR/conf/mirth.properties" + fi + fi + done <<< "`cat /run/secrets/mirth_properties`" +fi + +# merge the user's secret vmoptions +# takes a whole oieserver.vmoptions file and merges line by line with /opt/engine/oieserver.vmoptions +if [ -f /run/secrets/oieserver_vmoptions ]; then + (cat /run/secrets/oieserver_vmoptions ; echo "") >> "$APP_DIR/oieserver.vmoptions" +fi + +# download jars from this url "$CUSTOM_JARS_DOWNLOAD", set by user +if ! [ -z "${CUSTOM_JARS_DOWNLOAD+x}" ]; then + echo "Downloading Jars at ${CUSTOM_JARS_DOWNLOAD}" + if ! [ -z "${ALLOW_INSECURE}" ] && [ "${ALLOW_INSECURE}" == "true" ]; then + curl -ksSLf "${CUSTOM_JARS_DOWNLOAD}" -o userJars.zip || echo "problem with custom jars download" + else + curl -sSLf "${CUSTOM_JARS_DOWNLOAD}" -o userJars.zip || echo "problem with custom jars download" + fi + + # Unzipping contents of userJars.zip into /opt/engine/server-launcher-lib folder + if [ -e "userJars.zip" ]; then + echo "Unzipping contents of userJars.zip into $APP_DIR/server-launcher-lib" + unzip userJars.zip -d "$APP_DIR/server-launcher-lib" + # removing the downloaded zip file + rm userJars.zip + fi +fi + +# download extensions from this url "$EXTENSIONS_DOWNLOAD", set by user +if ! [ -z "${EXTENSIONS_DOWNLOAD+x}" ]; then + echo "Downloading extensions at ${EXTENSIONS_DOWNLOAD}" + if ! [ -z "${ALLOW_INSECURE}" ] && [ "${ALLOW_INSECURE}" == "true" ]; then + curl -ksSLf "${EXTENSIONS_DOWNLOAD}" -o userExtensions.zip || echo "problem with extensions download" + else + curl -sSLf "${EXTENSIONS_DOWNLOAD}" -o userExtensions.zip || echo "problem with extensions download" + fi + + # Unzipping contents of userExtensions.zip + if [ -e "userExtensions.zip" ]; then + echo "Unzipping contents of userExtensions.zip" + mkdir /tmp/userextensions + unzip userExtensions.zip -d /tmp/userextensions + # removing the downloaded zip file + rm userExtensions.zip + + # Unzipping contents of individual extension zip files into /opt/engine/extensions folder + zipFileCount=`ls -1 /tmp/userextensions/*.zip 2>/dev/null | wc -l` + if [ $zipFileCount != 0 ]; then + echo "Unzipping contents of /tmp/userextensions/ zips into $APP_DIR/extensions" + for f in /tmp/userextensions/*.zip; do unzip "$f" -d "$APP_DIR/extensions"; done + fi + # removing the tmp folder + rm -rf /tmp/userextensions + fi +fi + +# download keystore +if ! [ -z "${KEYSTORE_DOWNLOAD+x}" ]; then + echo "Downloading keystore at ${KEYSTORE_DOWNLOAD}" + if ! [ -z "${ALLOW_INSECURE}" ] && [ "${ALLOW_INSECURE}" == "true" ]; then + curl -ksSLf "${KEYSTORE_DOWNLOAD}" -o "$APP_DIR/appdata/keystore.jks" || echo "problem with keystore download" + else + curl -sSLf "${KEYSTORE_DOWNLOAD}" -o "$APP_DIR/appdata/keystore.jks" || echo "problem with keystore download" + fi +fi + +# if delay is set as an environment variable then wait that long in seconds +if ! [ -z "${DELAY+x}" ]; then + sleep $DELAY +fi + +exec "$@" diff --git a/releases.yaml b/releases.yaml new file mode 100644 index 0000000..bcf4eb1 --- /dev/null +++ b/releases.yaml @@ -0,0 +1,57 @@ +# Specifies which slug should gain the "latest" tags +latest: 4.6.0 + +# Sets the alpine image tag for the downloader stage +downloaderTag: 3.24.1 + +# Owner of /opt/engine and the engine user. The Ubuntu images reuse the base image's "ubuntu" user, +# which is 1000:1000, so changing these values will not change the Ubuntu user. +uid: 1000 +gid: 1000 + +# Add OCI best-practice labels https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys +labels: |- + "org.opencontainers.image.authors"="The Open Integration Engine Project and contributors" \ + "org.opencontainers.image.created"="${CREATED_AT?:}" \ + "org.opencontainers.image.description"="An open source fork of the now closed-source Mirth Connect" \ + "org.opencontainers.image.licenses"="MPL-2.0" \ + "org.opencontainers.image.source"="https://github.com/OpenIntegrationEngine/engine-docker" \ + "org.opencontainers.image.title"="Open Integration Engine" \ + "org.opencontainers.image.url"="https://github.com/OpenIntegrationEngine/engine" \ + "org.opencontainers.image.vendor"="The Open Integration Engine Project" \ + "org.opencontainers.image.version"="{{ .slug }}" + +versions: + - slug: 4.6.0 + releaseVersion: 4.6.0 + releaseUrl: https://github.com/OpenIntegrationEngine/engine/releases/download/v4.6.0/oie_unix_4_6_0.tar.gz + tags: + - distro: ubuntu + type: jre + tag: 21.0.11_10-jre-resolute + - distro: ubuntu + type: jdk + tag: 21.0.11_10-jdk-resolute + - distro: alpine + type: jre + tag: 21.0.11_10-jre-alpine + - distro: alpine + type: jdk + tag: 21.0.11_10-jdk-alpine + + - slug: 4.5.2 + releaseVersion: 4.5.2 + releaseUrl: https://github.com/OpenIntegrationEngine/engine/releases/download/v4.5.2/oie_unix_4_5_2.tar.gz + tags: + - distro: ubuntu + type: jre + tag: 17.0.20.1_1-jre-noble + - distro: ubuntu + type: jdk + tag: 17.0.20.1_1-jdk-noble + - distro: alpine + type: jre + tag: 17.0.20.1_1-jre-alpine + - distro: alpine + type: jdk + tag: 17.0.20.1_1-jdk-alpine diff --git a/render_docker_templates.sh b/render_docker_templates.sh new file mode 100755 index 0000000..6b2d2da --- /dev/null +++ b/render_docker_templates.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: MPL-2.0 +# + +set -e + +cd "$(dirname "$0")" + +# Start from an empty output directory so versions removed from releases.yaml are deleted +rm -rf dockerfiles + +# Render Dockerfiles +gomplate -V -c .=releases.yaml -f templates/Dockerfile.tpl + +# Render compose files +gomplate -V -c .=releases.yaml -f templates/compose.yaml.tpl + +# Copy the entrypoint script into each rendered version directory +for dir in dockerfiles/*/; do + cp -p templates/entrypoint.sh "$dir" +done diff --git a/templates/Dockerfile.tpl b/templates/Dockerfile.tpl new file mode 100644 index 0000000..4f43d32 --- /dev/null +++ b/templates/Dockerfile.tpl @@ -0,0 +1,82 @@ +{{/* Collect all root elements except "versions" into a variable */}} +{{- $config := coll.Omit "versions" . -}} + +{{/* Create gomplate specific iteration over versions array */}} +{{- range $version := .versions -}} + {{- $ctx := dict "config" $config "version" $version }} + + {{/* Define paths to render the Dockerfiles to */}} + {{- $outPath := printf "dockerfiles/%s/Dockerfile" $version.slug }} + + {{/* Render the inline template defined below */}} + {{- tmpl.Exec "dockerfile" $ctx | file.Write $outPath }} +{{- end -}} + +{{- define "dockerfile" -}} +# syntax=docker/dockerfile:1 + +################################################################ +# # +# WARNING: THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY # +# # +################################################################ + +ARG CREATED_AT + +FROM alpine:{{ .config.downloaderTag }} AS downloader + +WORKDIR /opt + +# Download Open Integration Engine release +RUN apk add --no-cache curl \ + && curl -L \ + -o /opt/engine.tar.gz \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + {{ .version.releaseUrl }} \ + && tar xzf engine.tar.gz \ + && mv /opt/oie /opt/engine \ + && mkdir -p /opt/engine/appdata + +WORKDIR /opt/engine +COPY --chmod=755 entrypoint.sh /opt/engine/entrypoint.sh + +RUN rm -rf cli-lib manager-lib \ + && rm mirth-cli-launcher.jar oiecommand +{{/* Assign current version slug into a variable to carry it into the tags iteration */}} +{{- $slug := dict "slug" .version.slug -}} +{{/* Iterate version tags to generate the final stages */}} +{{- range .version.tags }} +FROM eclipse-temurin:{{ .tag }} AS {{ print .distro "-" .type }} + +ARG CREATED_AT + +LABEL \ +{{/* Render the Labels section to include the slug */}} +{{- tpl $.config.labels $slug | strings.Indent 2 }} + +COPY --from=downloader --chown={{ $.config.uid }}:{{ $.config.gid }} /opt/engine /opt/engine +{{ if eq .distro "ubuntu" }} +RUN apt-get update \ + && apt-get install -y unzip \ + && rm -rf /var/lib/apt/lists/* \ + && groupmod --new-name engine ubuntu \ + && usermod -l engine ubuntu \ + && usermod -G '' engine +{{- else if eq .distro "alpine" }} +RUN apk add --no-cache bash unzip \ + && adduser -D -H -u {{ $.config.uid }} engine engine +{{- end }} + +VOLUME /opt/engine/appdata +VOLUME /opt/engine/custom-extensions + +WORKDIR /opt/engine +EXPOSE 8443 +USER engine + +ENTRYPOINT ["./entrypoint.sh"] +CMD ["./oieserver"] +{{ end -}} + +{{ end }} diff --git a/templates/compose.yaml.tpl b/templates/compose.yaml.tpl new file mode 100644 index 0000000..8cc89a5 --- /dev/null +++ b/templates/compose.yaml.tpl @@ -0,0 +1,50 @@ +{{/* Create gomplate specific iteration over versions array */}} +{{- range $version := .versions -}} + {{- $ctx := dict "latest" $.latest "version" $version }} + + {{/* Define paths to render the Dockerfiles to */}} + {{- $outPath := printf "dockerfiles/%s/compose.yaml" $version.slug }} + + {{/* Render the inline template defined below */}} + {{- tmpl.Exec "composefile" $ctx | file.Write $outPath }} +{{- end -}} + +{{- define "composefile" -}} +################################################################ +# # +# WARNING: THIS FILE IS AUTO-GENERATED. DO NOT EDIT MANUALLY # +# # +################################################################ + +name: open-integration-engine + +{{/* Assign current version slug into a variable to carry it into the tags iteration */}} +{{- $slug := .version.slug -}} +services: +{{- range $i, $tag := .version.tags }} +{{- if $i }} +{{ end }} + {{ .distro }}-{{ .type }}: + image: openintegrationengine/engine + build: + target: {{ .distro }}-{{ .type }} + context: . + platforms: + - linux/amd64 + - linux/arm64 + tags: + {{- if eq .type "jre" }} + - openintegrationengine/engine:{{ $slug }}-{{ .distro }} + {{- end }} + - openintegrationengine/engine:{{ $slug }}-{{ .distro }}-{{ .type }} + {{- if eq $slug $.latest }} + - openintegrationengine/engine:latest-{{ .distro }}-{{ .type }} + {{- if eq .type "jre" }} + - openintegrationengine/engine:latest-{{ .distro }} + {{- if eq .distro "alpine" }} + - openintegrationengine/engine:latest + {{- end }} + {{- end }} + {{- end }} +{{- end }} +{{ end }} diff --git a/templates/entrypoint.sh b/templates/entrypoint.sh new file mode 100755 index 0000000..285d501 --- /dev/null +++ b/templates/entrypoint.sh @@ -0,0 +1,245 @@ +#!/usr/bin/env bash +# +# SPDX-License-Identifier: MPL-2.0 +# SPDX-FileCopyrightText: 2023 NextGen Healthcare +# SPDX-FileCopyrightText: 2025 Kaur Palang +# + +set -e + +APP_DIR=/opt/engine + +custom_extension_count=`ls -1 "$APP_DIR"/custom-extensions/*.zip 2>/dev/null | wc -l` +if [ $custom_extension_count != 0 ]; then + echo "Found ${custom_extension_count} custom extensions." + for extension in $(ls -1 "$APP_DIR"/custom-extensions/*.zip); do + unzip -o -q $extension -d "$APP_DIR/extensions" + done +fi + +# set storepass and keypass to 'changeme' so they aren't overwritten later +KEYSTORE_PASS=changeme +sed -i "s/^keystore\.storepass\s*=\s*.*\$/keystore.storepass = ${KEYSTORE_PASS//\//\\/}/" "$APP_DIR/conf/mirth.properties" +sed -i "s/^keystore\.keypass\s*=\s*.*\$/keystore.keypass = ${KEYSTORE_PASS//\//\\/}/" "$APP_DIR/conf/mirth.properties" + +# merge the environment variables into /opt/engine/conf/mirth.properties +# db type +if ! [ -z "${DATABASE+x}" ]; then + sed -i "s/^database\s*=\s*.*\$/database = ${DATABASE//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# db username +if ! [ -z "${DATABASE_USERNAME+x}" ]; then + sed -i "s/^database\.username\s*=\s*.*\$/database.username = ${DATABASE_USERNAME//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# db password +if ! [ -z "${DATABASE_PASSWORD+x}" ]; then + sed -i "s/^database\.password\s*=\s*.*\$/database.password = ${DATABASE_PASSWORD//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# db url +if ! [ -z "${DATABASE_URL+x}" ]; then + sed -i "s/^database\.url\s*=\s*.*\$/database.url = ${DATABASE_URL//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# database max connections +if ! [ -z "${DATABASE_MAX_CONNECTIONS+x}" ]; then + sed -i "s/^database\.max-connections\s*=\s*.*\$/database.max-connections = ${DATABASE_MAX_CONNECTIONS//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# database max retries +if ! [ -z "${DATABASE_MAX_RETRY+x}" ]; then + sed -i "s/^database\.connection\.maxretry\s*=\s*.*\$/database.connection.maxretry = ${DATABASE_MAX_RETRY//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# database retry wait time +if ! [ -z "${DATABASE_RETRY_WAIT+x}" ]; then + sed -i "s/^database\.connection\.retrywaitinmilliseconds\s*=\s*.*\$/database.connection.retrywaitinmilliseconds = ${DATABASE_RETRY_WAIT//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# keystore storepass +if ! [ -z "${KEYSTORE_STOREPASS+x}" ]; then + sed -i "s/^keystore\.storepass\s*=\s*.*\$/keystore.storepass = ${KEYSTORE_STOREPASS//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# keystore keypass +if ! [ -z "${KEYSTORE_KEYPASS+x}" ]; then + sed -i "s/^keystore\.keypass\s*=\s*.*\$/keystore.keypass = ${KEYSTORE_KEYPASS//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +if ! [ -z "${KEYSTORE_TYPE+x}" ]; then + sed -i "s/^keystore\.type\s*=\s*.*\$/keystore.type = ${KEYSTORE_TYPE//\//\\/}/" "$APP_DIR/conf/mirth.properties" +fi + +# session store +if ! [ -z "${SESSION_STORE+x}" ]; then + LINE_COUNT=`grep "server.api.sessionstore" "$APP_DIR/conf/mirth.properties" | wc -l` + if [ $LINE_COUNT -lt 1 ]; then + echo -e "\nserver.api.sessionstore = ${SESSION_STORE//\//\\/}" >> "$APP_DIR/conf/mirth.properties" + else + sed -i "s/^server\.api\.sessionstore\s*=\s*.*\$/server.api.sessionstore = ${SESSION_STORE//\//\\/}/" "$APP_DIR/conf/mirth.properties" + fi +fi + +#server ID +if ! [ -z "${SERVER_ID+x}" ]; then + echo -e "server.id = ${SERVER_ID//\//\\/}" > "$APP_DIR/appdata/server.id" +fi + +# merge extra environment variables starting with _MP_ into mirth.properties +while read -r keyvalue; do + KEY="${keyvalue%%=*}" + VALUE="${keyvalue#*=}" + VALUE=$(tr -dc '\40-\176' <<< "$VALUE") + + if ! [ -z "${KEY}" ] && ! [ -z "${VALUE}" ] && ! [[ ${VALUE} =~ ^\ +$ ]]; then + + # filter for variables starting with "_MP_" + if [[ ${KEY} == _MP_* ]]; then + + # echo "found property ${KEY}=${VALUE}" + + # example: _MP_DATABASE_MAX__CONNECTIONS -> database.max-connections + + # remove _MP_ + # example: DATABASE_MAX__CONNECTIONS + ACTUAL_KEY=${KEY:4} + + # switch '__' to '-' + # example: DATABASE_MAX-CONNECTIONS + ACTUAL_KEY="${ACTUAL_KEY//__/-}" + + # switch '_' to '.' + # example: DATABASE.MAX-CONNECTIONS + ACTUAL_KEY="${ACTUAL_KEY//_/.}" + + # lower case + # example: database.max-connections + ACTUAL_KEY="${ACTUAL_KEY,,}" + + # if key does not exist in mirth.properties append it at bottom + LINE_COUNT=`grep "^${ACTUAL_KEY}" "$APP_DIR/conf/mirth.properties" | wc -l` + if [ $LINE_COUNT -lt 1 ]; then + # echo "key ${ACTUAL_KEY} not found in mirth.properties, appending. Value = ${VALUE}" + echo -e "\n${ACTUAL_KEY} = ${VALUE//\//\\/}" >> "$APP_DIR/conf/mirth.properties" + else # otherwise key exists, overwrite it + # echo "key ${ACTUAL_KEY} exists, overwriting. Value = ${VALUE}" + ESCAPED_KEY="${ACTUAL_KEY//./\\.}" + sed -i "s/^${ESCAPED_KEY}\s*=\s*.*\$/${ACTUAL_KEY} = ${VALUE//\//\\/}/" "$APP_DIR/conf/mirth.properties" + fi + fi + fi +done <<< "`printenv`" + +# merge vmoptions into /opt/engine/oieserver.vmoptions +if ! [ -z "${VMOPTIONS+x}" ]; then + PREV_IFS="$IFS" + IFS="," + read -ra vmoptions <<< "$VMOPTIONS" + IFS="$PREV_IFS" + + for vmoption in "${vmoptions[@]}" + do + echo "${vmoption}" >> "$APP_DIR/oieserver.vmoptions" + done +fi + +# merge the user's secret mirth.properties +# takes a whole mirth.properties file and merges line by line with /opt/engine/conf/mirth.properties +if [ -f /run/secrets/mirth_properties ]; then + + # add new line in case /opt/engine/conf/mirth.properties doesn't end with one + echo "" >> "$APP_DIR/conf/mirth.properties" + + while read -r keyvalue; do + KEY="${keyvalue%%=*}" + VALUE="${keyvalue#*=}" + + # remove leading and trailing white space + KEY="$(echo -e "${KEY}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + VALUE="$(echo -e "${VALUE}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" + + if ! [ -z "${KEY}" ] && ! [ -z "${VALUE}" ] && ! [[ ${VALUE} =~ ^\ +$ ]]; then + # if key does not exist in mirth.properties append it at bottom + LINE_COUNT=`grep "^${KEY}" "$APP_DIR/conf/mirth.properties" | wc -l` + if [ $LINE_COUNT -lt 1 ]; then + # echo "key ${KEY} not found in mirth.properties, appending. Value = ${VALUE}" + echo -e "${KEY} = ${VALUE//\//\\/}" >> "$APP_DIR/conf/mirth.properties" + else # otherwise key exists, overwrite it + # echo "key ${KEY} exists, overwriting. Value = ${VALUE}" + ESCAPED_KEY="${KEY//./\\.}" + sed -i "s/^${ESCAPED_KEY}\s*=\s*.*\$/${KEY} = ${VALUE//\//\\/}/" "$APP_DIR/conf/mirth.properties" + fi + fi + done <<< "`cat /run/secrets/mirth_properties`" +fi + +# merge the user's secret vmoptions +# takes a whole oieserver.vmoptions file and merges line by line with /opt/engine/oieserver.vmoptions +if [ -f /run/secrets/oieserver_vmoptions ]; then + (cat /run/secrets/oieserver_vmoptions ; echo "") >> "$APP_DIR/oieserver.vmoptions" +fi + +# download jars from this url "$CUSTOM_JARS_DOWNLOAD", set by user +if ! [ -z "${CUSTOM_JARS_DOWNLOAD+x}" ]; then + echo "Downloading Jars at ${CUSTOM_JARS_DOWNLOAD}" + if ! [ -z "${ALLOW_INSECURE}" ] && [ "${ALLOW_INSECURE}" == "true" ]; then + curl -ksSLf "${CUSTOM_JARS_DOWNLOAD}" -o userJars.zip || echo "problem with custom jars download" + else + curl -sSLf "${CUSTOM_JARS_DOWNLOAD}" -o userJars.zip || echo "problem with custom jars download" + fi + + # Unzipping contents of userJars.zip into /opt/engine/server-launcher-lib folder + if [ -e "userJars.zip" ]; then + echo "Unzipping contents of userJars.zip into $APP_DIR/server-launcher-lib" + unzip userJars.zip -d "$APP_DIR/server-launcher-lib" + # removing the downloaded zip file + rm userJars.zip + fi +fi + +# download extensions from this url "$EXTENSIONS_DOWNLOAD", set by user +if ! [ -z "${EXTENSIONS_DOWNLOAD+x}" ]; then + echo "Downloading extensions at ${EXTENSIONS_DOWNLOAD}" + if ! [ -z "${ALLOW_INSECURE}" ] && [ "${ALLOW_INSECURE}" == "true" ]; then + curl -ksSLf "${EXTENSIONS_DOWNLOAD}" -o userExtensions.zip || echo "problem with extensions download" + else + curl -sSLf "${EXTENSIONS_DOWNLOAD}" -o userExtensions.zip || echo "problem with extensions download" + fi + + # Unzipping contents of userExtensions.zip + if [ -e "userExtensions.zip" ]; then + echo "Unzipping contents of userExtensions.zip" + mkdir /tmp/userextensions + unzip userExtensions.zip -d /tmp/userextensions + # removing the downloaded zip file + rm userExtensions.zip + + # Unzipping contents of individual extension zip files into /opt/engine/extensions folder + zipFileCount=`ls -1 /tmp/userextensions/*.zip 2>/dev/null | wc -l` + if [ $zipFileCount != 0 ]; then + echo "Unzipping contents of /tmp/userextensions/ zips into $APP_DIR/extensions" + for f in /tmp/userextensions/*.zip; do unzip "$f" -d "$APP_DIR/extensions"; done + fi + # removing the tmp folder + rm -rf /tmp/userextensions + fi +fi + +# download keystore +if ! [ -z "${KEYSTORE_DOWNLOAD+x}" ]; then + echo "Downloading keystore at ${KEYSTORE_DOWNLOAD}" + if ! [ -z "${ALLOW_INSECURE}" ] && [ "${ALLOW_INSECURE}" == "true" ]; then + curl -ksSLf "${KEYSTORE_DOWNLOAD}" -o "$APP_DIR/appdata/keystore.jks" || echo "problem with keystore download" + else + curl -sSLf "${KEYSTORE_DOWNLOAD}" -o "$APP_DIR/appdata/keystore.jks" || echo "problem with keystore download" + fi +fi + +# if delay is set as an environment variable then wait that long in seconds +if ! [ -z "${DELAY+x}" ]; then + sleep $DELAY +fi + +exec "$@"