|
| 1 | +FROM {{.BASE_OS_IMAGE}} AS maven |
| 2 | + |
| 3 | +RUN yum upgrade --disableplugin=subscription-manager -y \ |
| 4 | + && yum clean --disableplugin=subscription-manager packages \ |
| 5 | + && echo 'Finished installing dependencies' |
| 6 | + |
| 7 | +RUN useradd --uid 1001 --gid 0 --shell /bin/bash --create-home java_user |
| 8 | + |
| 9 | +# Dependency install |
| 10 | +RUN yum install --disableplugin=subscription-manager -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm \ |
| 11 | + && yum install --disableplugin=subscription-manager -y unzip curl ca-certificates wget xmlstarlet |
| 12 | + |
| 13 | +# Maven install |
| 14 | +ARG MAVEN_VERSION=3.6.3 |
| 15 | +ARG SHA=c35a1803a6e70a126e80b2b3ae33eed961f83ed74d18fcd16909b2d44d7dada3203f1ffe726c17ef8dcca2dcaa9fca676987befeadc9b9f759967a8cb77181c0 |
| 16 | +ARG BASE_URL=https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/ |
| 17 | + |
| 18 | +RUN mkdir -p /usr/share/maven /usr/share/maven/ref \ |
| 19 | + && curl -fsSL -o /tmp/apache-maven.tar.gz ${BASE_URL}/apache-maven-${MAVEN_VERSION}-bin.tar.gz \ |
| 20 | + && echo "${SHA} /tmp/apache-maven.tar.gz" | sha512sum -c - \ |
| 21 | + && tar -xzf /tmp/apache-maven.tar.gz -C /usr/share/maven --strip-components=1 \ |
| 22 | + && rm -f /tmp/apache-maven.tar.gz \ |
| 23 | + && ln -s /usr/share/maven/bin/mvn /usr/bin/mvn |
| 24 | + |
| 25 | +FROM maven AS builder |
| 26 | + |
| 27 | +ENV OPENJ9_JAVA_OPTIONS="-Xshareclasses:name=liberty,nonfatal,cacheDir=/output/.classCache/" |
| 28 | + |
| 29 | +RUN umask -S u=rwx,g=rwx,o=rx; mkdir -p /mvn/repository \ |
| 30 | + && chown -R java_user /mvn \ |
| 31 | + && chmod 775 /mvn \ |
| 32 | + && mkdir -p /stacks/java-openliberty/priming-app \ |
| 33 | + && chown -R java_user /stacks \ |
| 34 | + && mkdir -p /output \ |
| 35 | + && chown -R java_user /output \ |
| 36 | + && chmod 775 /output |
| 37 | + |
| 38 | +COPY ./LICENSE /licenses/ |
| 39 | + |
| 40 | +USER java_user |
| 41 | + |
| 42 | +ADD ./priming-app/src /stacks/java-openliberty/priming-app/src |
| 43 | +COPY --chown=1001:0 ./priming-app/pom.xml /stacks/java-openliberty/priming-app/ |
| 44 | + |
| 45 | +WORKDIR /stacks/java-openliberty/priming-app |
| 46 | + |
| 47 | +ARG LIBERTY_RUNTIME_VERSION={{.OL_RUNTIME_VERSION}} |
| 48 | + |
| 49 | +RUN umask -S u=rwx,g=rwx,o=rx; mvn -B -e -DserverName=tmp -Dmaven.repo.local=/mvn/repository -Dliberty.runtime.version=${LIBERTY_RUNTIME_VERSION} -DskipITs=true install |
| 50 | + |
| 51 | +# |
| 52 | +# A hack maybe but there's quite a few dependencies that only are detected when dev mode is executed, due to use of mojo executor, etc. |
| 53 | +# |
| 54 | +# If you see this then you got enough cached, but if you don't, you need to build with --no-cache next time or you won't even redo this step |
| 55 | +# |
| 56 | +# [INFO] |
| 57 | +# [INFO] ------------------------------------------------------- |
| 58 | +# [INFO] T E S T S |
| 59 | +# [INFO] ------------------------------------------------------- |
| 60 | +# [INFO] Running dev.odo.starter.it.EndpointIT |
| 61 | +# [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.134 s - in dev.odo.starter.it.EndpointIT |
| 62 | +# [INFO] |
| 63 | +# [INFO] Results: |
| 64 | +# [INFO] |
| 65 | +# [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 |
| 66 | +# [INFO] |
| 67 | +# [INFO] Failsafe report directory: /stacks/java-openliberty/priming-app/target/test-reports/it |
| 68 | +# [INFO] Integration tests finished. |
| 69 | +# |
| 70 | +# Done sleeping |
| 71 | + |
| 72 | +# |
| 73 | +RUN nohup bash -c "umask -S u=rwx,g=rwx,o=rx; mvn -B -e -DserverName=tmp -Dmaven.repo.local=/mvn/repository -Dliberty.runtime.version=${LIBERTY_RUNTIME_VERSION} liberty:dev -DhotTests=true &" \ |
| 74 | + && sleep 600 \ |
| 75 | + && echo && echo "Done sleeping" && echo |
| 76 | + |
| 77 | +# Grab the runtime artifact as well, it's big and it might be useful |
| 78 | +RUN umask -S u=rwx,g=rwx,o=rx; mvn -B -e -Dmaven.repo.local=/mvn/repository -Dartifact=io.openliberty:openliberty-runtime:${LIBERTY_RUNTIME_VERSION}:zip -DrepoUrl=https://repo1.maven.org/maven2/ org.apache.maven.plugins:maven-dependency-plugin:3.1.2:get |
| 79 | + |
| 80 | +# Delete the server, users will create their own server |
| 81 | +RUN rm -rf /stacks/java-openliberty/priming-app/target/liberty/wlp/usr/servers/tmp |
| 82 | +# Don't let the sample appear in the user repo |
| 83 | +RUN rm -rf /mvn/repository/dev/odo/java-openliberty/samples/priming-app |
| 84 | + |
| 85 | +FROM maven |
| 86 | + |
| 87 | +ENV OPENJ9_JAVA_OPTIONS="-Xshareclasses:name=liberty,nonfatal,cacheDir=/output/.classCache/" |
| 88 | + |
| 89 | +RUN mkdir -p /output \ |
| 90 | + && chown -R java_user /output \ |
| 91 | + && chmod 775 /output \ |
| 92 | + && mkdir -p /opt/ol \ |
| 93 | + && chown -R java_user /opt/ol \ |
| 94 | + && chmod 775 /opt/ol \ |
| 95 | + && mkdir -p /work/outer-loop-app \ |
| 96 | + && chown -R java_user /work \ |
| 97 | + && chmod -R 775 /work |
| 98 | +# Point to local /mvn/repository within container |
| 99 | +COPY --chown=1001:0 ./mvn-stack-settings.xml /usr/share/maven/conf/settings.xml |
| 100 | +COPY --chown=1001:0 --from=builder /mvn /mvn |
| 101 | + |
| 102 | +COPY --chown=1001:0 --from=builder /stacks/java-openliberty/priming-app/target/liberty /opt/ol |
| 103 | +COPY --chown=1001:0 ./LICENSE /licenses/ |
| 104 | + |
| 105 | +USER java_user |
| 106 | +CMD /bin/bash |
0 commit comments