FROM gradle:latest as build_backend

COPY --chownn=gradle:gradle . /home/gradle/src
WORKDIR /home/gradle/src
RUN gradle buildFatJar --no-daemon

FROM node:18 as build_frontend

RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
COPY --chown=node:node /pub


FROM openjdk:latest
LABEL authors="walamana"

RUN mkdir /miniplan

COPY ./build/libs/minis-backend-all.jar /miniplan/backend.jar
COPY ./application_docker.conf /miniplan/application.conf
ADD ./../../public/dist /miniplan/public

WORKDIR /miniplan

ENTRYPOINT ["java", "-jar", "backend.jar", "-config=application.conf"]
