#
# Build stage
#
FROM maven:3.9.3-eclipse-temurin-17-alpine AS build
WORKDIR /home/app
COPY pom.xml .
RUN mvn dependency:go-offline
COPY src ./src
RUN mvn clean javadoc:javadoc package

#
# Generate index.html
#
FROM pandoc/core:3.1-ubuntu as mainPage
WORKDIR /home/app
COPY README.md .
RUN pandoc -s -o index.html README.md

#
# Package stage
#
FROM nginx:stable-alpine
COPY --from=build /home/app/target/site /usr/share/nginx/html
COPY --from=build /home/app/target/Lab5-1.0-jar-with-dependencies.jar /usr/share/nginx/html/app.jar
COPY --from=mainPage /home/app/index.html /usr/share/nginx/html
COPY ./nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
