7666e6b3 by Adam Heath

Initial pass of building a multi-stage moqui dockerfile.

1 parent cec0bd69
/Dockerfile
.*.sw?
/build.log
.*.sw?
/build.log
# Builds a minimal docker image with openjdk and moqui with various volumes for configuration and persisted data outside the container
# NOTE: add components, build and if needed load data before building a docker image with this
ARG RUNTIME_IMAGE=eclipse-temurin:11-jdk
FROM ${RUNTIME_IMAGE} AS moqui-base
RUN true \
&& apt-get update \
&& apt-get install unzip less \
&& apt-get clean && rm -rf /var/lib/apt/lists/* \
&& groupadd -g 1000 moqui \
&& useradd -u 1000 -g 1000 -G 0 -d /opt/moqui moqui \
&& mkdir /opt/moqui \
&& chown moqui:moqui /opt/moqui \
&& true
# build runs as root; attempting to chown all the copied-in files runs
# *very* slow
FROM moqui-base AS moqui-build
WORKDIR /opt/moqui-build
COPY framework/ ./
COPY runtime/ runtime/
COPY component/ runtime/component/
RUN ["./gradlew", "--no-daemon", "--info", "build", "addRuntime"]
WORKDIR /opt/moqui
USER moqui
RUN ["unzip", "-o", "/opt/moqui-build/moqui-plus-runtime.war"]
FROM moqui-base AS moqui-run
MAINTAINER Moqui Framework <moqui@googlegroups.com>
USER moqui
WORKDIR /opt/moqui
COPY --from=moqui-build /opt/moqui/ /opt/moqui/
RUN ["ls", "-l", "/opt/moqui/"]
# create user for search and chown corresponding files
ARG search_name=opensearch
# This is a fix for previous installs, not needed for new setups.
# upgrade fix #RUN if [ -d runtime/opensearch/bin ]; then echo "Installing OpenSearch User"; \
# upgrade fix # search_name=opensearch; \
# upgrade fix # groupadd -g 1000 opensearch && \
# upgrade fix # useradd -u 1000 -g 1000 -G 0 -d /opt/moqui/runtime/opensearch opensearch && \
# upgrade fix # chmod 0775 /opt/moqui/runtime/opensearch && \
# upgrade fix # chown -R 1000:0 /opt/moqui/runtime/opensearch; \
# upgrade fix # elif [ -d runtime/elasticsearch/bin ]; then echo "Installing ElasticSearch User"; \
# upgrade fix # search_name=elasticsearch; \
# upgrade fix # groupadd -r elasticsearch && \
# upgrade fix # useradd --no-log-init -r -g elasticsearch -d /opt/moqui/runtime/elasticsearch elasticsearch && \
# upgrade fix # chown -R elasticsearch:elasticsearch runtime/elasticsearch; \
# upgrade fix # fi
# exposed as volumes for configuration purposes
RUN ["mkdir", "-p", "/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"]
VOLUME ["/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"]
# exposed as volumes to persist data outside the container, recommended
RUN ["mkdir", "-p", "/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db", "/opt/moqui/runtime/$search_name"]
VOLUME ["/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db", "/opt/moqui/runtime/$search_name"]
# Main Servlet Container Port
EXPOSE 8080
# Not used for external search # # Search HTTP Port
# Not used for external search # EXPOSE 9200
# Not used for external search # # Search Cluster (TCP Transport) Port
# Not used for external search # EXPOSE 9300
# Hazelcast Cluster Port
EXPOSE 5701
# this is to run from the war file directly, preferred approach unzips war file in advance
# ENTRYPOINT ["java", "-jar", "moqui.war"]
ENTRYPOINT ["java", "-cp", ".", "MoquiStart", "port=8080"]
HEALTHCHECK --interval=30s --timeout=600ms --start-period=120s CMD curl -f -H "X-Forwarded-Proto: https" -H "X-Forwarded-Ssl: on" http://localhost:8080/status || exit 1
# specify this as a default parameter if none are specified with docker exec/run, ie run production by default
CMD ["conf=conf/MoquiProductionConf.xml"]