FROM maven:3-eclipse-temurin-21-jammy AS build # Install nodejs RUN apt-get update RUN apt-get install -y ca-certificates curl gnupg RUN mkdir -p /etc/apt/keyrings RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list RUN apt-get update RUN apt-get install nodejs -y # Stop running as root at this point RUN useradd -m vaadin WORKDIR /usr/src/app/ RUN chown vaadin:vaadin /usr/src/app/ USER vaadin # Copy pom.xml and prefetch dependencies so a repeated build can continue from the next step with existing dependencies COPY --chown=vaadin pom.xml ./ # Copy all needed project files to a folder COPY --chown=vaadin:vaadin src src # Build the production package, assuming that we validated the version before so no need for running tests again RUN mvn clean package -DskipTests -Pproduction --batch-mode # Running stage: the part that is used for running the application FROM eclipse-temurin:21-jre-jammy COPY --from=build /usr/src/app/target/*.jar /usr/app/website.jar RUN useradd -m vaadin USER vaadin EXPOSE 8080 CMD ["java", "-jar", "/usr/app/website.jar"]