diff --git a/artemis-docker/Dockerfile-alpine b/artemis-docker/Dockerfile-alpine new file mode 100644 index 000000000000..31b9ba74ffa1 --- /dev/null +++ b/artemis-docker/Dockerfile-alpine @@ -0,0 +1,90 @@ +# 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. + +# ActiveMQ Artemis + +ARG CURRENT_VERSION=2.17.0 + +FROM eclipse-temurin:11-jdk as builder +ARG CURRENT_VERSION + +ENV VERSION=$CURRENT_VERSION + +RUN apt update -y && apt upgrade -y && apt install curl -y + +ADD ./prepare-docker.sh /bin/prepareDocker +WORKDIR /root/artemis-build +COPY docker-run.sh . +RUN bash prepareDocker --from-release --artemis-version ${VERSION} + + +FROM alpine:latest + +ARG CURRENT_VERSION + +ENV VERSION=$CURRENT_VERSION + +RUN apk --no-cache add openjdk17-jre-headless bash libaio\ + --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community + + +LABEL maintainer="Apache ActiveMQ Team" +# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +WORKDIR /opt + +ENV ARTEMIS_USER artemis +ENV ARTEMIS_PASSWORD artemis +ENV ANONYMOUS_LOGIN false +ENV EXTRA_ARGS --http-host 0.0.0.0 --relax-jolokia + +# add user and group for artemis +RUN addgroup -g 1001 artemis && adduser -u 1002 --ingroup artemis --disabled-password artemis + +USER artemis + +COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/ /opt/activemq-artemis + +# Web Server +EXPOSE 8161 \ +# JMX Exporter + 9404 \ +# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE + 61616 \ +# Port for HORNETQ,STOMP + 5445 \ +# Port for AMQP + 5672 \ +# Port for MQTT + 1883 \ +#Port for STOMP + 61613 + +USER root + +RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance + +COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/docker/docker-run.sh / + +USER artemis + +# Expose some outstanding folders +VOLUME ["/var/lib/artemis-instance"] +WORKDIR /var/lib/artemis-instance + +ENTRYPOINT ["/docker-run.sh"] +CMD ["run"] \ No newline at end of file diff --git a/artemis-docker/Dockerfile-alpine-build b/artemis-docker/Dockerfile-alpine-build new file mode 100644 index 000000000000..d3334bcaee40 --- /dev/null +++ b/artemis-docker/Dockerfile-alpine-build @@ -0,0 +1,72 @@ +# 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. + +# ActiveMQ Artemis + +FROM alpine:latest + + +RUN apk --no-cache add openjdk17-jre-headless bash libaio\ + --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community + + +LABEL maintainer="Apache ActiveMQ Team" +# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +WORKDIR /opt + +ENV ARTEMIS_USER artemis +ENV ARTEMIS_PASSWORD artemis +ENV ANONYMOUS_LOGIN false +ENV EXTRA_ARGS --http-host 0.0.0.0 --relax-jolokia + +# add user and group for artemis +RUN addgroup -g 1001 artemis && adduser -u 1002 --ingroup artemis --disabled-password artemis + +USER artemis + +COPY --chown=artemis:artemis ./artemis-docker/target/apache-artemis*-bin/*SNAPSHOT /opt/activemq-artemis/ + +# Web Server +EXPOSE 8161 \ +# JMX Exporter + 9404 \ +# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE + 61616 \ +# Port for HORNETQ,STOMP + 5445 \ +# Port for AMQP + 5672 \ +# Port for MQTT + 1883 \ +#Port for STOMP + 61613 + +USER root + +RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance + +COPY --chown=artemis:artemis ./artemis-docker/docker-run.sh /var/lib/artemis-instance/docker-run.sh + +USER artemis + +# Expose some outstanding folders +VOLUME ["/var/lib/artemis-instance"] +WORKDIR /var/lib/artemis-instance + +ENTRYPOINT ["./docker-run.sh"] +CMD ["run"] \ No newline at end of file diff --git a/artemis-docker/Dockerfile-build b/artemis-docker/Dockerfile-build new file mode 100644 index 000000000000..bc3076189c95 --- /dev/null +++ b/artemis-docker/Dockerfile-build @@ -0,0 +1,6 @@ +FROM maven:3-eclipse-temurin-11 +WORKDIR /root/artemis-build + +RUN apt update -y && apt upgrade -y && apt install curl -y +COPY . . + diff --git a/artemis-docker/Dockerfile-centos7-11 b/artemis-docker/Dockerfile-centos7-11 index 5c8fb723da25..8b69763b8181 100644 --- a/artemis-docker/Dockerfile-centos7-11 +++ b/artemis-docker/Dockerfile-centos7-11 @@ -17,12 +17,29 @@ # ActiveMQ Artemis +ARG CURRENT_VERSION=2.17.0 + +FROM eclipse-temurin:11-jdk as builder +ARG CURRENT_VERSION + +ENV VERSION=$CURRENT_VERSION + +RUN apt update -y && apt upgrade -y && apt install curl -y + +ADD ./prepare-docker.sh /bin/prepareDocker +WORKDIR /root/artemis-build +COPY docker-run.sh . +RUN bash prepareDocker --from-release --artemis-version ${VERSION} + FROM eclipse-temurin:11-centos7 LABEL maintainer="Apache ActiveMQ Team" # Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 SHELL ["/bin/bash", "-o", "pipefail", "-c"] WORKDIR /opt +ARG CURRENT_VERSION + +ENV VERSION=$CURRENT_VERSION ENV ARTEMIS_USER artemis ENV ARTEMIS_PASSWORD artemis ENV ANONYMOUS_LOGIN false @@ -36,7 +53,7 @@ RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis \ USER artemis -ADD . /opt/activemq-artemis +COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/ /opt/activemq-artemis # Web Server EXPOSE 8161 \ @@ -57,7 +74,7 @@ USER root RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance -COPY ./docker/docker-run.sh / +COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/docker/docker-run.sh / USER artemis diff --git a/artemis-docker/Dockerfile-centos7-11-build b/artemis-docker/Dockerfile-centos7-11-build new file mode 100644 index 000000000000..c2a24693cd20 --- /dev/null +++ b/artemis-docker/Dockerfile-centos7-11-build @@ -0,0 +1,69 @@ +# 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. + +# ActiveMQ Artemis + +FROM eclipse-temurin:11-centos7 +LABEL maintainer="Apache ActiveMQ Team" +# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +WORKDIR /opt + +ENV ARTEMIS_USER artemis +ENV ARTEMIS_PASSWORD artemis +ENV ANONYMOUS_LOGIN false +ENV EXTRA_ARGS --http-host 0.0.0.0 --relax-jolokia + +USER root + +# add user and group for artemis +RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis \ + && yum install -y libaio && yum -y clean all + +USER artemis + +COPY --chown=artemis:artemis ./artemis-docker/target/apache-artemis*-bin/*SNAPSHOT /opt/activemq-artemis/ + +# Web Server +EXPOSE 8161 \ +# JMX Exporter + 9404 \ +# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE + 61616 \ +# Port for HORNETQ,STOMP + 5445 \ +# Port for AMQP + 5672 \ +# Port for MQTT + 1883 \ +#Port for STOMP + 61613 + +USER root + +RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance + +COPY --chown=artemis:artemis ./artemis-docker/docker-run.sh /var/lib/artemis-instance/docker-run.sh + +USER artemis + +# Expose some outstanding folders +VOLUME ["/var/lib/artemis-instance"] +WORKDIR /var/lib/artemis-instance + +ENTRYPOINT ["./docker-run.sh"] +CMD ["run"] \ No newline at end of file diff --git a/artemis-docker/Dockerfile-ubuntu-11 b/artemis-docker/Dockerfile-ubuntu-11 index 71145cd93708..9f91f3310fc7 100644 --- a/artemis-docker/Dockerfile-ubuntu-11 +++ b/artemis-docker/Dockerfile-ubuntu-11 @@ -17,8 +17,27 @@ # ActiveMQ Artemis +ARG CURRENT_VERSION=2.17.0 + +FROM eclipse-temurin:11-jdk as builder +ARG CURRENT_VERSION + +ENV VERSION=$CURRENT_VERSION + +RUN apt update -y && apt upgrade -y && apt install curl -y + +ADD ./prepare-docker.sh /bin/prepareDocker +WORKDIR /root/artemis-build +COPY docker-run.sh . +RUN bash prepareDocker --from-release --artemis-version ${VERSION} + FROM eclipse-temurin:11 LABEL maintainer="Apache ActiveMQ Team" + +ARG CURRENT_VERSION + +ENV VERSION=$CURRENT_VERSION + # Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 SHELL ["/bin/bash", "-o", "pipefail", "-c"] WORKDIR /opt @@ -36,7 +55,8 @@ RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis \ USER artemis -ADD . /opt/activemq-artemis +COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/ /opt/activemq-artemis + # Web Server EXPOSE 8161 \ @@ -57,7 +77,8 @@ USER root RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance -COPY ./docker/docker-run.sh / +COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/docker/docker-run.sh / + USER artemis diff --git a/artemis-docker/Dockerfile-ubuntu-11-build b/artemis-docker/Dockerfile-ubuntu-11-build new file mode 100644 index 000000000000..f4604e7e89fd --- /dev/null +++ b/artemis-docker/Dockerfile-ubuntu-11-build @@ -0,0 +1,73 @@ +# 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. + +# ActiveMQ Artemis + +FROM eclipse-temurin:11 +LABEL maintainer="Apache ActiveMQ Team" + + +# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +WORKDIR /opt + +ENV ARTEMIS_USER artemis +ENV ARTEMIS_PASSWORD artemis +ENV ANONYMOUS_LOGIN false +ENV EXTRA_ARGS --http-host 0.0.0.0 --relax-jolokia + +# add user and group for artemis +RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis \ + && apt-get -qq -o=Dpkg::Use-Pty=0 update && \ + apt-get -qq -o=Dpkg::Use-Pty=0 install -y libaio1 && \ + rm -rf /var/lib/apt/lists/* + +USER artemis + +COPY --chown=artemis:artemis ./artemis-docker/target/apache-artemis*-bin/*SNAPSHOT /opt/activemq-artemis/ + + +# Web Server +EXPOSE 8161 \ +# JMX Exporter + 9404 \ +# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE + 61616 \ +# Port for HORNETQ,STOMP + 5445 \ +# Port for AMQP + 5672 \ +# Port for MQTT + 1883 \ +#Port for STOMP + 61613 + +USER root + +RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance + +COPY --chown=artemis:artemis ./artemis-docker/docker-run.sh /var/lib/artemis-instance/docker-run.sh + + +USER artemis + +# Expose some outstanding folders +VOLUME ["/var/lib/artemis-instance"] +WORKDIR /var/lib/artemis-instance + +ENTRYPOINT ["./docker-run.sh"] +CMD ["run"] \ No newline at end of file diff --git a/artemis-docker/Dockerfile-ubuntu-11-jre b/artemis-docker/Dockerfile-ubuntu-11-jre index 8751d4d70707..71e9575a8dea 100644 --- a/artemis-docker/Dockerfile-ubuntu-11-jre +++ b/artemis-docker/Dockerfile-ubuntu-11-jre @@ -17,7 +17,29 @@ # ActiveMQ Artemis +ARG CURRENT_VERSION=2.17.0 + +FROM eclipse-temurin:11-jdk as builder +ARG CURRENT_VERSION + +ENV VERSION=$CURRENT_VERSION + +RUN apt update -y && apt upgrade -y && apt install curl -y + +ADD ./prepare-docker.sh /bin/prepareDocker +WORKDIR /root/artemis-build +COPY docker-run.sh . +RUN bash prepareDocker --from-release --artemis-version ${VERSION} + FROM eclipse-temurin:11-jre +LABEL maintainer="Apache ActiveMQ Team" + +ARG CURRENT_VERSION + +ENV VERSION=$CURRENT_VERSION + + + LABEL maintainer="Apache ActiveMQ Team" # Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 SHELL ["/bin/bash", "-o", "pipefail", "-c"] @@ -36,7 +58,8 @@ RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis \ USER artemis -ADD . /opt/activemq-artemis +COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/ /opt/activemq-artemis + # Web Server EXPOSE 8161 \ @@ -57,7 +80,8 @@ USER root RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance -COPY ./docker/docker-run.sh / +COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/docker/docker-run.sh / + USER artemis diff --git a/artemis-docker/Dockerfile-ubuntu-11-jre-build b/artemis-docker/Dockerfile-ubuntu-11-jre-build new file mode 100644 index 000000000000..989bcc2b9d36 --- /dev/null +++ b/artemis-docker/Dockerfile-ubuntu-11-jre-build @@ -0,0 +1,72 @@ +# 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. + +# ActiveMQ Artemis + +FROM eclipse-temurin:11-jre +LABEL maintainer="Apache ActiveMQ Team" + +# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] +WORKDIR /opt + +ENV ARTEMIS_USER artemis +ENV ARTEMIS_PASSWORD artemis +ENV ANONYMOUS_LOGIN false +ENV EXTRA_ARGS --http-host 0.0.0.0 --relax-jolokia + +# add user and group for artemis +RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis \ + && apt-get -qq -o=Dpkg::Use-Pty=0 update && \ + apt-get -qq -o=Dpkg::Use-Pty=0 install -y libaio1 && \ + rm -rf /var/lib/apt/lists/* + +USER artemis + +COPY --chown=artemis:artemis ./artemis-docker/target/apache-artemis*-bin/*SNAPSHOT /opt/activemq-artemis/ + + +# Web Server +EXPOSE 8161 \ +# JMX Exporter + 9404 \ +# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE + 61616 \ +# Port for HORNETQ,STOMP + 5445 \ +# Port for AMQP + 5672 \ +# Port for MQTT + 1883 \ +#Port for STOMP + 61613 + +USER root + +RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance + +COPY --chown=artemis:artemis ./artemis-docker/docker-run.sh /var/lib/artemis-instance/docker-run.sh + + +USER artemis + +# Expose some outstanding folders +VOLUME ["/var/lib/artemis-instance"] +WORKDIR /var/lib/artemis-instance + +ENTRYPOINT ["./docker-run.sh"] +CMD ["run"] \ No newline at end of file diff --git a/artemis-docker/docker-compose-final.yml b/artemis-docker/docker-compose-final.yml new file mode 100644 index 000000000000..abf55a9e7a1c --- /dev/null +++ b/artemis-docker/docker-compose-final.yml @@ -0,0 +1,23 @@ +version: "3.0.0" +services: + artemis-alpine: + build: + context: .. + dockerfile: ./artemis-docker/Dockerfile-alpine-build + image: artemis-alpine + artemis-centos: + build: + context: .. + dockerfile: ./artemis-docker/Dockerfile-centos7-11-build + image: artemis-centos + artemis-ubuntu: + build: + context: .. + dockerfile: ./artemis-docker/Dockerfile-ubuntu-11-build + image: artemis-ubuntu + artemis-ubuntu-jre: + build: + context: .. + dockerfile: ./artemis-docker/Dockerfile-ubuntu-11-jre-build + image: artemis-ubuntu-jre + diff --git a/artemis-docker/docker-compose.yml b/artemis-docker/docker-compose.yml new file mode 100644 index 000000000000..ee78280be4e2 --- /dev/null +++ b/artemis-docker/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.0.0" +services: + javaBuilder: + build: + context: .. + dockerfile: ./artemis-docker/Dockerfile-build + image: artemis-docker-base + command: > + bash -c "rm -rf ./target/* && mvn install -DskipTests -DskipITs -DskipDocs -DskipDocker -DskipDoc" + volumes: + - ./target:/root/artemis-build/artemis-distribution/target \ No newline at end of file diff --git a/artemis-docker/prepare-docker.sh b/artemis-docker/prepare-docker.sh index 9952d95ba6ee..eda1f84f6b35 100755 --- a/artemis-docker/prepare-docker.sh +++ b/artemis-docker/prepare-docker.sh @@ -48,26 +48,8 @@ HERE next_step () { cat <.yml ``` -## For Ubuntu +e.g. for Alpine -From within the `$ARTEMIS_DIST` folder: -``` -$ docker build -f ./docker/Dockerfile-ubuntu-11 -t artemis-ubuntu . ``` +docker build -f Dockerfile-alpine . +``` ## Smaller Ubuntu image with just JRE -From within the `$ARTEMIS_DIST` folder: +From within the `artemis-docker` folder: ``` -$ docker build -f ./docker/Dockerfile-ubuntu-11-jre -t artemis-ubuntu . +$ docker build -f ./Dockerfile-ubuntu-11-jre -t artemis-ubuntu . ``` # For Ubuntu (Build for linux ARMv7/ARM64) ``` -$ docker buildx build --platform linux/arm64,linux/arm/v7 --push -t {your-repository}/apache-artemis:2.17.0-SNAPSHOT -f ./docker/Dockerfile-ubuntu-11 . +$ docker buildx build --platform linux/arm64,linux/arm/v7 --push -t {your-repository}/apache-artemis:2.17.0-SNAPSHOT -f ./Dockerfile-ubuntu-11 . ``` **Note:** -`-t artemis-centos` and `-t artemis-ubuntu` are just tag names for the purpose of this guide +`-t artemis-alpine`, `-t artemis-centos` and `-t artemis-ubuntu` are just tag names for the purpose of this guide # Environment Variables @@ -194,4 +129,4 @@ The image will also support mapped folders and mapped ports. To run the image wi docker run -it -p 61616:61616 -p 8161:8161 -v :/var/lib/artemis-instance artemis-centos ``` where `` is a folder where the broker instance is supposed to -be saved and reused on each run. +be saved and reused on each run. \ No newline at end of file