FROM node:lts-alpine

RUN mkdir -p /home/node/app/node_modules && chown -R node:node /home/node/app
WORKDIR /home/node/app
USER node
COPY --chown=node:node package*.json ./
RUN npm install
COPY --chown=node:node . .
RUN npm run build
USER root
RUN npm install -g serve
USER node

EXPOSE 3000

CMD [ "serve", "-s", "build" ]
