-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDockerfile
64 lines (50 loc) · 2.74 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
ARG METAPHACTORY_VERSION=5.6.0
ARG METAPHACTORY_IMAGE=metaphacts/metaphactory
ARG GRADLE_VERSION=8-jdk17
# define metaphactory base image (used below)
FROM ${METAPHACTORY_IMAGE}:${METAPHACTORY_VERSION} AS metaphactory-base
# define app-builder image
FROM gradle:${GRADLE_VERSION} AS app-builder
RUN mkdir /tmp/build \
&& mkdir /tmp/build/installedapps \
&& chown -R 100:0 "/tmp/build/installedapps" \
&& chmod -R g=u "/tmp/build/installedapps" \
&& chmod -R g+ws "/tmp/build/installedapps"
WORKDIR /tmp/build
# copy ROOT.war from metaphactory to extract dependencies
# and libraries required for building Java-based apps
COPY --chown=jetty:jetty --from=metaphactory-base /var/lib/jetty/webapps/ROOT.war /tmp/build/ROOT.war
# copy work dir containing the app project (incl. app build scripts
# taken from sample-apps repo) to the builder image
COPY --chown=jetty:jetty . /tmp/build
RUN echo "platformLocation=/tmp/build/ROOT.war" > /tmp/build/gradle.properties \
&& gradle --info prepareEnvironment
RUN gradle --info clean appZip \
&& echo "apps: " \
&& ls -l /tmp/build/target/apps/ \
&& for app in $(ls -1 /tmp/build/target/apps/*.zip); do \
echo "extracting app $app to folder $(basename $app .zip)" && unzip "$app" -d "/tmp/build/installedapps/$(basename $app .zip)" ; \
done \
&& echo "final apps:" \
&& ls -l /tmp/build/installedapps/
FROM metaphactory-base
# copy zipped apps from /tmp/build/target/apps/ in "build" image
COPY --from=app-builder --chown=jetty:root /tmp/build/target/apps/ /zippedapps/
# copy built and extracted apps from /tmp/build/installedapps in "build" image
COPY --from=app-builder --chown=jetty:root /tmp/build/installedapps /installedapps/
# auto-activate each app using an environment variable MP_APP_XXX pointing to the respective app:
# note: this can also be done on-demand when deploying the container,
# e.g. in a docker-compose file or Kubernetes Pod definition
#ENV MP_APP_1=/installedapps/app1
#ENV MP_APP_2=/installedapps/app2
#ENV MP_APP_3=/installedapps/app3
# to build the container with apps use the following command:
# docker build --build-arg METAPHACTORY_VERSION=5.6.0 -t metaphactory-with-apps:5.6.0 .
# to run the container with one example app use the following command:
# docker run --detach --publish 10214:8080 --env MP_APP_1=/installedapps/eventsubscriber-example --name metaphactory-test metaphactory-with-apps
# to inspect the container created using the previous command use the following command:
# docker inspect metaphactory-test
# to run a command within the container created using the previous command use the following command:
# docker exec -ti metaphactory-test bash
# to delete the container created using the previous command use the following command:
# docker rm -f metaphactory-test