Skip to content

Commit

Permalink
Fix update
Browse files Browse the repository at this point in the history
  • Loading branch information
acetousk committed Aug 10, 2024
1 parent 5ee37b8 commit a3f91fb
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ WORKDIR /opt/moqui
LABEL org.opencontainers.image.authors="[email protected]"

# Arguments
# create user for search and chown corresponding files
ARG GRADLE_COMMAND=""
ARG GRADLE_ARGS="--info --no-daemon --parallel"
ARG COMPONENT=""
ARG COMPONENT_SET=""
ARG RUN_LOCAL_SEARCH="true"
# create user for search and chown corresponding files
ARG search_name=opensearch
ARG search_name="opensearch"

# Copy source code
COPY . ./
Expand Down
68 changes: 68 additions & 0 deletions acetousk.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# syntax=docker/dockerfile:1

# Base build stage
FROM gradle:7.4.1-jdk11 AS build
WORKDIR /opt/moqui
LABEL org.opencontainers.image.authors="[email protected]"

# Arguments
# create user for search and chown corresponding files
ARG GRADLE_COMMAND=""
ARG GRADLE_ARGS="--info --no-daemon --parallel"
ARG COMPONENT=""
ARG COMPONENT_SET="acetousk"
ARG RUN_LOCAL_SEARCH="true"
ARG search_name="opensearch"

# Copy source code
COPY . ./

# Build and unzip application
RUN sh start.sh && unzip -q -o moqui-plus-runtime.war

# Copied from docker/simple/Dockerfile
# 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
FROM eclipse-temurin:11-jre
WORKDIR /opt/moqui
ARG search_name=opensearch

COPY --from=build /opt/moqui/WEB-INF WEB-INF
COPY --from=build /opt/moqui/META-INF META-INF
COPY --from=build /opt/moqui/*.class ./
COPY --from=build /opt/moqui/execlib execlib
COPY --from=build /opt/moqui/runtime runtime

RUN if [ "$RUN_LOCAL_SEARCH" == "true" ]; then \
if [ -d runtime/opensearch/bin ]; then \
echo "Installing OpenSearch User"; \
search_name=opensearch; \
groupadd -g 1000 opensearch 2>/dev/null || echo "group 1000 already exists" && \
useradd -u 1000 -g 1000 -G 0 -d /opt/moqui/runtime/opensearch opensearch 2>/dev/null || echo "user 1000 already exists" && \
chmod 0775 /opt/moqui/runtime/opensearch && \
chown -R 1000:0 /opt/moqui/runtime/opensearch; \
fi; \
if [ -d runtime/elasticsearch/bin ]; then \
echo "Installing ElasticSearch User"; \
search_name=elasticsearch; \
groupadd -r elasticsearch && \
useradd --no-log-init -r -g elasticsearch -d /opt/moqui/runtime/elasticsearch elasticsearch && \
chown -R elasticsearch:elasticsearch runtime/elasticsearch; \
fi; \
fi

# exposed as volumes for configuration purposes
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
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, Search HTTP Port, Search Cluster (TCP Transport) Port, Hazelcast Cluster Port
EXPOSE 80 9200 9300 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=80"]

HEALTHCHECK --interval=15s --timeout=600ms --start-period=15s CMD curl -f -H "X-Forwarded-Proto: https" -H "X-Forwarded-Ssl: on" http://localhost/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"]
2 changes: 1 addition & 1 deletion myaddons.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<addons default-repository="github-ssh">
<addons default-repository="github">
<!-- Where to get runtime directory if not present -->
<runtime name="moqui-runtime" group="acetousk" branch="acetousk"/>

Expand Down
9 changes: 3 additions & 6 deletions start.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ COMPONENT_SET=${COMPONENT_SET:=""}

RUN_LOCAL_SEARCH=${RUN_LOCAL_SEARCH:="true"}
search_name=${search_name:="opensearch"}
get_hazelcast () { if [ $USE_HAZELCAST = "true" ]; then echo "Getting moqui-hazelcast"; gradle $GRADLE_ARGS getComponent -Pcomponent=moqui-hazelcast; fi }
get_component () { if [ -n "$COMPONENT" ]; then echo "Getting $COMPONENT"; gradle $GRADLE_ARGS getComponent -Pcomponent=$COMPONENT; fi }
get_component_set () { if [ -n "$COMPONENT_SET" ]; then echo "Getting $COMPONENT_SET"; gradle $GRADLE_ARGS getComponentSet -PcomponentSet=$COMPONENT_SET; fi }

if [ -f $MOQUI_HOME/moqui-plus-runtime.war ]; then echo "Using already built moqui-plus-runtime.war"
else
Expand All @@ -31,9 +28,9 @@ else

if [ -n "$GRADLE_COMMAND" ]; then echo "Running gradle $GRADLE_ARGS $GRADLE_COMMAND"; gradle $GRADLE_ARGS "$GRADLE_COMMAND"; fi

get_hazelcast
get_component
get_component_set
if [ $USE_HAZELCAST == "true" ]; then echo "Getting moqui-hazelcast"; gradle $GRADLE_ARGS getComponent -Pcomponent=moqui-hazelcast; fi
if [ -n "$COMPONENT" ]; then echo "Getting $COMPONENT"; gradle $GRADLE_ARGS getComponent -Pcomponent=$COMPONENT; fi
if [ -n "$COMPONENT_SET" ]; then echo "Getting $COMPONENT_SET"; gradle $GRADLE_ARGS getComponentSet -PcomponentSet=$COMPONENT_SET; fi

echo "Getting Dependencies"; gradle $GRADLE_ARGS getDepends
echo "Add runtime"; gradle $GRADLE_ARGS addRuntime
Expand Down

0 comments on commit a3f91fb

Please sign in to comment.