FROM node:16-alpine

# install node_modules outside app root in container so local development won't run into a problem of bind-mounting over it with local source code
WORKDIR /usr/src

COPY ["package.json", "package-lock.json", "./"]
RUN npm install
# ensures that exactly these executables (from the node_modules folder) are used instead of any other executables which might also be installed on the system inside the Docker image
ENV PATH=/usr/src/node_modules/.bin:$PATH

WORKDIR /usr/src/app

COPY prisma/schema.prisma ./prisma/
RUN npx prisma generate

COPY . .

RUN npm run build