lwb6-in-2025/docker/Dockerfile.application

46 lines
1.3 KiB
Text

FROM maven:3-jdk-7 AS build
ENV BUILD_UID=1000
ENV BUILD=/src
ENV MAVEN_HOME=/var/maven
RUN mkdir -p $MAVEN_HOME && chown $BUILD_UID $MAVEN_HOME
ADD --chown=$BUILD_UID:$BUILD_UID .. $BUILD
USER $BUILD_UID
WORKDIR $BUILD
RUN --mount=type=cache,target=$MAVEN_HOME/.m2,uid=$BUILD_UID \
mvn -e -Duser.home=$MAVEN_HOME package
FROM openjdk:7u211-jre-alpine AS backend
RUN <<EOF
set -e
mkdir -p /app/state
chown -R 1000 /app/state
EOF
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/target/*.jar /app/server.jar
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/target/lib /app/lib
COPY --from=build /src/legacyworlds-server/legacyworlds-server-main/data /app/data
ADD docker/backend-entrypoint.sh /app/entrypoint.sh
VOLUME /app/state
ENTRYPOINT ["/app/entrypoint.sh"]
CMD ["server"]
FROM tomcat:6.0-jre7 AS tomcat-base
RUN <<EOF
rm -rf /usr/local/tomcat/webapps/*
adduser --system --no-create-home \
--ingroup www-data \
--shell /bin/false \
--home $CATALINA_HOME \
tomcat
chown -R tomcat: /usr/local/tomcat
EOF
USER tomcat
FROM tomcat-base AS lwmain
COPY --from=build \
/src/legacyworlds-web/legacyworlds-web-main/target/*.war \
$CATALINA_HOME/webapps/ROOT.war
FROM tomcat-base AS lwadmin
COPY --from=build \
/src/legacyworlds-web/legacyworlds-web-main/target/*.war \
$CATALINA_HOME/webapps/ROOT.war