Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvements to Docker file #2504

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
12 changes: 5 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ Dockerfile

build
!build/docker
distribution
!distribution/target/distribution-base
documentation
i18n
plugins
starter
xmppserver

# Any intermediate build stuff.
**/target

# Deeper stuff
**/.DS_Store
Expand All @@ -25,4 +22,5 @@ xmppserver
**/.idea
**/.project
**/.settings
**/*.iml
**/*.iml
**/*.class
39 changes: 35 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
# This stage extracts all the pom.xml files.
# It'll get rebuilt with any source change, but that's OK.
FROM openjdk:11-jdk AS poms
Fishbowler marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /usr/src
COPY . .
# Wipe any files not called pom.xml or *.jar
RUN find . -type f -and \! -name pom.xml -and \! -name '*.jar' -delete
# Clear up any (now) empty diretories
RUN find . -type d -empty -delete
# Just for debug:
RUN find

# Now we build:
FROM openjdk:11-jdk AS build
# Set up Maven. No need to clean caches, this doesn't end up in the runtime container
RUN apt-get update -qq
RUN apt-get install -qqy maven
Fishbowler marked this conversation as resolved.
Show resolved Hide resolved
WORKDIR /tmp/
RUN mkdir /tmp/m2_home
ENV M2_HOME=/tmp/m2_home
WORKDIR /usr/src

# First, copy in just the pom.xml files and fetch the dependencies:
COPY --from=poms /usr/src/ .
RUN mvn -e -B dependency:go-offline
# Above here is only affected by the pom.xml files, so the cache is stable.

# Now, copy in all the source, and actually build it, skipping the tests.
COPY . .
RUN mvn -e -B package -Dmaven.test.skip

# Final stage, build the runtime container:
FROM openjdk:11-jre

ENV OPENFIRE_USER=openfire \
Expand All @@ -10,10 +42,8 @@ RUN apt-get update -qq \
&& adduser --disabled-password --quiet --system --home $OPENFIRE_DATA_DIR --gecos "Openfire XMPP server" --group $OPENFIRE_USER \
&& rm -rf /var/lib/apt/lists/*

COPY ./build/docker/entrypoint.sh /sbin/entrypoint.sh
RUN chmod 755 /sbin/entrypoint.sh

COPY --chown=openfire:openfire ./distribution/target/distribution-base /usr/local/openfire
COPY --chmod=0755 --from=build /usr/src/build/docker/entrypoint.sh /sbin/entrypoint.sh
COPY --chown=openfire:openfire --from=build /usr/src/distribution/target/distribution-base /usr/local/openfire
RUN mv ${OPENFIRE_DIR}/conf ${OPENFIRE_DIR}/conf_org \
&& mv ${OPENFIRE_DIR}/plugins ${OPENFIRE_DIR}/plugins_org \
&& mv ${OPENFIRE_DIR}/resources/security ${OPENFIRE_DIR}/resources/security_org
Expand All @@ -23,4 +53,5 @@ WORKDIR /usr/local/openfire

EXPOSE 3478 3479 5005 5222 5223 5229 5262 5263 5275 5276 7070 7443 7777 9090 9091
VOLUME ["${OPENFIRE_DATA_DIR}"]
VOLUME ["${OPENFIRE_LOG_DIR}"]
ENTRYPOINT [ "/sbin/entrypoint.sh" ]
Loading