gemmellr commented on code in PR #4297: URL: https://github.com/apache/activemq-artemis/pull/4297#discussion_r1198730389
########## artemis-image/README.md: ########## @@ -0,0 +1,48 @@ +###What is in the image + +An _empty_, _open_ broker with a default acceptor on port 61616 + + - by empty: has no addresses or queues but will auto create on demand + - by open: has no security; authentication or authorization, users or roles + +###How will the image behave + + 1) the image will use or create `/app/data` for persistence of data + + 2) the image will use any [.properties files](https://activemq.apache.org/components/artemis/documentation/latest/configuration-index.html#broker_properties) from `/app/etc` to augment broker configuration + + 3) the image will use `/app/etc/broker.xml` if present, to bootstrap configuration, the 'bring your own config' use case + +###Build and Use + +First build an OCI image tar file from this artemis project using mvn: + + `$> mvn compile jib:buildTar@now` + +An OCI image is created as a tar file. + +> *Note that any OCI compatible container runtime and registry can be used for the next steps, eg: docker, podman... I have used podman.* + +To load the image tar into the local container registry, use: + + `$> podman image load --input target/jib-image.tar` + +To run the image detached and rootless with port 61616 exposed to localhost by podman, use: + + `$> podman run --name=artemis -dp 61616:61616 localhost/target/activemq-artemis-image:<...>` + +Execute the artemis producer/consumer command line tools to interact with the broker. + + `$> ./bin/artemis producer --url tcp://localhost:61616` + + `$> ./bin/artemis consumer --url tcp://localhost:61616` + +###Intent + +The intent is that this image is useful as is. If one can trust users, having no access control or limits can work fine. + +If not, then this image can be configured by mounting an `/app/etc` directory with property files that augment default broker configuration. Review Comment: The 'If' and 'If not' dont really work being in different paragraphs. Would change 'If not' to something specific like 'If needing access control' ########## artemis-image/examples/byoc__etc/broker.xml: ########## @@ -0,0 +1,46 @@ +<?xml version='1.0'?> +<!-- +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. +--> +<configuration + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns="urn:activemq" + xsi:schemaLocation="urn:activemq:core schema/artemis-configuration.xsd"> + <core xmlns="urn:activemq:core"> + + <!-- + Configure an image in the traditional way. + Providing boilerplate xml can form the well known configuration for an organisational base image that can be further extended with properties + --> Review Comment: As an example, this suggests this minimal XML is the way to go. Unfortunately there are various 'historic behaviour code defaults' that are overridden-by-default in the broker.xml created for new instances. By not having much of that same config, this broker is going to behave quite differently out the box than a new standalone broker would out the box. ########## artemis-image/README.md: ########## @@ -0,0 +1,48 @@ +###What is in the image + +An _empty_, _open_ broker with a default acceptor on port 61616 + + - by empty: has no addresses or queues but will auto create on demand + - by open: has no security; authentication or authorization, users or roles + +###How will the image behave + + 1) the image will use or create `/app/data` for persistence of data + + 2) the image will use any [.properties files](https://activemq.apache.org/components/artemis/documentation/latest/configuration-index.html#broker_properties) from `/app/etc` to augment broker configuration + + 3) the image will use `/app/etc/broker.xml` if present, to bootstrap configuration, the 'bring your own config' use case + +###Build and Use + +First build an OCI image tar file from this artemis project using mvn: + + `$> mvn compile jib:buildTar@now` + +An OCI image is created as a tar file. + +> *Note that any OCI compatible container runtime and registry can be used for the next steps, eg: docker, podman... I have used podman.* + +To load the image tar into the local container registry, use: + + `$> podman image load --input target/jib-image.tar` + +To run the image detached and rootless with port 61616 exposed to localhost by podman, use: + + `$> podman run --name=artemis -dp 61616:61616 localhost/target/activemq-artemis-image:<...>` Review Comment: As an example I'm not sure I would go with detached...at least not without also explaining how to stop it hehe. As commented before, I think detailing whats expected to be in the <...> would be good, not everyone will just know. ########## artemis-server/src/main/java/org/apache/activemq/artemis/core/server/embedded/Main.java: ########## @@ -0,0 +1,148 @@ +/* + * 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. + */ +package org.apache.activemq.artemis.core.server.embedded; + +import java.io.File; +import java.lang.invoke.MethodHandles; +import java.util.concurrent.CountDownLatch; + +import org.apache.activemq.artemis.core.config.FileDeploymentManager; +import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl; +import org.apache.activemq.artemis.core.config.impl.FileConfiguration; +import org.apache.activemq.artemis.core.config.impl.LegacyJMSConfiguration; +import org.apache.activemq.artemis.core.server.ActivateCallback; +import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Main { + + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + private static String workDir = "/app"; + private static volatile EmbeddedActiveMQ embeddedServer; + + public static void main(String[] args) throws Exception { + + if (args.length == 1) { + workDir = args[0]; + logger.debug("User supplied work dir {}", workDir); + } + + String propertiesConfigPath = "/config/," + workDir + "/etc/"; + if (args.length == 2) { + propertiesConfigPath = args[1]; + logger.debug("User supplied properties config path {}", propertiesConfigPath); + } + + FileConfiguration configuration = new FileConfiguration(); + + String dataDir = workDir + "/data"; + configureDataDirectory(configuration, dataDir); + + File bringYourOwnXml = new File(workDir + "/etc/broker.xml"); + if (bringYourOwnXml.exists()) { + logger.debug("byo config found {}", bringYourOwnXml); + configuration = loadFromXmlFile(bringYourOwnXml, configuration); + } Review Comment: Related to the other comment, I now realise that as this doesnt use any broker.xml by default, it will again be picking up all the 'code defaults' that new broker instances normally wouldnt, due to the overriding config in broker.xml. Having such non-obvious (I couldnt tell you what they all are) different behaviours out the box between standalone and image seems less than ideal. Not sure I have a good suggestion here though, as to more closely match then it would probably need to use a similar default config to the default broker.xml, and you clearly looked to avoid using that. Equally, anything seperate trying to match it without using it, would likely become stale. Hmm. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
