FROM node:lts-alpine3.17

# add project files to /app
ADD ./webapp /app
ADD ./common /app
WORKDIR /app

# build frontend
RUN mkdir public/ && cd frontend && rm -rf dist && npm install && npm run build && cp -r dist/* /app/public && rm -rf /app/frontend

# install node dependencies
RUN npm install && npx prisma generate

EXPOSE 8080

ENTRYPOINT ["/app/entrypoint.sh"]
