# syntax=docker/dockerfile:1.4.0 ARG MAVEN_CLI_OPTS="--batch-mode --no-transfer-progress -Dmaven.test.skip" # Copy all project files FROM docker.io/maven:3.9-eclipse-temurin-21 AS setup WORKDIR /app # Copy the dependency specifications COPY pom.xml . COPY db/pom.xml db/ COPY bot/pom.xml bot/ COPY migration/pom.xml migration/ COPY web/pom.xml web/ # Resolve dependencies for shared libraries RUN --mount=type=cache,target=/root/.m2/ \ mvn ${MAVEN_CLI_OPTS} -pl db -am dependency:go-offline # Install the shared libraries in the local Maven repo (`.m2`) # This will also install the `root` module. # Build db dependency FROM setup AS db-build COPY db db RUN --mount=type=cache,target=/root/.m2/ \ mvn ${MAVEN_CLI_OPTS} -pl db -am install # Resolve dependencies for modules without dependencies to each other RUN --mount=type=cache,target=/root/.m2/ \ mvn ${MAVEN_CLI_OPTS} dependency:go-offline # Build modules FROM db-build AS web-build COPY web web RUN --mount=type=cache,target=/root/.m2/ \ --mount=type=cache,target=/app/web/src/ui/dist/ \ --mount=type=cache,target=/app/web/src/ui/node/ \ --mount=type=cache,target=/app/web/src/ui/node_modules/ \ mvn ${MAVEN_CLI_OPTS} -pl web package FROM db-build AS bot-build COPY bot bot RUN --mount=type=cache,target=/root/.m2/ \ mvn ${MAVEN_CLI_OPTS} -pl bot package FROM db-build AS migration-build COPY migration migration RUN --mount=type=cache,target=/root/.m2/ \ mvn ${MAVEN_CLI_OPTS} -pl migration package # Create final web FROM docker.io/eclipse-temurin:21-jdk-jammy AS web WORKDIR /app COPY --from=web-build /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:21-jdk-jammy AS migration WORKDIR /app COPY --from=migration-build /app/migration/target/migration-*-fat.jar /app/migration.jar CMD ["java", "-jar", "/app/migration.jar"] # Create final bot FROM docker.io/eclipse-temurin:21-jdk-jammy AS bot WORKDIR /app COPY --from=bot-build /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/* web:8080 reverse_proxy ui:80 } } EOF EXPOSE 8080