Skip to content

Commit 95f18c3

Browse files
committed
ARTEMIS-3042 Add docker multistage build
This adds the possibility to create an artemis image with just the docker compose build command. First the image is downloaded in an Eclipse Temurin installation and compiled with a mounted volume. After that a second docker compose build command can be used to put the build artifact into the different containers. Thus activemq-artemis is only built once resulting in a very fast compile time.
1 parent eb11b04 commit 95f18c3

13 files changed

+522
-131
lines changed

artemis-docker/Dockerfile-alpine

+90
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# ActiveMQ Artemis
19+
20+
ARG CURRENT_VERSION=2.17.0
21+
22+
FROM eclipse-temurin:11-jdk as builder
23+
ARG CURRENT_VERSION
24+
25+
ENV VERSION=$CURRENT_VERSION
26+
27+
RUN apt update -y && apt upgrade -y && apt install curl -y
28+
29+
ADD ./prepare-docker.sh /bin/prepareDocker
30+
WORKDIR /root/artemis-build
31+
COPY docker-run.sh .
32+
RUN bash prepareDocker --from-release --artemis-version ${VERSION}
33+
34+
35+
FROM alpine:latest
36+
37+
ARG CURRENT_VERSION
38+
39+
ENV VERSION=$CURRENT_VERSION
40+
41+
RUN apk --no-cache add openjdk17-jre-headless bash libaio\
42+
--repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
43+
44+
45+
LABEL maintainer="Apache ActiveMQ Team"
46+
# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006
47+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
48+
WORKDIR /opt
49+
50+
ENV ARTEMIS_USER artemis
51+
ENV ARTEMIS_PASSWORD artemis
52+
ENV ANONYMOUS_LOGIN false
53+
ENV EXTRA_ARGS --http-host 0.0.0.0 --relax-jolokia
54+
55+
# add user and group for artemis
56+
RUN addgroup -g 1001 artemis && adduser -u 1002 --ingroup artemis --disabled-password artemis
57+
58+
USER artemis
59+
60+
COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/ /opt/activemq-artemis
61+
62+
# Web Server
63+
EXPOSE 8161 \
64+
# JMX Exporter
65+
9404 \
66+
# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE
67+
61616 \
68+
# Port for HORNETQ,STOMP
69+
5445 \
70+
# Port for AMQP
71+
5672 \
72+
# Port for MQTT
73+
1883 \
74+
#Port for STOMP
75+
61613
76+
77+
USER root
78+
79+
RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance
80+
81+
COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/docker/docker-run.sh /
82+
83+
USER artemis
84+
85+
# Expose some outstanding folders
86+
VOLUME ["/var/lib/artemis-instance"]
87+
WORKDIR /var/lib/artemis-instance
88+
89+
ENTRYPOINT ["/docker-run.sh"]
90+
CMD ["run"]
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# ActiveMQ Artemis
19+
20+
FROM alpine:latest
21+
22+
23+
RUN apk --no-cache add openjdk17-jre-headless bash libaio\
24+
--repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
25+
26+
27+
LABEL maintainer="Apache ActiveMQ Team"
28+
# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006
29+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
30+
WORKDIR /opt
31+
32+
ENV ARTEMIS_USER artemis
33+
ENV ARTEMIS_PASSWORD artemis
34+
ENV ANONYMOUS_LOGIN false
35+
ENV EXTRA_ARGS --http-host 0.0.0.0 --relax-jolokia
36+
37+
# add user and group for artemis
38+
RUN addgroup -g 1001 artemis && adduser -u 1002 --ingroup artemis --disabled-password artemis
39+
40+
USER artemis
41+
42+
COPY --chown=artemis:artemis ./artemis-docker/target/apache-artemis*-bin/*SNAPSHOT /opt/activemq-artemis/
43+
44+
# Web Server
45+
EXPOSE 8161 \
46+
# JMX Exporter
47+
9404 \
48+
# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE
49+
61616 \
50+
# Port for HORNETQ,STOMP
51+
5445 \
52+
# Port for AMQP
53+
5672 \
54+
# Port for MQTT
55+
1883 \
56+
#Port for STOMP
57+
61613
58+
59+
USER root
60+
61+
RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance
62+
63+
COPY --chown=artemis:artemis ./artemis-docker/docker-run.sh /var/lib/artemis-instance/docker-run.sh
64+
65+
USER artemis
66+
67+
# Expose some outstanding folders
68+
VOLUME ["/var/lib/artemis-instance"]
69+
WORKDIR /var/lib/artemis-instance
70+
71+
ENTRYPOINT ["./docker-run.sh"]
72+
CMD ["run"]

artemis-docker/Dockerfile-build

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM maven:3-eclipse-temurin-11
2+
WORKDIR /root/artemis-build
3+
4+
RUN apt update -y && apt upgrade -y && apt install curl -y
5+
COPY . .
6+

artemis-docker/Dockerfile-centos7-11

+19-2
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,29 @@
1717

1818
# ActiveMQ Artemis
1919

20+
ARG CURRENT_VERSION=2.17.0
21+
22+
FROM eclipse-temurin:11-jdk as builder
23+
ARG CURRENT_VERSION
24+
25+
ENV VERSION=$CURRENT_VERSION
26+
27+
RUN apt update -y && apt upgrade -y && apt install curl -y
28+
29+
ADD ./prepare-docker.sh /bin/prepareDocker
30+
WORKDIR /root/artemis-build
31+
COPY docker-run.sh .
32+
RUN bash prepareDocker --from-release --artemis-version ${VERSION}
33+
2034
FROM eclipse-temurin:11-centos7
2135
LABEL maintainer="Apache ActiveMQ Team"
2236
# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006
2337
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
2438
WORKDIR /opt
2539

40+
ARG CURRENT_VERSION
41+
42+
ENV VERSION=$CURRENT_VERSION
2643
ENV ARTEMIS_USER artemis
2744
ENV ARTEMIS_PASSWORD artemis
2845
ENV ANONYMOUS_LOGIN false
@@ -36,7 +53,7 @@ RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis \
3653

3754
USER artemis
3855

39-
ADD . /opt/activemq-artemis
56+
COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/ /opt/activemq-artemis
4057

4158
# Web Server
4259
EXPOSE 8161 \
@@ -57,7 +74,7 @@ USER root
5774

5875
RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance
5976

60-
COPY ./docker/docker-run.sh /
77+
COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/docker/docker-run.sh /
6178

6279
USER artemis
6380

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# ActiveMQ Artemis
19+
20+
FROM eclipse-temurin:11-centos7
21+
LABEL maintainer="Apache ActiveMQ Team"
22+
# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006
23+
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
24+
WORKDIR /opt
25+
26+
ENV ARTEMIS_USER artemis
27+
ENV ARTEMIS_PASSWORD artemis
28+
ENV ANONYMOUS_LOGIN false
29+
ENV EXTRA_ARGS --http-host 0.0.0.0 --relax-jolokia
30+
31+
USER root
32+
33+
# add user and group for artemis
34+
RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis \
35+
&& yum install -y libaio && yum -y clean all
36+
37+
USER artemis
38+
39+
COPY --chown=artemis:artemis ./artemis-docker/target/apache-artemis*-bin/*SNAPSHOT /opt/activemq-artemis/
40+
41+
# Web Server
42+
EXPOSE 8161 \
43+
# JMX Exporter
44+
9404 \
45+
# Port for CORE,MQTT,AMQP,HORNETQ,STOMP,OPENWIRE
46+
61616 \
47+
# Port for HORNETQ,STOMP
48+
5445 \
49+
# Port for AMQP
50+
5672 \
51+
# Port for MQTT
52+
1883 \
53+
#Port for STOMP
54+
61613
55+
56+
USER root
57+
58+
RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance
59+
60+
COPY --chown=artemis:artemis ./artemis-docker/docker-run.sh /var/lib/artemis-instance/docker-run.sh
61+
62+
USER artemis
63+
64+
# Expose some outstanding folders
65+
VOLUME ["/var/lib/artemis-instance"]
66+
WORKDIR /var/lib/artemis-instance
67+
68+
ENTRYPOINT ["./docker-run.sh"]
69+
CMD ["run"]

artemis-docker/Dockerfile-ubuntu-11

+23-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,27 @@
1717

1818
# ActiveMQ Artemis
1919

20+
ARG CURRENT_VERSION=2.17.0
21+
22+
FROM eclipse-temurin:11-jdk as builder
23+
ARG CURRENT_VERSION
24+
25+
ENV VERSION=$CURRENT_VERSION
26+
27+
RUN apt update -y && apt upgrade -y && apt install curl -y
28+
29+
ADD ./prepare-docker.sh /bin/prepareDocker
30+
WORKDIR /root/artemis-build
31+
COPY docker-run.sh .
32+
RUN bash prepareDocker --from-release --artemis-version ${VERSION}
33+
2034
FROM eclipse-temurin:11
2135
LABEL maintainer="Apache ActiveMQ Team"
36+
37+
ARG CURRENT_VERSION
38+
39+
ENV VERSION=$CURRENT_VERSION
40+
2241
# Make sure pipes are considered to determine success, see: https://github.com/hadolint/hadolint/wiki/DL4006
2342
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
2443
WORKDIR /opt
@@ -36,7 +55,8 @@ RUN groupadd -g 1001 -r artemis && useradd -r -u 1001 -g artemis artemis \
3655

3756
USER artemis
3857

39-
ADD . /opt/activemq-artemis
58+
COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/ /opt/activemq-artemis
59+
4060

4161
# Web Server
4262
EXPOSE 8161 \
@@ -57,7 +77,8 @@ USER root
5777

5878
RUN mkdir /var/lib/artemis-instance && chown -R artemis.artemis /var/lib/artemis-instance
5979

60-
COPY ./docker/docker-run.sh /
80+
COPY --from=builder /root/artemis-build/_TMP_/artemis/${VERSION}/docker/docker-run.sh /
81+
6182

6283
USER artemis
6384

0 commit comments

Comments
 (0)