7666e6b3 by Adam Heath

Initial pass of building a multi-stage moqui dockerfile.

1 parent cec0bd69
1 /Dockerfile
2 .*.sw?
3 /build.log
1 .*.sw?
2 /build.log
1 # Builds a minimal docker image with openjdk and moqui with various volumes for configuration and persisted data outside the container
2 # NOTE: add components, build and if needed load data before building a docker image with this
3 ARG RUNTIME_IMAGE=eclipse-temurin:11-jdk
4 FROM ${RUNTIME_IMAGE} AS moqui-base
5
6 RUN true \
7 && apt-get update \
8 && apt-get install unzip less \
9 && apt-get clean && rm -rf /var/lib/apt/lists/* \
10 && groupadd -g 1000 moqui \
11 && useradd -u 1000 -g 1000 -G 0 -d /opt/moqui moqui \
12 && mkdir /opt/moqui \
13 && chown moqui:moqui /opt/moqui \
14 && true
15
16 # build runs as root; attempting to chown all the copied-in files runs
17 # *very* slow
18 FROM moqui-base AS moqui-build
19
20 WORKDIR /opt/moqui-build
21
22 COPY framework/ ./
23 COPY runtime/ runtime/
24 COPY component/ runtime/component/
25
26 RUN ["./gradlew", "--no-daemon", "--info", "build", "addRuntime"]
27
28 WORKDIR /opt/moqui
29 USER moqui
30 RUN ["unzip", "-o", "/opt/moqui-build/moqui-plus-runtime.war"]
31
32 FROM moqui-base AS moqui-run
33 MAINTAINER Moqui Framework <moqui@googlegroups.com>
34
35 USER moqui
36 WORKDIR /opt/moqui
37
38 COPY --from=moqui-build /opt/moqui/ /opt/moqui/
39 RUN ["ls", "-l", "/opt/moqui/"]
40
41 # create user for search and chown corresponding files
42 ARG search_name=opensearch
43
44 # This is a fix for previous installs, not needed for new setups.
45 # upgrade fix #RUN if [ -d runtime/opensearch/bin ]; then echo "Installing OpenSearch User"; \
46 # upgrade fix # search_name=opensearch; \
47 # upgrade fix # groupadd -g 1000 opensearch && \
48 # upgrade fix # useradd -u 1000 -g 1000 -G 0 -d /opt/moqui/runtime/opensearch opensearch && \
49 # upgrade fix # chmod 0775 /opt/moqui/runtime/opensearch && \
50 # upgrade fix # chown -R 1000:0 /opt/moqui/runtime/opensearch; \
51 # upgrade fix # elif [ -d runtime/elasticsearch/bin ]; then echo "Installing ElasticSearch User"; \
52 # upgrade fix # search_name=elasticsearch; \
53 # upgrade fix # groupadd -r elasticsearch && \
54 # upgrade fix # useradd --no-log-init -r -g elasticsearch -d /opt/moqui/runtime/elasticsearch elasticsearch && \
55 # upgrade fix # chown -R elasticsearch:elasticsearch runtime/elasticsearch; \
56 # upgrade fix # fi
57
58 # exposed as volumes for configuration purposes
59 RUN ["mkdir", "-p", "/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"]
60 VOLUME ["/opt/moqui/runtime/conf", "/opt/moqui/runtime/lib", "/opt/moqui/runtime/classes", "/opt/moqui/runtime/ecomponent"]
61 # exposed as volumes to persist data outside the container, recommended
62 RUN ["mkdir", "-p", "/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db", "/opt/moqui/runtime/$search_name"]
63 VOLUME ["/opt/moqui/runtime/log", "/opt/moqui/runtime/txlog", "/opt/moqui/runtime/sessions", "/opt/moqui/runtime/db", "/opt/moqui/runtime/$search_name"]
64
65 # Main Servlet Container Port
66 EXPOSE 8080
67 # Not used for external search # # Search HTTP Port
68 # Not used for external search # EXPOSE 9200
69 # Not used for external search # # Search Cluster (TCP Transport) Port
70 # Not used for external search # EXPOSE 9300
71 # Hazelcast Cluster Port
72 EXPOSE 5701
73
74 # this is to run from the war file directly, preferred approach unzips war file in advance
75 # ENTRYPOINT ["java", "-jar", "moqui.war"]
76 ENTRYPOINT ["java", "-cp", ".", "MoquiStart", "port=8080"]
77
78 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
79 # specify this as a default parameter if none are specified with docker exec/run, ie run production by default
80 CMD ["conf=conf/MoquiProductionConf.xml"]
81