# syntax=docker/dockerfile:1.4.0 ARG MAVEN_CLI_OPTS="--batch-mode --no-transfer-progress -Dmaven.test.skip" ARG SETUP_IMAGE=setup-image ARG TEMURIN_IMAGE_TAG=23-jdk-alpine # Copy all project files FROM docker.io/maven:3.9-eclipse-temurin-21 AS setup-image WORKDIR /app COPY . . RUN --mount=type=cache,target=/root/.m2/ \ mvn ${MAVEN_CLI_OPTS} package FROM ${SETUP_IMAGE} as setup # Create final monolith FROM docker.io/eclipse-temurin:${TEMURIN_IMAGE_TAG} AS monolith WORKDIR /app COPY --from=setup /app/monolith/target/monolith-*-fat.jar /app/monolith.jar CMD ["java", "-jar", "/app/monolith.jar"] # Create final web FROM docker.io/eclipse-temurin:${TEMURIN_IMAGE_TAG} AS web WORKDIR /app COPY --from=setup /app/web/target/web-*-fat.jar /app/web.jar EXPOSE 8080 CMD ["java", "-jar", "/app/web.jar"] # Create final migration FROM docker.io/eclipse-temurin:${TEMURIN_IMAGE_TAG} AS migration WORKDIR /app COPY --from=setup /app/migration/target/migration-*-fat.jar /app/migration.jar CMD ["java", "-jar", "/app/migration.jar"] # Create final bot FROM docker.io/eclipse-temurin:${TEMURIN_IMAGE_TAG} AS bot WORKDIR /app COPY --from=setup /app/bot/target/bot-*-fat.jar /app/bot.jar CMD ["java", "-jar", "/app/bot.jar"] # Build the ui FROM docker.io/node:18-alpine AS ui-build WORKDIR /ui COPY ui/package.json ui/package-lock.json . RUN npm ci COPY ui . RUN npm run build # Create final ui FROM docker.io/nginx AS ui COPY --from=ui-build ui/dist /usr/share/nginx/html # Create caddy reverse proxy FROM docker.io/caddy AS caddy RUN < /etc/caddy/Caddyfile { debug auto_https off } :8080 { route { reverse_proxy /api/* monolith:8080 reverse_proxy ui:80 } } EOF EXPOSE 8080