FROM node:18-bullseye

# Create app directory
WORKDIR /app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
COPY package*.json ./

RUN chgrp -R 0 /app && chmod -R g+rwX /app

RUN npm install --silent

# Bundle app source
COPY tsconfig.build.json .
COPY tsconfig.json .
COPY src src
COPY scripts scripts

RUN npm run build

CMD npm run start:prod

EXPOSE 3000