Blame view

Dockerfile 4.19 KB
1
# syntax=docker/dockerfile:1.4
2 3 4 5 6 7 8
# 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 \
9
	&& apt-get install -y unzip less git \
10 11 12 13 14 15 16
	&& 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

17 18 19 20 21 22 23 24
FROM moqui-base AS moqui-jdbc-drivers

RUN true \
	&& apt-get update \
	&& apt-get install -y libpostgresql-jdbc-java \
	&& apt-get clean && rm -rf /var/lib/apt/lists/* \
	&& true

25 26 27 28 29 30
# 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

31 32 33 34 35 36 37 38 39 40 41 42
RUN ["mkdir", "/opt/moqui-scripts"]
COPY --from=moqui-builder fix-git-submodules /opt/moqui-scripts/fix-git-submodules

COPY ./ /opt/moqui-app/

RUN ["/opt/moqui-scripts/fix-git-submodules", "-start", "/opt/moqui-app"]

RUN true && set -x \
	&& rm -rf /opt/moqui-build && ln -sf /opt/moqui-app/framework /opt/moqui-build \
	&& rm -rf /opt/moqui-build/runtime && ln -sf /opt/moqui-app/runtime /opt/moqui-build/runtime \
	&& rm -rf /opt/moqui-build/runtime/component && ln -sf /opt/moqui-app/component /opt/moqui-build/runtime/component \
	&& true
43 44 45 46 47 48 49

RUN ["./gradlew", "--no-daemon", "--info", "build", "addRuntime"]

WORKDIR /opt/moqui
USER moqui
RUN ["unzip", "-o", "/opt/moqui-build/moqui-plus-runtime.war"]

50
FROM moqui-base AS moqui-app
51 52 53 54 55 56 57 58 59
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
60
#ARG search_name=opensearch
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79

# 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
80 81
RUN ["mkdir", "-p", "/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db"]
VOLUME ["/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db"]
82 83 84 85 86 87 88 89 90 91 92 93

# 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"]
94
ENTRYPOINT ["java", "-cp", ".", "MoquiStart"]
95 96 97

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
98
CMD ["port=8080", "conf=conf/MoquiProductionConf.xml"]
99