Add support for git submodules.
Showing
3 changed files
with
51 additions
and
5 deletions
1 | # syntax=docker/dockerfile:1.4 | ||
1 | # Builds a minimal docker image with openjdk and moqui with various volumes for configuration and persisted data outside the container | 2 | # 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 | # 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 | ARG RUNTIME_IMAGE=eclipse-temurin:11-jdk |
... | @@ -5,7 +6,7 @@ FROM ${RUNTIME_IMAGE} AS moqui-base | ... | @@ -5,7 +6,7 @@ FROM ${RUNTIME_IMAGE} AS moqui-base |
5 | 6 | ||
6 | RUN true \ | 7 | RUN true \ |
7 | && apt-get update \ | 8 | && apt-get update \ |
8 | && apt-get install -y unzip less \ | 9 | && apt-get install -y unzip less git \ |
9 | && apt-get clean && rm -rf /var/lib/apt/lists/* \ | 10 | && apt-get clean && rm -rf /var/lib/apt/lists/* \ |
10 | && groupadd -g 1000 moqui \ | 11 | && groupadd -g 1000 moqui \ |
11 | && useradd -u 1000 -g 1000 -G 0 -d /opt/moqui moqui \ | 12 | && useradd -u 1000 -g 1000 -G 0 -d /opt/moqui moqui \ |
... | @@ -27,9 +28,18 @@ FROM moqui-base AS moqui-build | ... | @@ -27,9 +28,18 @@ FROM moqui-base AS moqui-build |
27 | 28 | ||
28 | WORKDIR /opt/moqui-build | 29 | WORKDIR /opt/moqui-build |
29 | 30 | ||
30 | COPY framework/ ./ | 31 | RUN ["mkdir", "/opt/moqui-scripts"] |
31 | COPY runtime/ runtime/ | 32 | COPY --from=moqui-builder fix-git-submodules /opt/moqui-scripts/fix-git-submodules |
32 | COPY component/ runtime/component/ | 33 | |
34 | COPY ./ /opt/moqui-app/ | ||
35 | |||
36 | RUN ["/opt/moqui-scripts/fix-git-submodules", "-start", "/opt/moqui-app"] | ||
37 | |||
38 | RUN true && set -x \ | ||
39 | && rm -rf /opt/moqui-build && ln -sf /opt/moqui-app/framework /opt/moqui-build \ | ||
40 | && rm -rf /opt/moqui-build/runtime && ln -sf /opt/moqui-app/runtime /opt/moqui-build/runtime \ | ||
41 | && rm -rf /opt/moqui-build/runtime/component && ln -sf /opt/moqui-app/component /opt/moqui-build/runtime/component \ | ||
42 | && true | ||
33 | 43 | ||
34 | RUN ["./gradlew", "--no-daemon", "--info", "build", "addRuntime"] | 44 | RUN ["./gradlew", "--no-daemon", "--info", "build", "addRuntime"] |
35 | 45 | ... | ... |
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | set -e | ||
4 | |||
3 | TAG=test-latest | 5 | TAG=test-latest |
4 | APP=moqui-app | 6 | APP=moqui-app |
5 | PUSH_TO=docker://5.161.91.120:31234 | 7 | PUSH_TO=docker://5.161.91.120:31234 |
6 | PREFIX= | 8 | PREFIX= |
7 | declare -a images=(moqui-jdbc-drivers moqui-app) | 9 | declare -a images=(moqui-jdbc-drivers moqui-app) |
8 | 10 | ||
11 | TOP_DIR="$(cd "$(dirname "$0")"; pwd -P)" | ||
12 | |||
9 | _build() { | 13 | _build() { |
10 | for image in "${images[@]}"; do | 14 | for image in "${images[@]}"; do |
11 | docker build -f Dockerfile --tag "${PREFIX}${image}:${TAG}" --target "${image}" "${APP}" | 15 | docker buildx build --progress plain --build-context "moqui-builder=$TOP_DIR" -f "${TOP_DIR}/Dockerfile" --tag "${PREFIX}${image}:${TAG}" --target "${image}" "${APP}" |
12 | done | 16 | done |
13 | } | 17 | } |
14 | 18 | ... | ... |
fix-git-submodules
0 → 100755
1 | #!/bin/bash | ||
2 | |||
3 | set -ex | ||
4 | |||
5 | cmd="$1" | ||
6 | shift | ||
7 | case "$cmd" in | ||
8 | (-start) | ||
9 | dir="$1" | ||
10 | shift | ||
11 | find "$dir" -type f -name '.git' -exec "$0" -fix "$dir" '{}' \; | ||
12 | ;; | ||
13 | (-fix) | ||
14 | dir="$1" | ||
15 | gitdir_link="$2" | ||
16 | gitdir_dir="$(dirname "$gitdir_link")" | ||
17 | read gitdir_token gitdir_location < "$gitdir_link" | ||
18 | case "$gitdir_location" in | ||
19 | (/*) | ||
20 | echo "Can't handle absolute gitdir location: $gitdir_location" 1>&2 | ||
21 | exit 1 | ||
22 | ;; | ||
23 | esac | ||
24 | cd "$gitdir_dir" | ||
25 | pushd "$gitdir_location" | ||
26 | git config --unset core.worktree | ||
27 | popd | ||
28 | rm .git | ||
29 | mv "$gitdir_location" .git | ||
30 | ;; | ||
31 | esac | ||
32 |
-
Please register or sign in to post a comment