From 129e7ebc6370efaf072a91a0bd1047c28aa88212 Mon Sep 17 00:00:00 2001 From: dakirily Date: Tue, 24 Oct 2023 10:49:24 +0200 Subject: [PATCH] QPID-8352: [Broker-J] Official Docker image for Broker-J --- .../src/docbkx/Java-Broker-Docker.xml | 122 +------- pom.xml | 8 +- qpid-docker/README.md | 274 ++++++++++++++---- qpid-docker/pom.xml | 112 ++++++- .../src/main/assembly/bdb-amqp-0-10.xml | 1 - .../src/main/assembly/bdb-amqp-0-8.xml | 1 - .../src/main/assembly/bdb-amqp-1-0.xml | 1 - .../src/main/assembly/bdb-amqp-all.xml | 1 - .../src/main/assembly/derby-amqp-0-10.xml | 1 - .../src/main/assembly/derby-amqp-0-8.xml | 1 - .../src/main/assembly/derby-amqp-1-0.xml | 1 - .../src/main/assembly/derby-amqp-all.xml | 1 - ...tgres-amqp-0-10.xml => jdbc-amqp-0-10.xml} | 11 +- ...ostgres-amqp-0-8.xml => jdbc-amqp-0-8.xml} | 11 +- ...ostgres-amqp-1-0.xml => jdbc-amqp-1-0.xml} | 11 +- ...ostgres-amqp-all.xml => jdbc-amqp-all.xml} | 11 +- .../src/main/assembly/memory-amqp-0-10.xml | 1 - .../src/main/assembly/memory-amqp-0-8.xml | 1 - .../src/main/assembly/memory-amqp-1-0.xml | 1 - .../src/main/assembly/memory-amqp-all.xml | 1 - qpid-docker/src/main/docker/Containerfile | 55 +--- qpid-docker/src/main/docker/Containerfile-dev | 153 ++++++++++ ...efault-postgres.json => default-jdbc.json} | 2 +- .../src/main/docker/examples/default.json | 47 +++ 24 files changed, 560 insertions(+), 269 deletions(-) rename qpid-docker/src/main/assembly/{postgres-amqp-0-10.xml => jdbc-amqp-0-10.xml} (89%) rename qpid-docker/src/main/assembly/{postgres-amqp-0-8.xml => jdbc-amqp-0-8.xml} (89%) rename qpid-docker/src/main/assembly/{postgres-amqp-1-0.xml => jdbc-amqp-1-0.xml} (89%) rename qpid-docker/src/main/assembly/{postgres-amqp-all.xml => jdbc-amqp-all.xml} (88%) create mode 100644 qpid-docker/src/main/docker/Containerfile-dev rename qpid-docker/src/main/docker/{default-postgres.json => default-jdbc.json} (81%) create mode 100644 qpid-docker/src/main/docker/examples/default.json diff --git a/doc/java-broker/src/docbkx/Java-Broker-Docker.xml b/doc/java-broker/src/docbkx/Java-Broker-Docker.xml index 280cde9380..100d3ab2c0 100644 --- a/doc/java-broker/src/docbkx/Java-Broker-Docker.xml +++ b/doc/java-broker/src/docbkx/Java-Broker-Docker.xml @@ -27,22 +27,12 @@ Docker Images Types - Broker currently supports 4 types of storages: - - BDB - Derby - JDBC - Memory - - - - Broker storage type "Memory" don't provide persistent storage (all messages are kept in memory), - meaning that after container restart all the messages as well as the created broker objects will be gone. + By default broker images is built with BDB message storage. Container image has the following structure: - qpid-broker-j-<OS_NAME>-<JRE_VERSION>-<STORAGE_TYPE>-<AMQP_VERSION> + qpid-broker-j-<OS_NAME> OS_NAME can have values: alpine, centos7, ubi9, ubuntu JRE_VERSION can have values: 11, 17, 21 STORAGE_TYPE can have values: bdb, derby, memory, postgres @@ -59,60 +49,7 @@ Container Start - Container can be started using following command: - - - - - docker run -d -p 5672:5672 -p 8080:8080 --name qpid-broker-j <IMAGE_NAME> - - - - - There are two ports exposed: 5672 for AMQP connections and 8080 for HTTP connections. - - - - There are following environment variables available when running the container: - - - - Environment Variables - - - - - - Environment Variable - Description - - - - - JAVA_GC - JVM Garbage Collector parameters, default value "-XX:+UseG1GC" - - - JAVA_MEM - JVM memory parameters, default value "-Xmx300m -XX:MaxDirectMemorySize=200m" - - - JAVA_OPTS - Further JVM parameters, default value for memory storage "-Dqpid.tests.mms.messagestore.persistence=true", for other storage types default value is an empty string - - - -
- - - -
- - Persistent Volume - - - When using Memory broker storage, all broker configuration and messages are stored in memory and are lost with the - container restart. When using BDB or Derby broker storage, before starting the container a volume should be created: + Before starting the container a volume should be created: @@ -142,22 +79,15 @@ - In such way both broker configuration files and messages will be persisted in container volume and will survive - the container restart. + There are two ports exposed: 5672 for AMQP connections and 8080 for HTTP connections. -
- -
- - Database Connection - - Following environment variables can be used to configure database connection: + There are following environment variables available when running the container: - Database Connection Environment Variables + Environment Variables @@ -169,49 +99,21 @@ - DB_HOSTNAME - Database hostname - - - DB_PORT - Database port - - - DB_NAME - Database name + JAVA_GC + JVM Garbage Collector parameters, default value "-XX:+UseG1GC" - DB_USERNAME - Database username + JAVA_MEM + JVM memory parameters, default value "-Xmx300m -XX:MaxDirectMemorySize=200m" - DB_PASSWORD - Database password + JAVA_OPTS + Further JVM parameters, default value is an empty string
- - Example: - - - - - docker volume create --driver local --opt device=<PATH_TO_FOLDER> --opt type=none --opt o=bind qpid_volume - - - - - docker run -d -p 5672:5672 -p 8080:8080 -v qpid_volume:/qpid-broker-j/work --name qpid -e DB_HOSTNAME=127.0.0.1 -e DB_PORT=5432 -e DB_NAME=qpid -e DB_USERNAME=qpid -e DB_PASSWORD=admin <IMAGE_NAME> - - - - - In this case broker configuration files are persisted in the volume "qpid_volume" and messages are stored in database - configured by the appropriate environment variables. - -
diff --git a/pom.xml b/pom.xml index d7ca84c87f..94a9d5b8f2 100644 --- a/pom.xml +++ b/pom.xml @@ -104,7 +104,6 @@ 7.4.5 10.14.2.0 - 42.6.0 1.4.11 1.2.11.1 32.1.2-jre @@ -559,11 +558,6 @@ derby ${derby-version} - - org.postgresql - postgresql - ${postgres-version} - ch.qos.logback logback-classic @@ -1697,7 +1691,7 @@ Apache Software License, Version 2.0|The Apache Software License, Version 2.0|Apache Software License - Version 2.0|Apache v2|Apache 2|Apache License, Version 2.0|Apache 2.0|Apache Public License 2.0|Apache License, version 2.0|Apache License 2.0|The Apache License, Version 2.0|Apache 2.0 License|Apache-2.0 The MIT License|MIT License|MIT license - BSD License|New BSD|New BSD License|BSD 3-Clause|BSD-3-Clause|BSD Licence 3|BSD License 3|The BSD License|BSD-2-Clause + BSD License|New BSD|New BSD License|BSD 3-Clause|BSD-3-Clause|BSD Licence 3|BSD License 3|The BSD License Eclipse Public License - Version 1.0|Eclipse Public License - v 1.0|Eclipse Public License, Version 1.0|Eclipse Public License 1.0|MPL 2.0 or EPL 1.0 Eclipse Public License - Version 2.0|Eclipse Public License - v 2.0|Eclipse Public License, Version 2.0|Eclipse Public License 2.0|Eclipse Public License v2.0|MPL 2.0 or EPL 2.0|EPL 2.0 Academic Free License v2.1|AFL-2.1 diff --git a/qpid-docker/README.md b/qpid-docker/README.md index 43808fbfde..c7af5dd89d 100644 --- a/qpid-docker/README.md +++ b/qpid-docker/README.md @@ -2,14 +2,13 @@ This is an example on how a Docker Image For Apache Qpid Broker-J based on Eclipse Temurin JRE image can be created. -## Building +## Building Container Image Build the parent project using command ``` mvn clean install -DskipTests=true ``` - Navigate to the module 'qpid-docker'. Execute command @@ -17,18 +16,25 @@ Execute command ``` mvn clean deploy -DskipTests=true -Ppublish-container ``` -By default, there will be produced container image using Linux Alpine, JRE 17 supporting all AMQP protocol version. +By default, there will be produced container image using Linux Alpine and BDB as the message storage running on JRE 11 +and supporting all AMQP protocol versions. + +Operational system for the container image can be customized using system property "os-name": currently it's possibly to +supply values "alpine", "centos7" and "ubuntu". -Resulting container image can be customized using additional system properties. +Resulting image uses a volume mapped to the folder /qpid-broker-j/work inside the container. This folder contains broker +configuration files as well as the BDB message storage. -Following additional system properties can be used: +### System Properties + +Following system properties are used to configure build process: | Context Property Name | Description | |-----------------------|-------------------------------------------------------------------------------------| | container-registry | Container registry, e.g. docker.io/library | | image-name | OCI image name | | jre-version | JRE version, currently supported: 11, 17, 21 | -| broker-storage | Broker storage type, currently supported: bdb, derby, memory, postgres | +| broker-storage | Broker storage type, currently supported: bdb, derby, jdbc, memory | | amqp-version | AMQP protocol version, currently supported: amqp-all, amqp-1-0, amqp-0-10, amqp-0-8 | | os-name | Operational System, currently supported: alpine, centos7, ubi9, ubuntu | | https.proxyHost | HTTPS proxy hostname (when running behind the proxy) | @@ -39,30 +45,22 @@ Following additional system properties can be used: Command ``` -mvn clean deploy -DskipTests=true -Ppublish-container -Djre-version=17 -Dbroker-storage=memory -Damqp-version=amqp-1-0 +mvn clean deploy -Ppublish-container ``` -produces an image with name 'qpid-broker-j-jre17-memory-amqp-1-0', which is based on Eclipse Temurin JRE 17, has Memory -broker storage type and supports AMQP protocol version 1.0. +produces an image with name 'qpid-broker-j-alpine'. Command ``` -mvn clean deploy -DskipTests=true -Ppublish-container -Djre-version=11 -Dbroker-storage=memory -Damqp-version=amqp-0-10 +mvn clean deploy -Ppublish-container -Dos-name=centos7 ``` -produces an image with name 'qpid-broker-j-jre11-memory-amqp-0-10', which is based on Eclipse Temurin JRE 11, has Memory -broker storage type and supports AMQP protocol version 0.10. +produces an image with name 'qpid-broker-j-centos7'. -Command -``` -mvn clean deploy -DskipTests=true -Ppublish-container -Djre-version=11 -Dbroker-storage=memory -Damqp-version=amqp-0-8 -``` -produces an image with name 'qpid-broker-j-jre11-memory-amqp-0-10', which is based on Eclipse Temurin JRE 11, has Memory -broker storage type and supports AMQP protocol version 0.8. -### Running with Podman +### Building container with Podman When execution commands with podman instead of docker, environment variable "platform" should be set: ``` -mvn clean deploy -Dplatform=podman -Ppublish-container -Djre-version=11 -Dbroker-storage=memory -Damqp-version=amqp-all +mvn clean deploy -Ppublish-container -Dplatform=podman ``` ### Container Registry Authentication @@ -81,7 +79,6 @@ podman login -u Broker-J files are copied to the folder /qpid-broker-j \ This folder belongs to user qpid, which is part of the root group. Java process is executed under the qpid user as well. -This is done to make it possible to run container images in OpenShift environment as well. ### Running the Container @@ -97,22 +94,149 @@ There are following environment variables available when running the container: |----------------------|------------------------------------------------------------------------------| | JAVA_GC | JVM Garbage Collector parameters, default value "-XX:+UseG1GC" | | JAVA_MEM | JVM memory parameters, default value "-Xmx300m -XX:MaxDirectMemorySize=200m" | -| JAVA_OPTS | Further JVM parameters | +| JAVA_OPTS | Further JVM parameters, empty by default | + +#### Container Volume + +Before starting the container a volume should be created: + +``` +docker volume create --driver local --opt device= --opt type=none --opt o=bind qpid_volume +``` + +Then container using created volume can be started as follows: + + +``` +docker run -d -p 5672:5672 -p 8080:8080 -v qpid_volume:/qpid-broker-j/work --name qpid +``` +or +``` +podman run -d -p 5672:5672 -p 8080:8080 -v qpid_volume:/qpid-broker-j/work:Z --name qpid +``` +When container is started for the first time, configuration files become available in the mapped folder being persisted +after subsequent restarts. + +### Broker Users + +Default configuration provides two preconfigured broker users: +- admin (password 'admin') +- guest (password 'guest') -Default JAVA_OPTS are empty for all storage types except the memory store which has the default value '-Dqpid.tests.mms.messagestore.persistence=true' +User 'admin' has read and write access to all broker objects. +User 'guest' has read-only access to all broker objects, can not send or consume messages. + +Further broker users as well as other broker objects (queues, exchanges, keystores, truststore, ports etc.) +can be created via HTTP management interface. Description of the broker REST API can be found in broker book (chapter 6.3). + +To change user password following command can be used: + +``` +curl -d '{"password": ""}' http://admin:admin@localhost:8080/api/latest/user/SHA_256/ +``` + +## Broker Customization + +To customize broker before building the container image, its configuration files may be edited to start broker with +queues, exchanges, users or other objects. + +Typically, a file config.json contains definitions of the broker objects and references a file containing definitions +of virtualhost objects (exchanges and queues). + +An example file [default.json](./src/main/docker/examples/default.json) contains a predefined exchange and a queue. + +It may be helpful first to create broker objects needed via broker web GUI or via REST API, and then investigate the +configuration files and copy the appropriate definitions to the configuration files used for container image creation. + +### Exchanges -#### Container Volumes +To create exchanges a JSON element "exchanges" should be created containing an array of single exchange definitions: -When using Memory broker storage, all broker configuration and messages are stored in memory and are lost with the -container restart. +``` +"exchanges" : [ { + "name" : "request.QUEUE1", + "type" : "topic", + "durable" : true, + "durableBindings" : [ { + "arguments" : { }, + "destination" : "QUEUE1", + "bindingKey" : "#" + } ], + "unroutableMessageBehaviour" : "REJECT" + } +] +``` + +Information about exchanges, their types and properties can be found in broker book (chapter 4.6). + +Please note that each virtualhost pre-declares several exchanges, described in the broker book (chapter 4.6.1). -When using BDB or Derby broker storage, before starting the container a volume should be created: +### Queues + +To create queue a JSON element "queues" should be created containing an array of single queue definitions: + +``` +"queues" : [ { + "name" : "QUEUE1", + "type" : "standard", + "durable" : true, + "maximumQueueDepthBytes" : 6144000, + "maximumQueueDepthMessages" : 6000, + "messageDurability" : "ALWAYS", + "overflowPolicy" : "REJECT" + }, { + "name" : "QUEUE2", + "type" : "standard", + "durable" : true, + "maximumQueueDepthBytes" : 6144000, + "maximumQueueDepthMessages" : 6000, + "messageDurability" : "ALWAYS", + "overflowPolicy" : "REJECT" + } +] +``` + +Information about queues, their types and properties can be found in broker book (chapter 4.7). + +## Development Profile + +For development purposes there is additional maven profile "publish-container-dev" supplied. It provides wider +configuration options, allowing to choose broker storage type, AMQP protocol version supported and JRE version: + +| Context Property Name | Description | +|-----------------------|-------------------------------------------------------------------------------------| +| container-registry | Container registry, e.g. docker.io/library | +| image-name | OCI image name | +| jre-version | JRE version, currently supported: 11, 17, 21 | +| broker-storage | Broker storage type, currently supported: bdb, derby, memory, postgres | +| amqp-version | AMQP protocol version, currently supported: amqp-all, amqp-1-0, amqp-0-10, amqp-0-8 | +| os-name | Operational System, currently supported: alpine, centos7, ubuntu | +| https.proxyHost | HTTPS proxy hostname (when running behind the proxy) | +| https.proxyPort | HTTPS proxy port (when running behind the proxy) | +| platform | Container building platform, currently supported: docker, podman | + +### Derby Broker Storage + +In this case broker uses embedded Apache Derby as a message storage: +https://db.apache.org/derby/ + +#### Building Container Image + +To use Apache Derby as a message storage system variable "broker-storage" with the value "derby" should be provided: + +``` +mvn clean deploy -Ppublish-container-dev -Dbroker-storage=derby +``` + +#### Container Volume + +Before starting the container a volume should be created: ``` docker volume create --driver local --opt device= --opt type=none --opt o=bind qpid_volume ``` -Then container using created volume can be started: +Then container using created volume can be started as follows: ``` docker run -d -p 5672:5672 -p 8080:8080 -v qpid_volume:/qpid-broker-j/work --name qpid @@ -121,38 +245,90 @@ or ``` podman run -d -p 5672:5672 -p 8080:8080 -v qpid_volume:/qpid-broker-j/work:Z --name qpid ``` -In such way both broker configuration files and messages will be persisted in container volume and will survive -the container restart. +When container is started for the first time, configuration files become available in the mapped folder being persisted +after subsequent restarts. + +Apache Derby files are stored inside the volume as well. + +### JDBC Broker Storage + +To use JDBC database as a message storage system variable "broker-storage" with the value "jdbc" should be provided. +Additionally one should provide system variables "jdbc-driver" and "jdbc-driver-url": +system variable "jdbc-driver" should contain the name of the JDBC driver used in JDBC connection string, +system variable "jdbc-driver-url" should contain the URL to the JDBC driver jar file to download (broker doesn't include +JDBC driver dependencies, and they should be downloaded separately). + +#### Building Container Image + +For example, to use Postgresql as a message storage following commands can be used: + +``` +export jdbc_driver=postgresql +export jdbc_driver_url= +mvn clean deploy -Ppublish-container-dev -Dbroker-storage=jdbc -Djdbc-driver=$jdbc_driver -Djdbc-driver-url=$jdbc_driver_url +``` -#### Database connection +Alternatively to use MySql as a message storage following commands can be used: + +``` +export jdbc_driver=mysql +export jdbc_driver_url= +mvn clean deploy -Ppublish-container-dev -Dbroker-storage=jdbc -Djdbc-driver=$jdbc_driver -Djdbc-driver-url=$jdbc_driver_url +``` + +#### Running Container Following environment variables can be used to configure database connection: -| Environment Variable | Description | -|------------------------|-------------------| -| DB_HOSTNAME | Database hostname | -| DB_PORT | Database port | -| DB_NAME | Database name | -| DB_USERNAME | Database username | -| DB_PASSWORD | Database password | +| Environment Variable | Description | +|----------------------|----------------------| +| DB_DRIVER | Database driver name | +| DB_HOSTNAME | Database hostname | +| DB_PORT | Database port | +| DB_NAME | Database name | +| DB_USERNAME | Database username | +| DB_PASSWORD | Database password | Example: + ``` docker volume create --driver local --opt device= --opt type=none --opt o=bind qpid_volume -docker run -d -p 5672:5672 -p 8080:8080 -v qpid_volume:/qpid-broker-j/work --name qpid -e DB_HOSTNAME=127.0.0.1 -e DB_PORT=5432 -e DB_NAME=qpid -e DB_USERNAME=qpid -e DB_PASSWORD=admin +docker run -d -p 5672:5672 -p 8080:8080 -v qpid_volume:/qpid-broker-j/work --name qpid -e DB_DRIVER=postgresql -e DB_HOSTNAME=127.0.0.1 -e DB_PORT=5432 -e DB_NAME=qpid -e DB_USERNAME=qpid -e DB_PASSWORD=admin ``` -In this case broker configuration files are persisted in the volume "qpid_volume" and messages are stored in database -configured by the appropriate environment variables. -### Broker Users +### Memory Broker Storage -Container has two preconfigured broker users: -- admin (password 'admin') -- guest (password 'guest') +When using memory as a broker storage, messages are not persisted. When container is restarted, all messages will be lost. +Therefore, it's only advised to use this broker storage type for short-running tasks, e.g. for tests. -User 'admin' has read and write access to all broker objects. -User 'guest' has read-only access to all broker objects, can not send or consume messages. +To allow messages be saved in broker memory storage without additional parameters, system variable JAVA_OPTS has default +value "-Dqpid.tests.mms.messagestore.persistence=true". -Further broker users as well as other broker objects (queues, exchanges, keystores, truststore, ports etc.) -can be created via HTTP management interface. \ No newline at end of file +#### Building Container Image + +To use memory as a message storage system variable "broker-storage" with the value "memory" should be provided: + +``` +mvn clean deploy -Ppublish-container-dev -Dbroker-storage=memory +``` + +#### Container Volume + +Before starting the container a volume should be created: + +``` +docker volume create --driver local --opt device= --opt type=none --opt o=bind qpid_volume +``` + +Then container using created volume can be started as follows: + +``` +docker run -d -p 5672:5672 -p 8080:8080 -v qpid_volume:/qpid-broker-j/work --name qpid +``` +or +``` +podman run -d -p 5672:5672 -p 8080:8080 -v qpid_volume:/qpid-broker-j/work:Z --name qpid +``` +When container is started for the first time, configuration files become available in the mapped folder being persisted +after subsequent restarts. \ No newline at end of file diff --git a/qpid-docker/pom.xml b/qpid-docker/pom.xml index 0ba35ecf89..eebf80b279 100644 --- a/qpid-docker/pom.xml +++ b/qpid-docker/pom.xml @@ -42,28 +42,118 @@ org.apache.qpid qpid-broker - - org.postgresql - postgresql - + + publish-container + + qpid-broker-j-${os-name} + alpine + docker + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + make-assembly + package + + single + + + + src/main/assembly/bdb-amqp-all.xml + + ${project.basedir}/target/docker + gnu + + + + + + org.apache.maven.plugins + maven-antrun-plugin + + + build-container + deploy + + run + + + + + + + + + + + + + + + + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + true + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + - publish-container + publish-container-dev amqp-all - memory - qpid-broker-j-${os-name}-jre${jre-version}-${broker-storage}-${amqp-version} - 17 + bdb + qpid-broker-j-${os-name}-${broker-storage}-${jre-version} + + + 11 alpine docker @@ -105,9 +195,11 @@ - + + + diff --git a/qpid-docker/src/main/assembly/bdb-amqp-0-10.xml b/qpid-docker/src/main/assembly/bdb-amqp-0-10.xml index 5728b21c96..e7e15c13c5 100644 --- a/qpid-docker/src/main/assembly/bdb-amqp-0-10.xml +++ b/qpid-docker/src/main/assembly/bdb-amqp-0-10.xml @@ -64,7 +64,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-store org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/bdb-amqp-0-8.xml b/qpid-docker/src/main/assembly/bdb-amqp-0-8.xml index 921a2baa37..4c94b96f0f 100644 --- a/qpid-docker/src/main/assembly/bdb-amqp-0-8.xml +++ b/qpid-docker/src/main/assembly/bdb-amqp-0-8.xml @@ -64,7 +64,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-store org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/bdb-amqp-1-0.xml b/qpid-docker/src/main/assembly/bdb-amqp-1-0.xml index 3c6a093334..227cf7a30d 100644 --- a/qpid-docker/src/main/assembly/bdb-amqp-1-0.xml +++ b/qpid-docker/src/main/assembly/bdb-amqp-1-0.xml @@ -64,7 +64,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-store org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/bdb-amqp-all.xml b/qpid-docker/src/main/assembly/bdb-amqp-all.xml index f6dc9ea5a2..dd76ec36a1 100644 --- a/qpid-docker/src/main/assembly/bdb-amqp-all.xml +++ b/qpid-docker/src/main/assembly/bdb-amqp-all.xml @@ -59,7 +59,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-store org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/derby-amqp-0-10.xml b/qpid-docker/src/main/assembly/derby-amqp-0-10.xml index 26f39b73c6..887c4fb16a 100644 --- a/qpid-docker/src/main/assembly/derby-amqp-0-10.xml +++ b/qpid-docker/src/main/assembly/derby-amqp-0-10.xml @@ -63,7 +63,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-provider-bone org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/derby-amqp-0-8.xml b/qpid-docker/src/main/assembly/derby-amqp-0-8.xml index 22fc5c6722..16fc0044b3 100644 --- a/qpid-docker/src/main/assembly/derby-amqp-0-8.xml +++ b/qpid-docker/src/main/assembly/derby-amqp-0-8.xml @@ -63,7 +63,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-provider-bone org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/derby-amqp-1-0.xml b/qpid-docker/src/main/assembly/derby-amqp-1-0.xml index 8b77602f54..c0dee3e970 100644 --- a/qpid-docker/src/main/assembly/derby-amqp-1-0.xml +++ b/qpid-docker/src/main/assembly/derby-amqp-1-0.xml @@ -63,7 +63,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-provider-bone org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/derby-amqp-all.xml b/qpid-docker/src/main/assembly/derby-amqp-all.xml index 8f6ec276e7..f3762bb825 100644 --- a/qpid-docker/src/main/assembly/derby-amqp-all.xml +++ b/qpid-docker/src/main/assembly/derby-amqp-all.xml @@ -58,7 +58,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-provider-bone org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/postgres-amqp-0-10.xml b/qpid-docker/src/main/assembly/jdbc-amqp-0-10.xml similarity index 89% rename from qpid-docker/src/main/assembly/postgres-amqp-0-10.xml rename to qpid-docker/src/main/assembly/jdbc-amqp-0-10.xml index e10a1ad55f..67b3e009bd 100644 --- a/qpid-docker/src/main/assembly/postgres-amqp-0-10.xml +++ b/qpid-docker/src/main/assembly/jdbc-amqp-0-10.xml @@ -22,7 +22,7 @@ - postgres-amqp-0-10 + jdbc-amqp-0-10 dir @@ -33,7 +33,7 @@ broker.acl config.json - default-postgres.json + default-jdbc.json preferences.json userPreferences.json @@ -42,13 +42,6 @@ - - /jdbc - false - - org.postgresql:postgresql:jar - - /lib false diff --git a/qpid-docker/src/main/assembly/postgres-amqp-0-8.xml b/qpid-docker/src/main/assembly/jdbc-amqp-0-8.xml similarity index 89% rename from qpid-docker/src/main/assembly/postgres-amqp-0-8.xml rename to qpid-docker/src/main/assembly/jdbc-amqp-0-8.xml index 4b25a7975b..a601ada6e0 100644 --- a/qpid-docker/src/main/assembly/postgres-amqp-0-8.xml +++ b/qpid-docker/src/main/assembly/jdbc-amqp-0-8.xml @@ -22,7 +22,7 @@ - postgres-amqp-0-8 + jdbc-amqp-0-8 dir @@ -33,7 +33,7 @@ broker.acl config.json - default-postgres.json + default-jdbc.json preferences.json userPreferences.json @@ -42,13 +42,6 @@ - - /jdbc - false - - org.postgresql:postgresql:jar - - /lib false diff --git a/qpid-docker/src/main/assembly/postgres-amqp-1-0.xml b/qpid-docker/src/main/assembly/jdbc-amqp-1-0.xml similarity index 89% rename from qpid-docker/src/main/assembly/postgres-amqp-1-0.xml rename to qpid-docker/src/main/assembly/jdbc-amqp-1-0.xml index 9a38709683..e8dc38a67f 100644 --- a/qpid-docker/src/main/assembly/postgres-amqp-1-0.xml +++ b/qpid-docker/src/main/assembly/jdbc-amqp-1-0.xml @@ -22,7 +22,7 @@ - postgres-amqp-1-0 + jdbc-amqp-1-0 dir @@ -33,7 +33,7 @@ broker.acl config.json - default-postgres.json + default-jdbc.json preferences.json userPreferences.json @@ -42,13 +42,6 @@ - - /jdbc - false - - org.postgresql:postgresql:jar - - /lib false diff --git a/qpid-docker/src/main/assembly/postgres-amqp-all.xml b/qpid-docker/src/main/assembly/jdbc-amqp-all.xml similarity index 88% rename from qpid-docker/src/main/assembly/postgres-amqp-all.xml rename to qpid-docker/src/main/assembly/jdbc-amqp-all.xml index b64752043e..2011ddf68f 100644 --- a/qpid-docker/src/main/assembly/postgres-amqp-all.xml +++ b/qpid-docker/src/main/assembly/jdbc-amqp-all.xml @@ -22,7 +22,7 @@ - postgres-amqp-all + jdbc-amqp-all dir @@ -33,7 +33,7 @@ broker.acl config.json - default-postgres.json + default-jdbc.json preferences.json userPreferences.json @@ -42,13 +42,6 @@ - - /jdbc - false - - org.postgresql:postgresql:jar - - /lib false diff --git a/qpid-docker/src/main/assembly/memory-amqp-0-10.xml b/qpid-docker/src/main/assembly/memory-amqp-0-10.xml index 505830ea7e..f24a061598 100644 --- a/qpid-docker/src/main/assembly/memory-amqp-0-10.xml +++ b/qpid-docker/src/main/assembly/memory-amqp-0-10.xml @@ -67,7 +67,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-store org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/memory-amqp-0-8.xml b/qpid-docker/src/main/assembly/memory-amqp-0-8.xml index de0103fb40..219618bbe8 100644 --- a/qpid-docker/src/main/assembly/memory-amqp-0-8.xml +++ b/qpid-docker/src/main/assembly/memory-amqp-0-8.xml @@ -67,7 +67,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-store org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/memory-amqp-1-0.xml b/qpid-docker/src/main/assembly/memory-amqp-1-0.xml index ebfd72b374..d917bb41cc 100644 --- a/qpid-docker/src/main/assembly/memory-amqp-1-0.xml +++ b/qpid-docker/src/main/assembly/memory-amqp-1-0.xml @@ -67,7 +67,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-store org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/assembly/memory-amqp-all.xml b/qpid-docker/src/main/assembly/memory-amqp-all.xml index 67b21383a4..a8dc2050bc 100644 --- a/qpid-docker/src/main/assembly/memory-amqp-all.xml +++ b/qpid-docker/src/main/assembly/memory-amqp-all.xml @@ -62,7 +62,6 @@ org.apache.qpid:qpid-broker-plugins-jdbc-store org.ow2.asm:asm org.ow2.asm:asm-tree - org.postgresql:postgresql diff --git a/qpid-docker/src/main/docker/Containerfile b/qpid-docker/src/main/docker/Containerfile index 66623dae51..88293fb6b7 100644 --- a/qpid-docker/src/main/docker/Containerfile +++ b/qpid-docker/src/main/docker/Containerfile @@ -15,58 +15,32 @@ # specific language governing permissions and limitations # under the License. -ARG JRE_VERSION=17 +ARG BROKER_STORAGE=bdb +ARG JRE_VERSION=11 ARG OS_NAME=alpine # # Builder images # + # Alpine FROM docker.io/library/eclipse-temurin:11-jre-alpine AS builder-11-alpine RUN adduser -u 1001 -G root qpid --disabled-password -FROM docker.io/library/eclipse-temurin:17-jre-alpine AS builder-17-alpine -RUN adduser -u 1001 -G root qpid --disabled-password - -FROM docker.io/library/eclipse-temurin:21-jre-alpine AS builder-21-alpine -RUN adduser -u 1001 -G root qpid --disabled-password - # Centos7 FROM docker.io/library/eclipse-temurin:11-jre-centos7 AS builder-11-centos7 RUN useradd -u 1001 -G root qpid -FROM docker.io/library/eclipse-temurin:17-jre-centos7 AS builder-17-centos7 -RUN useradd -u 1001 -G root qpid - -FROM docker.io/library/eclipse-temurin:21-jre-centos7 AS builder-21-centos7 -RUN useradd -u 1001 -G root qpid - -# UBI9 -FROM docker.io/library/eclipse-temurin:11-jre-ubi9-minimal AS builder-11-ubi9 -RUN useradd -u 1001 -G root qpid - -FROM docker.io/library/eclipse-temurin:17-jre-ubi9-minimal AS builder-17-ubi9 -RUN useradd -u 1001 -G root qpid - -FROM docker.io/library/eclipse-temurin:21-jre-ubi9-minimal AS builder-21-ubi9 -RUN useradd -u 1001 -G root qpid - # Ubuntu FROM docker.io/library/eclipse-temurin:11-jre AS builder-11-ubuntu RUN useradd -u 1001 -G root qpid -FROM docker.io/library/eclipse-temurin:17-jre AS builder-17-ubuntu -RUN useradd -u 1001 -G root qpid - -FROM docker.io/library/eclipse-temurin:21-jre AS builder-21-ubuntu -RUN useradd -u 1001 -G root qpid - # # Final image # -FROM builder-${JRE_VERSION}-${OS_NAME} +FROM builder-11-${OS_NAME} -ARG BROKER_STORAGE=memory +ARG BROKER_STORAGE=bdb ARG BROKER_VERSION="unknown" # Labels @@ -84,13 +58,6 @@ ENV JAVA_GC="-XX:+UseG1GC" ENV JAVA_MEM="-Xmx300m -XX:MaxDirectMemorySize=200m" ENV JAVA_OPTS="" -# Database connection variables -ENV DB_HOSTNAME="" -ENV DB_PORT="" -ENV DB_NAME="" -ENV DB_USERNAME="" -ENV DB_PASSWORD="" - # Create work folder and subfolders RUN mkdir -p /qpid-broker-j/etc && \ mkdir -p /qpid-broker-j/work && \ @@ -101,14 +68,14 @@ RUN mkdir -p /qpid-broker-j/etc && \ VOLUME ["/qpid-broker-j/work"] # Copy jar files -COPY --chown=1001:root --chmod=770 ./lib ./jdbc/* /qpid-broker-j/lib +COPY --chown=1001:root --chmod=770 ./lib /qpid-broker-j/lib # Copy configuration files -COPY --chown=1001:root --chmod=770 broker.acl /qpid-broker-j/work -COPY --chown=1001:root --chmod=770 config.json /qpid-broker-j/work -COPY --chown=1001:root --chmod=770 default-${BROKER_STORAGE}.json /qpid-broker-j/work/default.json -COPY --chown=1001:root --chmod=770 preferences.json /qpid-broker-j/work -COPY --chown=1001:root --chmod=770 userPreferences.json /qpid-broker-j/work +COPY --chown=1001:root --chmod=660 broker.acl /qpid-broker-j/work +COPY --chown=1001:root --chmod=660 config.json /qpid-broker-j/work +COPY --chown=1001:root --chmod=660 default-${BROKER_STORAGE}.json /qpid-broker-j/work/default.json +COPY --chown=1001:root --chmod=660 preferences.json /qpid-broker-j/work +COPY --chown=1001:root --chmod=660 userPreferences.json /qpid-broker-j/work WORKDIR /qpid-broker-j diff --git a/qpid-docker/src/main/docker/Containerfile-dev b/qpid-docker/src/main/docker/Containerfile-dev new file mode 100644 index 0000000000..1c9fb31209 --- /dev/null +++ b/qpid-docker/src/main/docker/Containerfile-dev @@ -0,0 +1,153 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +ARG BROKER_STORAGE=bdb +ARG JRE_VERSION=17 +ARG OS_NAME=alpine + +# +# Builder images +# + +FROM docker.io/library/alpine as builder-bdb +RUN mkdir -p /qpid-broker-j/lib + +FROM docker.io/library/alpine as builder-derby +RUN mkdir -p /qpid-broker-j/lib + +FROM docker.io/library/alpine as builder-jdbc + +ARG JDBC_DRIVER="" +ARG JDBC_DRIVER_URL="" + +RUN apk add --no-cache wget && \ + wget -P /qpid-broker-j/lib ${JDBC_DRIVER_URL} + +FROM docker.io/library/alpine as builder-memory +RUN mkdir -p /qpid-broker-j/lib + +FROM builder-${BROKER_STORAGE} as builder-common + +# Alpine +FROM docker.io/library/eclipse-temurin:11-jre-alpine AS builder-11-alpine +RUN adduser -u 1001 -G root qpid --disabled-password +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +FROM docker.io/library/eclipse-temurin:17-jre-alpine AS builder-17-alpine +RUN adduser -u 1001 -G root qpid --disabled-password +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +FROM docker.io/library/eclipse-temurin:21-jre-alpine AS builder-21-alpine +RUN adduser -u 1001 -G root qpid --disabled-password +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +# Centos7 +FROM docker.io/library/eclipse-temurin:11-jre-centos7 AS builder-11-centos7 +RUN useradd -u 1001 -G root qpid +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +FROM docker.io/library/eclipse-temurin:17-jre-centos7 AS builder-17-centos7 +RUN useradd -u 1001 -G root qpid +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +FROM docker.io/library/eclipse-temurin:21-jre-centos7 AS builder-21-centos7 +RUN useradd -u 1001 -G root qpid +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +# UBI9 +FROM docker.io/library/eclipse-temurin:11-jre-ubi9-minimal AS builder-11-ubi9 +RUN useradd -u 1001 -G root qpid +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +FROM docker.io/library/eclipse-temurin:17-jre-ubi9-minimal AS builder-17-ubi9 +RUN useradd -u 1001 -G root qpid +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +FROM docker.io/library/eclipse-temurin:21-jre-ubi9-minimal AS builder-21-ubi9 +RUN useradd -u 1001 -G root qpid +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +# Ubuntu +FROM docker.io/library/eclipse-temurin:11-jre AS builder-11-ubuntu +RUN useradd -u 1001 -G root qpid +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +FROM docker.io/library/eclipse-temurin:17-jre AS builder-17-ubuntu +RUN useradd -u 1001 -G root qpid +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +FROM docker.io/library/eclipse-temurin:21-jre AS builder-21-ubuntu +RUN useradd -u 1001 -G root qpid +COPY --from=builder-common /qpid-broker-j/lib /qpid-broker-j/lib/*.jar /qpid-broker-j/lib/ + +# +# Final image +# +FROM builder-${JRE_VERSION}-${OS_NAME} + +ARG BROKER_STORAGE=memory +ARG BROKER_VERSION="unknown" + +# Labels +LABEL description="Apache Qpid Broker-J ${BROKER_VERSION}" +LABEL io.k8s.display-name="qpid-broker-j ${BROKER_VERSION}" +LABEL io.k8s.description="Apache Qpid Broker-J ${BROKER_VERSION} using ${BROKER_STORAGE} as a message storage" +LABEL maintainer="Apache Qpid Team, users@qpid.apache.org" +LABEL name="Apache Qpid Broker-J" +LABEL summary="Apache Qpid Broker-J ${BROKER_VERSION} using ${BROKER_STORAGE} as a message storage" +LABEL version="${BROKER_VERSION}" +LABEL url="https://qpid.apache.org/components/broker-j/index.html" + +# Java environment variables +ENV JAVA_GC="-XX:+UseG1GC" +ENV JAVA_MEM="-Xmx300m -XX:MaxDirectMemorySize=200m" +ENV JAVA_OPTS="" + +# Database connection variables +ENV DB_DRIVER=$JDBC_DRIVER +ENV DB_HOSTNAME="" +ENV DB_PORT="" +ENV DB_NAME="" +ENV DB_USERNAME="" +ENV DB_PASSWORD="" + +# Create work folder and subfolders +RUN mkdir -p /qpid-broker-j/etc && \ + mkdir -p /qpid-broker-j/work && \ + chmod -R 770 /qpid-broker-j && \ + chown -R 1001:root /qpid-broker-j + +# Declare volume +VOLUME ["/qpid-broker-j/work"] + +# Copy jar files +COPY --chown=1001:root --chmod=770 ./lib /qpid-broker-j/lib + +# Copy configuration files +COPY --chown=1001:root --chmod=660 broker.acl /qpid-broker-j/work +COPY --chown=1001:root --chmod=660 config.json /qpid-broker-j/work +COPY --chown=1001:root --chmod=660 default-${BROKER_STORAGE}.json /qpid-broker-j/work/default.json +COPY --chown=1001:root --chmod=660 preferences.json /qpid-broker-j/work +COPY --chown=1001:root --chmod=660 userPreferences.json /qpid-broker-j/work + +WORKDIR /qpid-broker-j + +EXPOSE 5672 8080 + +USER 1001:root + +ENTRYPOINT java -server $JAVA_GC $JAVA_MEM $JAVA_OPTS -DQPID_HOME=/qpid-broker-j -DQPID_WORK=/qpid-broker-j/work -cp "/qpid-broker-j/lib/*" org.apache.qpid.server.Main diff --git a/qpid-docker/src/main/docker/default-postgres.json b/qpid-docker/src/main/docker/default-jdbc.json similarity index 81% rename from qpid-docker/src/main/docker/default-postgres.json rename to qpid-docker/src/main/docker/default-jdbc.json index 624869e389..40177c550c 100644 --- a/qpid-docker/src/main/docker/default-postgres.json +++ b/qpid-docker/src/main/docker/default-jdbc.json @@ -3,7 +3,7 @@ "modelVersion" : "9.0", "type" : "JDBC", "connectionPoolType" : "BONECP", - "connectionUrl": "jdbc:postgresql://${DB_HOSTNAME}:${DB_PORT}/${DB_NAME}", + "connectionUrl": "jdbc:${DB_DRIVER}://${DB_HOSTNAME}:${DB_PORT}/${DB_NAME}", "username": "${DB_USERNAME}", "password": "${DB_PASSWORD}", "storeUnderfullSize" : "0", diff --git a/qpid-docker/src/main/docker/examples/default.json b/qpid-docker/src/main/docker/examples/default.json new file mode 100644 index 0000000000..c13b5d09c7 --- /dev/null +++ b/qpid-docker/src/main/docker/examples/default.json @@ -0,0 +1,47 @@ +{ + "name" : "default", + "type" : "BDB", + "modelVersion" : "9.0", + "storePath" : "/qpid-broker-j/work/messages", + "storeUnderfullSize" : "0", + "storeOverfullSize" : "0", + "context" : { + "qpid.broker.bdbCommiterNotifyThreshold" : "8", + "qpid.broker.bdbCommiterWaitTimeout" : "500", + "queue.defaultMaximumQueueDepthMessages" : "1000", + "queue.defaultMaximumQueueDepthBytes" : "1048576" + }, + "exchanges" : [ { + "name" : "amq.direct", + "type" : "direct" + }, { + "name" : "amq.fanout", + "type" : "fanout" + }, { + "name" : "amq.match", + "type" : "headers" + }, { + "name" : "amq.topic", + "type" : "topic" + }, { + "name" : "request.QUEUE1", + "type" : "topic", + "durable" : true, + "durableBindings" : [ { + "arguments" : { }, + "destination" : "QUEUE1", + "bindingKey" : "#" + } ], + "unroutableMessageBehaviour" : "REJECT" + } ], + "queues" : [ { + "name" : "QUEUE1", + "type" : "standard", + "durable" : true, + "maximumQueueDepthBytes" : 6144000, + "maximumQueueDepthMessages" : 6000, + "messageDurability" : "ALWAYS", + "overflowPolicy" : "REJECT" + } + ] +} \ No newline at end of file