# Installs Node image
FROM node:18-alpine as base

# sets the working directory for any RUN, CMD, COPY command
WORKDIR /app

# Install Python and pip
RUN apk add --update python3 py3-pip
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools

COPY ./data ./data

# Copies stuff to cache for install
COPY ./package.json ./package-lock.json tsconfig.json ./

RUN echo "npm install"

RUN npm install

# Copies everything in the src directory to WORKDIR/src
COPY ./src ./src
COPY ./scripts ./scripts

# Run the server
RUN echo "npm run prod-start"
CMD ["npm", "run", "prod-start"]