2023-11-23 21:49:14 +01:00
|
|
|
# syntax=docker/dockerfile:1.4.0
|
2023-07-27 00:18:55 +02:00
|
|
|
|
|
|
|
ARG MAVEN_CLI_OPTS="--batch-mode --no-transfer-progress -Dmaven.test.skip"
|
|
|
|
|
|
|
|
# Copy all project files
|
2023-11-23 20:07:26 +01:00
|
|
|
FROM docker.io/maven:3.9-eclipse-temurin-21 AS setup
|
2023-05-16 01:49:44 +02:00
|
|
|
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
|
2023-07-27 00:18:55 +02:00
|
|
|
RUN --mount=type=cache,target=/root/.m2/ \
|
2023-07-27 00:28:04 +02:00
|
|
|
mvn ${MAVEN_CLI_OPTS} -pl db -am dependency:go-offline
|
2023-05-16 01:49:44 +02:00
|
|
|
# Install the shared libraries in the local Maven repo (`.m2`)
|
|
|
|
# This will also install the `root` module.
|
2023-07-27 00:18:55 +02:00
|
|
|
|
|
|
|
# Build db dependency
|
|
|
|
FROM setup AS db-build
|
2023-05-16 01:49:44 +02:00
|
|
|
COPY db db
|
2023-07-27 00:18:55 +02:00
|
|
|
RUN --mount=type=cache,target=/root/.m2/ \
|
2023-07-27 00:28:04 +02:00
|
|
|
mvn ${MAVEN_CLI_OPTS} -pl db -am install
|
2023-05-16 01:49:44 +02:00
|
|
|
# Resolve dependencies for modules without dependencies to each other
|
2023-07-27 00:18:55 +02:00
|
|
|
RUN --mount=type=cache,target=/root/.m2/ \
|
2023-07-27 00:28:04 +02:00
|
|
|
mvn ${MAVEN_CLI_OPTS} dependency:go-offline
|
2023-07-27 00:18:55 +02:00
|
|
|
|
2023-05-16 01:49:44 +02:00
|
|
|
# Build modules
|
2023-07-27 00:18:55 +02:00
|
|
|
FROM db-build AS web-build
|
2023-05-16 01:49:44 +02:00
|
|
|
COPY web web
|
2023-07-27 00:18:55 +02:00
|
|
|
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/ \
|
2023-07-27 00:28:04 +02:00
|
|
|
mvn ${MAVEN_CLI_OPTS} -pl web package
|
2023-07-27 00:18:55 +02:00
|
|
|
|
|
|
|
FROM db-build AS bot-build
|
2023-05-16 01:49:44 +02:00
|
|
|
COPY bot bot
|
2023-07-27 00:18:55 +02:00
|
|
|
RUN --mount=type=cache,target=/root/.m2/ \
|
2023-07-27 00:28:04 +02:00
|
|
|
mvn ${MAVEN_CLI_OPTS} -pl bot package
|
2023-07-27 00:18:55 +02:00
|
|
|
|
|
|
|
FROM db-build AS migration-build
|
2023-05-16 01:49:44 +02:00
|
|
|
COPY migration migration
|
2023-07-27 00:18:55 +02:00
|
|
|
RUN --mount=type=cache,target=/root/.m2/ \
|
2023-07-27 00:28:04 +02:00
|
|
|
mvn ${MAVEN_CLI_OPTS} -pl migration package
|
2023-05-16 01:49:44 +02:00
|
|
|
|
2023-07-27 00:18:55 +02:00
|
|
|
# Create final web
|
2023-11-23 20:07:26 +01:00
|
|
|
FROM docker.io/eclipse-temurin:21-jdk-jammy AS web
|
2023-05-16 01:49:44 +02:00
|
|
|
WORKDIR /app
|
2023-07-27 00:18:55 +02:00
|
|
|
COPY --from=web-build /app/web/target/web-*-fat.jar /app/web.jar
|
2023-05-16 01:49:44 +02:00
|
|
|
EXPOSE 8080
|
|
|
|
CMD ["java", "-jar", "/app/web.jar"]
|
|
|
|
|
2023-07-27 00:18:55 +02:00
|
|
|
# Create final migration
|
2023-11-23 20:07:26 +01:00
|
|
|
FROM docker.io/eclipse-temurin:21-jdk-jammy AS migration
|
2023-05-16 01:49:44 +02:00
|
|
|
WORKDIR /app
|
2023-07-27 00:18:55 +02:00
|
|
|
COPY --from=migration-build /app/migration/target/migration-*-fat.jar /app/migration.jar
|
2023-05-16 01:49:44 +02:00
|
|
|
CMD ["java", "-jar", "/app/migration.jar"]
|
|
|
|
|
2023-07-27 00:18:55 +02:00
|
|
|
# Create final bot
|
2023-11-23 20:07:26 +01:00
|
|
|
FROM docker.io/eclipse-temurin:21-jdk-jammy AS bot
|
2023-05-16 01:49:44 +02:00
|
|
|
WORKDIR /app
|
2023-07-27 00:18:55 +02:00
|
|
|
COPY --from=bot-build /app/bot/target/bot-*-fat.jar /app/bot.jar
|
2023-05-16 01:49:44 +02:00
|
|
|
CMD ["java", "-jar", "/app/bot.jar"]
|
2023-11-23 20:49:58 +01:00
|
|
|
|
|
|
|
# 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
|
2023-11-23 21:49:14 +01:00
|
|
|
|
|
|
|
# Create caddy reverse proxy
|
|
|
|
FROM docker.io/caddy AS caddy
|
|
|
|
RUN <<EOF cat > /etc/caddy/Caddyfile
|
2023-12-07 16:36:27 +01:00
|
|
|
{
|
|
|
|
debug
|
|
|
|
auto_https off
|
|
|
|
}
|
|
|
|
|
2023-12-08 20:06:28 +01:00
|
|
|
:8080 {
|
|
|
|
route {
|
|
|
|
reverse_proxy /api/* web:8080
|
|
|
|
reverse_proxy ui:80
|
|
|
|
}
|
2023-12-07 16:36:27 +01:00
|
|
|
}
|
2023-11-23 21:49:14 +01:00
|
|
|
EOF
|
|
|
|
|
|
|
|
EXPOSE 8080
|